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

Commita1242bf

Browse files
committed
Added more URI builder tests.
1 parentc20d1d3 commita1242bf

File tree

17 files changed

+571
-43
lines changed

17 files changed

+571
-43
lines changed
File renamed without changes.

‎boost/network/uri/directives.hpp‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
#include<boost/network/uri/directives/path.hpp>
1212
#include<boost/network/uri/directives/query.hpp>
1313
#include<boost/network/uri/directives/fragment.hpp>
14-
#include<boost/network/support/is_pod.hpp>
15-
#include<boost/utility/enable_if.hpp>
16-
#include<boost/mpl/if.hpp>
17-
#include<boost/mpl/or.hpp>
1814

1915

2016
namespaceboost {

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,53 @@
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>
9+
10+
511
namespaceboost {
612
namespacenetwork {
713
namespaceuri {
14+
template<
15+
classValueType
16+
>
17+
structauthority_directive {
18+
19+
explicitauthority_directive(const ValueType &value)
20+
: value(value)
21+
{}
22+
23+
template<
24+
classTag
25+
,template<class>classUri
26+
>
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 {
38+
uri.append(value);
39+
}
40+
41+
const ValueType &value;
42+
43+
};
844

45+
template<
46+
classT
47+
>
48+
inline
49+
authority_directive<T>authority(const T &value) {
50+
return authority_directive<T>(value);
51+
}
952
}// namespace uri
1053
}// namespace network
1154
}// namespace boost

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,57 @@
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>
9+
10+
511
namespaceboost {
612
namespacenetwork {
713
namespaceuri {
14+
template<
15+
classValueType
16+
>
17+
structfragment_directive {
18+
19+
explicitfragment_directive(const ValueType &value)
20+
: value(value)
21+
{}
22+
23+
template<
24+
classTag
25+
,template<class>classUri
26+
>
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 {
40+
staticconstchar separator[] = {'#'};
41+
uri.append(boost::begin(separator),boost::end(separator));
42+
uri.append(value);
43+
}
44+
45+
const ValueType &value;
46+
47+
};
848

49+
template<
50+
classT
51+
>
52+
inline
53+
fragment_directive<T>fragment(const T &value) {
54+
return fragment_directive<T>(value);
55+
}
956
}// namespace uri
1057
}// namespace network
1158
}// namespace boost

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
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>
9+
10+
511
namespaceboost {
612
namespacenetwork {
713
namespaceuri {

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
#define__BOOST_NETWORK_URI_DIRECTIVES_PATH_INC__
33

44

5+
#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>
10+
11+
512
namespaceboost {
613
namespacenetwork {
714
namespaceuri {
@@ -20,7 +27,9 @@ struct path_directive {
2027
>
2128
typename enable_if<is_pod<Tag>,void>::type
2229
operator () (Uri<Tag> &uri)const {
23-
uri.append(value);
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);
2433
}
2534

2635
template<
@@ -29,7 +38,9 @@ struct path_directive {
2938
>
3039
typename enable_if<mpl::not_<is_pod<Tag> >,void>::type
3140
operator () (Uri<Tag> &uri)const {
32-
uri.append(value);
41+
typename string<Tag>::type encoded_value;
42+
encode(boost::begin(value),boost::end(value),std::back_inserter(encoded_value));
43+
uri.append(encoded_value);
3344
}
3445

3546
const ValueType &value;

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

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,88 @@
22
#define__BOOST_NETWORK_URI_DIRECTIVES_PORT_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>
9+
#include<boost/type_traits/is_integral.hpp>
10+
#include<boost/cstdint.hpp>
11+
12+
513
namespaceboost {
614
namespacenetwork {
715
namespaceuri {
16+
template<
17+
classValueType
18+
>
19+
structport_directive {
20+
21+
explicitport_directive(const ValueType &value)
22+
: value(value)
23+
{}
24+
25+
template<
26+
classTag
27+
,template<class>classUri
28+
>
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 {
42+
staticconstchar separator[] = {':'};
43+
uri.append(boost::begin(separator),boost::end(separator));
44+
uri.append(value);
45+
}
46+
47+
const ValueType &value;
48+
49+
};
50+
51+
52+
structport_directive_us {
53+
54+
explicitport_directive_us(boost::uint16_t value)
55+
: value(value)
56+
{}
57+
58+
template<
59+
classTag
60+
,template<class>classUri
61+
>
62+
voidoperator () (Uri<Tag> &uri)const {
63+
staticconstchar separator[] = {':'};
64+
uri.append(boost::begin(separator),boost::end(separator));
65+
typename string<Tag>::type port = boost::lexical_cast<typename string<Tag>::type>(value);
66+
uri.append(port);
67+
}
68+
69+
boost::uint16_t value;
70+
71+
};
72+
73+
74+
template<
75+
classT
76+
>
77+
inline
78+
port_directive<T>port(const T &value,
79+
typename boost::disable_if<typename boost::is_integral<T>::type>::type * =0) {
80+
return port_directive<T>(value);
81+
}
882

83+
inline
84+
port_directive_usport(boost::uint16_t value) {
85+
returnport_directive_us(value);
86+
}
987
}// namespace uri
1088
}// namespace network
1189
}// namespace boost

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

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,127 @@
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>
9+
10+
511
namespaceboost {
612
namespacenetwork {
713
namespaceuri {
14+
template<
15+
classValueType
16+
>
17+
structquery_directive {
18+
19+
explicitquery_directive(const ValueType &value)
20+
: value(value)
21+
{}
22+
23+
template<
24+
classTag
25+
,template<class>classUri
26+
>
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 {
40+
staticconstchar separator[] = {'?'};
41+
uri.append(boost::begin(separator),boost::end(separator));
42+
uri.append(value);
43+
}
44+
45+
const ValueType &value;
46+
47+
};
48+
49+
template<
50+
classT
51+
>
52+
inline
53+
query_directive<T>query(const T &value) {
54+
return query_directive<T>(value);
55+
}
56+
57+
template<
58+
classKeyType
59+
,classValueType
60+
>
61+
structquery_key_value_directive {
62+
63+
query_key_value_directive(const KeyType &key,const ValueType &value)
64+
: key(key), value(value)
65+
{}
66+
67+
template<
68+
classTag
69+
,template<class>classUri
70+
>
71+
typename enable_if<is_pod<Tag>,void>::type
72+
operator () (Uri<Tag> &uri)const {
73+
staticconstchar separator_1[] = {'?'};
74+
staticconstchar separator_2[] = {'='};
75+
staticconstchar separator_3[] = {';'};
76+
if (!uri.query_range())
77+
{
78+
uri.append(boost::begin(separator_1),boost::end(separator_1));
79+
}
80+
else
81+
{
82+
uri.append(boost::begin(separator_3),boost::end(separator_3));
83+
}
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));
88+
uri.append(encoded_value);
89+
}
90+
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+
113+
const KeyType &key;
114+
const ValueType &value;
115+
116+
};
8117

118+
template<
119+
classKey
120+
,classValue
121+
>
122+
inline
123+
query_key_value_directive<Key, Value>query(const Key &key,const Value &value) {
124+
return query_key_value_directive<Key, Value>(key, value);
125+
}
9126
}// namespace uri
10127
}// namespace network
11128
}// namespace boost

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp