12
12
# include < boost/network/uri/encode.hpp>
13
13
# include < boost/network/uri/decode.hpp>
14
14
# include < boost/spirit/include/qi.hpp>
15
+ # include < boost/fusion/include/std_pair.hpp>
15
16
16
17
17
18
namespace boost {
18
19
namespace network {
19
20
namespace uri {
20
21
namespace details {
21
22
template <
22
- typename Uri,
23
23
typename Map
24
24
>
25
25
struct key_value_sequence
26
- : spirit::qi::grammar<typename Uri::const_iterator_type , Map()>
26
+ : spirit::qi::grammar<uri::const_iterator , Map()>
27
27
{
28
- typedef typename Uri::const_iterator_type const_iterator_type;
29
-
30
28
key_value_sequence ()
31
29
: key_value_sequence::base_type(query)
32
30
{
@@ -36,79 +34,63 @@ struct key_value_sequence
36
34
value = +spirit::qi::char_ (" a-zA-Z_0-9/%" );
37
35
}
38
36
39
- spirit::qi::rule<const_iterator_type , Map()> query;
40
- spirit::qi::rule<const_iterator_type , std::pair<typename Uri::string_type, typename Uri::string_type >()> pair;
41
- spirit::qi::rule<const_iterator_type , typename Uri::string_type ()> key, value;
37
+ spirit::qi::rule<uri::const_iterator , Map()> query;
38
+ spirit::qi::rule<uri::const_iterator , std::pair<std::string, std::string >()> pair;
39
+ spirit::qi::rule<uri::const_iterator , typename std::string ()> key, value;
42
40
};
43
41
} // namespace details
44
42
45
43
template <
46
- class Tag ,
47
44
class Map
48
45
>
49
46
inline
50
- Map &query_map (const basic_uri<Tag> &uri , Map &map) {
51
- typename basic_uri<Tag> ::const_range_type range = uri .query_range ();
52
- details::key_value_sequence<basic_uri<Tag>, Map> parser;
47
+ Map &query_map (const uri &uri_ , Map &map) {
48
+ uri ::const_range_type range = uri_ .query_range ();
49
+ details::key_value_sequence<Map> parser;
53
50
spirit::qi::parse (boost::begin (range), boost::end (range), parser, map);
54
51
return map;
55
52
}
56
53
57
- template <
58
- class Tag
59
- >
60
- typename basic_uri<Tag>::string_type username (const basic_uri<Tag> &uri) {
61
- typename basic_uri<Tag>::const_range_type user_info_range = uri.user_info_range ();
62
- typename basic_uri<Tag>::const_iterator_type it (boost::begin (user_info_range)), end (boost::end (user_info_range));
54
+ std::string username (const uri &uri_) {
55
+ uri::const_range_type user_info_range = uri_.user_info_range ();
56
+ uri::const_iterator it (boost::begin (user_info_range)), end (boost::end (user_info_range));
63
57
for (; it != end; ++it) {
64
58
if (*it == ' :' ) {
65
59
break ;
66
60
}
67
61
}
68
- return typename string<Tag>:: type (boost::begin (user_info_range), it);
62
+ return std::string (boost::begin (user_info_range), it);
69
63
}
70
64
71
- template <
72
- class Tag
73
- >
74
- typename basic_uri<Tag>::string_type password (const basic_uri<Tag> &uri) {
75
- typename basic_uri<Tag>::const_range_type user_info_range = uri.user_info_range ();
76
- typename basic_uri<Tag>::const_iterator_type it (boost::begin (user_info_range)), end (boost::end (user_info_range));
65
+ std::string password (const uri &uri_) {
66
+ uri::const_range_type user_info_range = uri_.user_info_range ();
67
+ uri::const_iterator it (boost::begin (user_info_range)), end (boost::end (user_info_range));
77
68
for (; it != end; ++it) {
78
69
if (*it == ' :' ) {
79
70
++it;
80
71
break ;
81
72
}
82
73
}
83
- return typename string<Tag>:: type (it, boost::end (user_info_range));
74
+ return std::string (it, boost::end (user_info_range));
84
75
}
85
76
86
- template <
87
- class Tag
88
- >
89
- typename basic_uri<Tag>::string_type decoded_path (const basic_uri<Tag> &uri) {
90
- typename basic_uri<Tag>::const_range_type path_range = uri.path_range ();
91
- typename basic_uri<Tag>::string_type decoded_path;
77
+ std::string decoded_path (const uri &uri_) {
78
+ uri::const_range_type path_range = uri_.path_range ();
79
+ std::string decoded_path;
92
80
decode (path_range, std::back_inserter (decoded_path));
93
81
return decoded_path;
94
82
}
95
83
96
- template <
97
- class Tag
98
- >
99
- typename basic_uri<Tag>::string_type decoded_query (const basic_uri<Tag> &uri) {
100
- typename basic_uri<Tag>::const_range_type query_range = uri.query_range ();
101
- typename basic_uri<Tag>::string_type decoded_query;
84
+ std::string decoded_query (const uri &uri_) {
85
+ uri::const_range_type query_range = uri_.query_range ();
86
+ std::string decoded_query;
102
87
decode (query_range, std::back_inserter (decoded_query));
103
88
return decoded_query;
104
89
}
105
90
106
- template <
107
- class Tag
108
- >
109
- typename basic_uri<Tag>::string_type decoded_fragment (const basic_uri<Tag> &uri) {
110
- typename basic_uri<Tag>::const_range_type fragment_range = uri.fragment_range ();
111
- typename basic_uri<Tag>::string_type decoded_fragment;
91
+ std::string decoded_fragment (const uri &uri_) {
92
+ uri::const_range_type fragment_range = uri_.fragment_range ();
93
+ std::string decoded_fragment;
112
94
decode (fragment_range, std::back_inserter (decoded_fragment));
113
95
return decoded_fragment;
114
96
}
0 commit comments