2
2
# define __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__
3
3
4
4
5
- # include < boost/network/support/is_pod.hpp>
6
- # include < boost/utility/enable_if.hpp>
7
- # include < boost/mpl/if.hpp>
8
- # include < boost/mpl/or.hpp>
5
+ # include < boost/network/uri/encode.hpp>
6
+ # include < boost/range/begin.hpp>
7
+ # include < boost/range/end.hpp>
9
8
10
9
11
10
namespace boost {
@@ -24,19 +23,8 @@ struct query_directive {
24
23
class Tag
25
24
, template <class > class Uri
26
25
>
27
- typename enable_if<is_pod<Tag>, void >::type
28
- operator () (Uri<Tag> &uri) const {
29
- static const char separator[] = {' ?' };
30
- uri.append (boost::begin (separator), boost::end (separator));
31
- uri.append (value);
32
- }
33
-
34
- template <
35
- class Tag
36
- , template <class > class Uri
37
- >
38
- typename enable_if<mpl::not_<is_pod<Tag> >, void >::type
39
- operator () (Uri<Tag> &uri) const {
26
+ void operator () (Uri<Tag> &uri) const {
27
+ typename string<Tag>::type encoded_value;
40
28
static const char separator[] = {' ?' };
41
29
uri.append (boost::begin (separator), boost::end (separator));
42
30
uri.append (value);
@@ -68,48 +56,26 @@ struct query_key_value_directive {
68
56
class Tag
69
57
, template <class > class Uri
70
58
>
71
- typename enable_if<is_pod< Tag>, void >::type
72
- operator () (Uri <Tag> &uri) const {
73
- static const char separator_1 [] = {' ?' };
74
- static const char separator_2 [] = {' =' };
75
- static const char separator_3 [] = {' ;' };
59
+ void operator () (Uri< Tag> &uri) const {
60
+ typename string <Tag>::type encoded_key, encoded_value;
61
+ static const char qmark [] = {' ?' };
62
+ static const char equal [] = {' =' };
63
+ static const char scolon [] = {' ;' };
76
64
if (!uri.query_range ())
77
65
{
78
- uri.append (boost::begin (separator_1 ), boost::end (separator_1 ));
66
+ uri.append (boost::begin (qmark ), boost::end (qmark ));
79
67
}
80
68
else
81
69
{
82
- uri.append (boost::begin (separator_3 ), boost::end (separator_3 ));
70
+ uri.append (boost::begin (scolon ), boost::end (scolon ));
83
71
}
84
- uri. append ( key);
85
- uri.append (boost::begin (separator_2), boost::end (separator_2) );
86
- typename string<Tag>::type encoded_value ;
87
- encode (boost::begin (value), boost::end (value), std::back_inserter (encoded_value));
72
+ encode ( boost::as_literal ( key), std::back_inserter (encoded_key) );
73
+ uri.append (encoded_key );
74
+ uri. append ( boost::begin (equal), boost::end (equal)) ;
75
+ encode (boost::as_literal (value), std::back_inserter (encoded_value));
88
76
uri.append (encoded_value);
89
77
}
90
78
91
- template <
92
- class Tag
93
- , template <class > class Uri
94
- >
95
- typename enable_if<mpl::not_<is_pod<Tag> >, void >::type
96
- operator () (Uri<Tag> &uri) const {
97
- static const char separator_1[] = {' ?' };
98
- static const char separator_2[] = {' =' };
99
- static const char separator_3[] = {' ;' };
100
- if (!uri.query_range ())
101
- {
102
- uri.append (boost::begin (separator_1), boost::end (separator_1));
103
- }
104
- else
105
- {
106
- uri.append (boost::begin (separator_3), boost::end (separator_3));
107
- }
108
- uri.append (key);
109
- uri.append (boost::begin (separator_2), boost::end (separator_2));
110
- uri.append (value);
111
- }
112
-
113
79
const KeyType &key;
114
80
const ValueType &value;
115
81
0 commit comments