Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit21015f7

Browse files
committed
Updated the builder directives & tests; added a very short example.
1 parenta1242bf commit21015f7

File tree

14 files changed

+189
-165
lines changed

14 files changed

+189
-165
lines changed

‎boost/network/uri/decode.hpp‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ template <
5959
classInputIterator,
6060
classOutputIterator
6161
>
62-
OutputIteratordecode(const InputIterator &in_begin,const InputIterator &in_end,const OutputIterator &out_begin) {
62+
OutputIteratordecode(const InputIterator &in_begin,
63+
const InputIterator &in_end,
64+
const OutputIterator &out_begin) {
6365
typedeftypename boost::iterator_value<InputIterator>::type value_type;
6466

6567
InputIterator it = in_begin;
@@ -87,7 +89,8 @@ template <
8789
classOutputIterator
8890
>
8991
inline
90-
OutputIteratordecode(const SinglePassRange &range,const OutputIterator &out) {
92+
OutputIteratordecode(const SinglePassRange &range,
93+
const OutputIterator &out) {
9194
returndecode(boost::begin(range),boost::end(range), out);
9295
}
9396
}// namespace uri

‎boost/network/uri/directives/authority.hpp‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
#define__BOOST_NETWORK_URI_DIRECTIVES_AUTHORITY_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/range/as_literal.hpp>
6+
97

108

119
namespaceboost {
@@ -24,17 +22,7 @@ struct authority_directive {
2422
classTag
2523
,template<class>classUri
2624
>
27-
typename enable_if<is_pod<Tag>,void>::type
28-
operator () (Uri<Tag> &uri)const {
29-
uri.append(value);
30-
}
31-
32-
template<
33-
classTag
34-
,template<class>classUri
35-
>
36-
typename enable_if<mpl::not_<is_pod<Tag> >,void>::type
37-
operator () (Uri<Tag> &uri)const {
25+
voidoperator () (Uri<Tag> &uri)const {
3826
uri.append(value);
3927
}
4028

‎boost/network/uri/directives/fragment.hpp‎

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
#define__BOOST_NETWORK_URI_DIRECTIVES_FRAGMENT_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

1110
namespaceboost {
@@ -24,22 +23,12 @@ struct fragment_directive {
2423
classTag
2524
,template<class>classUri
2625
>
27-
typename enable_if<is_pod<Tag>,void>::type
28-
operator () (Uri<Tag> &uri)const {
26+
voidoperator () (Uri<Tag> &uri)const {
27+
typename string<Tag>::type encoded_value;
2928
staticconstchar separator[] = {'#'};
3029
uri.append(boost::begin(separator),boost::end(separator));
31-
uri.append(value);
32-
}
33-
34-
template<
35-
classTag
36-
,template<class>classUri
37-
>
38-
typename enable_if<mpl::not_<is_pod<Tag> >,void>::type
39-
operator () (Uri<Tag> &uri)const {
40-
staticconstchar separator[] = {'#'};
41-
uri.append(boost::begin(separator),boost::end(separator));
42-
uri.append(value);
30+
encode(boost::as_literal(value),std::back_inserter(encoded_value));
31+
uri.append(encoded_value);
4332
}
4433

4534
const ValueType &value;

‎boost/network/uri/directives/host.hpp‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
#define__BOOST_NETWORK_URI_DIRECTIVES_HOST_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/range/begin.hpp>
6+
#include<boost/range/end.hpp>
97

108

119
namespaceboost {
@@ -24,17 +22,7 @@ struct host_directive {
2422
classTag
2523
,template<class>classUri
2624
>
27-
typename enable_if<is_pod<Tag>,void>::type
28-
operator () (Uri<Tag> &uri)const {
29-
uri.append(value);
30-
}
31-
32-
template<
33-
classTag
34-
,template<class>classUri
35-
>
36-
typename enable_if<mpl::not_<is_pod<Tag> >,void>::type
37-
operator () (Uri<Tag> &uri)const {
25+
voidoperator () (Uri<Tag> &uri)const {
3826
uri.append(value);
3927
}
4028

‎boost/network/uri/directives/path.hpp‎

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33

44

55
#include<boost/network/uri/encode.hpp>
6-
#include<boost/network/support/is_pod.hpp>
7-
#include<boost/utility/enable_if.hpp>
8-
#include<boost/mpl/if.hpp>
9-
#include<boost/mpl/or.hpp>
6+
#include<boost/range/as_literal.hpp>
107

118

129
namespaceboost {
@@ -25,21 +22,39 @@ struct path_directive {
2522
classTag
2623
,template<class>classUri
2724
>
28-
typename enable_if<is_pod<Tag>,void>::type
29-
operator () (Uri<Tag> &uri)const {
30-
typename string<Tag>::type encoded_value;
31-
encode(boost::begin(value),boost::end(value),std::back_inserter(encoded_value));
32-
uri.append(encoded_value);
25+
voidoperator () (Uri<Tag> &uri)const {
26+
(*this)(boost::as_literal(value), uri);
27+
}
28+
29+
template<
30+
classRng
31+
,classTag
32+
,template<class>classUri
33+
>
34+
voidoperator () (const Rng &rng, Uri<Tag> &uri)const {
35+
uri.append(boost::begin(rng),boost::end(rng));
3336
}
3437

38+
const ValueType &value;
39+
40+
};
41+
42+
template<
43+
classValueType
44+
>
45+
structencoded_path_directive {
46+
47+
explicitencoded_path_directive(const ValueType &value)
48+
: value(value)
49+
{}
50+
3551
template<
3652
classTag
3753
,template<class>classUri
3854
>
39-
typename enable_if<mpl::not_<is_pod<Tag> >,void>::type
40-
operator () (Uri<Tag> &uri)const {
55+
voidoperator () (Uri<Tag> &uri)const {
4156
typename string<Tag>::type encoded_value;
42-
encode(boost::begin(value),boost::end(value),std::back_inserter(encoded_value));
57+
encode(boost::as_literal(value),std::back_inserter(encoded_value));
4358
uri.append(encoded_value);
4459
}
4560

@@ -54,6 +69,14 @@ inline
5469
path_directive<T>path(const T &value) {
5570
return path_directive<T>(value);
5671
}
72+
73+
template<
74+
classT
75+
>
76+
inline
77+
encoded_path_directive<T>encoded_path(const T &value) {
78+
return encoded_path_directive<T>(value);
79+
}
5780
}// namespace uri
5881
}// namespace network
5982
}// namespace boost

‎boost/network/uri/directives/port.hpp‎

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
#define__BOOST_NETWORK_URI_DIRECTIVES_PORT_INC__
33

44

5-
#include<boost/network/support/is_pod.hpp>
65
#include<boost/utility/enable_if.hpp>
7-
#include<boost/mpl/if.hpp>
8-
#include<boost/mpl/or.hpp>
96
#include<boost/type_traits/is_integral.hpp>
107
#include<boost/cstdint.hpp>
8+
#include<boost/range/begin.hpp>
9+
#include<boost/range/end.hpp>
1110

1211

1312
namespaceboost {
@@ -26,19 +25,7 @@ struct port_directive {
2625
classTag
2726
,template<class>classUri
2827
>
29-
typename enable_if<is_pod<Tag>,void>::type
30-
operator () (Uri<Tag> &uri)const {
31-
staticconstchar separator[] = {':'};
32-
uri.append(boost::begin(separator),boost::end(separator));
33-
uri.append(value);
34-
}
35-
36-
template<
37-
classTag
38-
,template<class>classUri
39-
>
40-
typename enable_if<mpl::not_<is_pod<Tag> >,void>::type
41-
operator () (Uri<Tag> &uri)const {
28+
voidoperator () (Uri<Tag> &uri)const {
4229
staticconstchar separator[] = {':'};
4330
uri.append(boost::begin(separator),boost::end(separator));
4431
uri.append(value);

‎boost/network/uri/directives/query.hpp‎

Lines changed: 16 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
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

1110
namespaceboost {
@@ -24,19 +23,8 @@ struct query_directive {
2423
classTag
2524
,template<class>classUri
2625
>
27-
typename enable_if<is_pod<Tag>,void>::type
28-
operator () (Uri<Tag> &uri)const {
29-
staticconstchar separator[] = {'?'};
30-
uri.append(boost::begin(separator),boost::end(separator));
31-
uri.append(value);
32-
}
33-
34-
template<
35-
classTag
36-
,template<class>classUri
37-
>
38-
typename enable_if<mpl::not_<is_pod<Tag> >,void>::type
39-
operator () (Uri<Tag> &uri)const {
26+
voidoperator () (Uri<Tag> &uri)const {
27+
typename string<Tag>::type encoded_value;
4028
staticconstchar separator[] = {'?'};
4129
uri.append(boost::begin(separator),boost::end(separator));
4230
uri.append(value);
@@ -68,48 +56,26 @@ struct query_key_value_directive {
6856
classTag
6957
,template<class>classUri
7058
>
71-
typename enable_if<is_pod<Tag>,void>::type
72-
operator () (Uri<Tag> &uri)const {
73-
staticconstcharseparator_1[] = {'?'};
74-
staticconstcharseparator_2[] = {'='};
75-
staticconstcharseparator_3[] = {';'};
59+
voidoperator () (Uri<Tag> &uri)const {
60+
typename string<Tag>::type encoded_key, encoded_value;
61+
staticconstcharqmark[] = {'?'};
62+
staticconstcharequal[] = {'='};
63+
staticconstcharscolon[] = {';'};
7664
if (!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
}
8068
else
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-
classTag
93-
,template<class>classUri
94-
>
95-
typename enable_if<mpl::not_<is_pod<Tag> >,void>::type
96-
operator () (Uri<Tag> &uri)const {
97-
staticconstchar separator_1[] = {'?'};
98-
staticconstchar separator_2[] = {'='};
99-
staticconstchar 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-
11379
const KeyType &key;
11480
const ValueType &value;
11581

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp