Skip to content

Commit 2ee819a

Browse files
committed
First (and limited) draft of URI builder syntax.
1 parent b14d676 commit 2ee819a

File tree

15 files changed

+289
-152
lines changed

15 files changed

+289
-152
lines changed

boost/network/uri/builder.hpp

Lines changed: 0 additions & 141 deletions
This file was deleted.

boost/network/uri/detail/parse_uri.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,10 @@ struct uri_grammar : qi::grammar<Iterator, detail::uri_parts<String>()> {
115115
;
116116

117117
ipv6address %= qi::raw[
118-
//qi::lit("1080:0:0:0:8:800:200C:417A")
119118
qi::repeat(6)[h16 >> ':'] >> ls32
120119
| "::" >> qi::repeat(5)[h16 >> ':'] >> ls32
121120
| qi::raw[ h16] >> "::" >> qi::repeat(4)[h16 >> ':'] >> ls32
122-
| qi::raw[+(*(h16 >> ':')) >> h16] >> "::" >> qi::repeat(3)[h16 >> ':'] >> ls32
121+
| qi::raw[ +(*(h16 >> ':')) >> h16] >> "::" >> qi::repeat(3)[h16 >> ':'] >> ls32
123122
| qi::raw[qi::repeat(2)[*(h16 >> ':')] >> h16] >> "::" >> qi::repeat(2)[h16 >> ':'] >> ls32
124123
| qi::raw[qi::repeat(3)[*(h16 >> ':')] >> h16] >> "::" >> h16 >> ':' >> ls32
125124
| qi::raw[qi::repeat(4)[*(h16 >> ':')] >> h16] >> "::" >> ls32

boost/network/uri/directives.hpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#ifndef __BOOST_NETWORK_URI_DIRECTIVES_INC__
2+
# define __BOOST_NETWORK_URI_DIRECTIVES_INC__
3+
4+
5+
# include <boost/network/uri/uri.hpp>
6+
# include <boost/network/uri/directives/scheme.hpp>
7+
# include <boost/network/uri/directives/user_info.hpp>
8+
# include <boost/network/uri/directives/host.hpp>
9+
# include <boost/network/uri/directives/port.hpp>
10+
# include <boost/network/uri/directives/authority.hpp>
11+
# include <boost/network/uri/directives/path.hpp>
12+
# include <boost/network/uri/directives/query.hpp>
13+
# include <boost/network/uri/directives/fragment.hpp>
14+
# include <boost/network/support/is_pod.hpp>
15+
# include <boost/utility/enable_if.hpp>
16+
# include <boost/mpl/if.hpp>
17+
# include <boost/mpl/or.hpp>
18+
19+
20+
namespace boost {
21+
namespace network {
22+
namespace uri {
23+
template <
24+
class Tag
25+
, class Directive
26+
>
27+
inline
28+
basic_uri<Tag> &operator << (basic_uri<Tag> &uri, const Directive &directive) {
29+
directive(uri);
30+
return uri;
31+
}
32+
} // namespace uri
33+
} // namespace network
34+
} // namespace boost
35+
36+
37+
#endif // __BOOST_NETWORK_URI_DIRECTIVES_INC__
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef __BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__
2+
# define __BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__
3+
4+
5+
namespace boost {
6+
namespace network {
7+
namespace uri {
8+
9+
} // namespace uri
10+
} // namespace network
11+
} // namespace boost
12+
13+
14+
#endif // __BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_INC__
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef __BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__
2+
# define __BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__
3+
4+
5+
namespace boost {
6+
namespace network {
7+
namespace uri {
8+
9+
} // namespace uri
10+
} // namespace network
11+
} // namespace boost
12+
13+
14+
#endif // __BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_INC__

boost/network/uri/directives/host.hpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#ifndef __BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__
2+
# define __BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__
3+
4+
5+
namespace boost {
6+
namespace network {
7+
namespace uri {
8+
template <
9+
class ValueType
10+
>
11+
struct host_directive {
12+
13+
explicit host_directive(const ValueType &value)
14+
: value(value)
15+
{}
16+
17+
template <
18+
class Tag
19+
, template <class> class Uri
20+
>
21+
typename enable_if<is_pod<Tag>, void>::type
22+
operator () (Uri<Tag> &uri) const {
23+
uri.append(value);
24+
}
25+
26+
template <
27+
class Tag
28+
, template <class> class Uri
29+
>
30+
typename enable_if<mpl::not_<is_pod<Tag> >, void>::type
31+
operator () (Uri<Tag> &uri) const {
32+
uri.append(value);
33+
}
34+
35+
const ValueType &value;
36+
37+
};
38+
39+
template <
40+
class T
41+
>
42+
inline
43+
host_directive<T> host(const T &value) {
44+
return host_directive<T>(value);
45+
}
46+
} // namespace uri
47+
} // namespace network
48+
} // namespace boost
49+
50+
51+
#endif // __BOOST_NETWORK_URI_DIRECTIVES_HOST_INC__

boost/network/uri/directives/path.hpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#ifndef __BOOST_NETWORK_URI_DIRECTIVES_PATH_INC__
2+
# define __BOOST_NETWORK_URI_DIRECTIVES_PATH_INC__
3+
4+
5+
namespace boost {
6+
namespace network {
7+
namespace uri {
8+
template <
9+
class ValueType
10+
>
11+
struct path_directive {
12+
13+
explicit path_directive(const ValueType &value)
14+
: value(value)
15+
{}
16+
17+
template <
18+
class Tag
19+
, template <class> class Uri
20+
>
21+
typename enable_if<is_pod<Tag>, void>::type
22+
operator () (Uri<Tag> &uri) const {
23+
uri.append(value);
24+
}
25+
26+
template <
27+
class Tag
28+
, template <class> class Uri
29+
>
30+
typename enable_if<mpl::not_<is_pod<Tag> >, void>::type
31+
operator () (Uri<Tag> &uri) const {
32+
uri.append(value);
33+
}
34+
35+
const ValueType &value;
36+
37+
};
38+
39+
template <
40+
class T
41+
>
42+
inline
43+
path_directive<T> path(const T &value) {
44+
return path_directive<T>(value);
45+
}
46+
} // namespace uri
47+
} // namespace network
48+
} // namespace boost
49+
50+
51+
#endif // __BOOST_NETWORK_URI_DIRECTIVES_PATH_INC__

boost/network/uri/directives/port.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef __BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__
2+
# define __BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__
3+
4+
5+
namespace boost {
6+
namespace network {
7+
namespace uri {
8+
9+
} // namespace uri
10+
} // namespace network
11+
} // namespace boost
12+
13+
14+
#endif // __BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__
2+
# define __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__
3+
4+
5+
namespace boost {
6+
namespace network {
7+
namespace uri {
8+
9+
} // namespace uri
10+
} // namespace network
11+
} // namespace boost
12+
13+
14+
#endif // __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__

0 commit comments

Comments
 (0)