22#define __BOOST_NETWORK_URI_DIRECTIVES_QUERY_INC__
33
44
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>
98
109
1110namespace boost {
@@ -24,19 +23,8 @@ struct query_directive {
2423class Tag
2524 ,template <class >class Uri
2625 >
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;
4028static const char separator[] = {' ?' };
4129 uri.append (boost::begin (separator),boost::end (separator));
4230 uri.append (value);
@@ -68,48 +56,26 @@ struct query_key_value_directive {
6856class Tag
6957 ,template <class >class Uri
7058 >
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 [] = {' ;' };
7664if (!uri.query_range ())
7765 {
78- uri.append (boost::begin (separator_1 ),boost::end (separator_1 ));
66+ uri.append (boost::begin (qmark ),boost::end (qmark ));
7967 }
8068else
8169 {
82- uri.append (boost::begin (separator_3 ),boost::end (separator_3 ));
70+ uri.append (boost::begin (scolon ),boost::end (scolon ));
8371 }
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));
8876 uri.append (encoded_value);
8977 }
9078
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-
11379const KeyType &key;
11480const ValueType &value;
11581