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