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

Commit8a05166

Browse files
committed
Added a couple of extra tests to construct a URI from an existing root URI.
1 parent1945ea8 commit8a05166

File tree

6 files changed

+116
-28
lines changed

6 files changed

+116
-28
lines changed

‎boost/network/uri/accessors.hpp‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ template <
2323
typename Map
2424
>
2525
structkey_value_sequence
26-
: spirit::qi::grammar<typename Uri::const_iterator_type, Map()>
26+
: spirit::qi::grammar<typename Uri::const_iterator, Map()>
2727
{
28-
typedeftypename Uri::const_iterator_type const_iterator_type;
28+
typedeftypename Uri::const_iterator const_iterator;
2929

3030
key_value_sequence()
3131
: key_value_sequence::base_type(query)
@@ -36,9 +36,9 @@ struct key_value_sequence
3636
value = +spirit::qi::char_("a-zA-Z_0-9/%");
3737
}
3838

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,typenameUri::string_type()> key, value;
39+
spirit::qi::rule<const_iterator, Map()> query;
40+
spirit::qi::rule<const_iterator, std::pair<typename Uri::string_type,typename Uri::string_type>()> pair;
41+
spirit::qi::rule<const_iterator,typenameUri::string_type()> key, value;
4242
};
4343
}// namespace details
4444

@@ -59,7 +59,7 @@ template <
5959
>
6060
typename basic_uri<Tag>::string_typeusername(const basic_uri<Tag> &uri) {
6161
typename basic_uri<Tag>::const_range_type user_info_range = uri.user_info_range();
62-
typename basic_uri<Tag>::const_iterator_typeit(boost::begin(user_info_range)),end(boost::end(user_info_range));
62+
typename basic_uri<Tag>::const_iteratorit(boost::begin(user_info_range)),end(boost::end(user_info_range));
6363
for (; it != end; ++it) {
6464
if (*it ==':') {
6565
break;
@@ -73,7 +73,7 @@ template <
7373
>
7474
typename basic_uri<Tag>::string_typepassword(const basic_uri<Tag> &uri) {
7575
typename basic_uri<Tag>::const_range_type user_info_range = uri.user_info_range();
76-
typename basic_uri<Tag>::const_iterator_typeit(boost::begin(user_info_range)),end(boost::end(user_info_range));
76+
typename basic_uri<Tag>::const_iteratorit(boost::begin(user_info_range)),end(boost::end(user_info_range));
7777
for (; it != end; ++it) {
7878
if (*it ==':') {
7979
++it;

‎boost/network/uri/directives.hpp‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@
1616
namespaceboost {
1717
namespacenetwork {
1818
namespaceuri {
19+
template<
20+
classTag
21+
>
22+
inline
23+
basic_uri<Tag> &operator << (basic_uri<Tag> &uri,const basic_uri<Tag> &root_uri) {
24+
if (root_uri.is_valid()) {
25+
uri.append(boost::begin(root_uri),boost::end(root_uri));
26+
}
27+
return uri;
28+
}
29+
1930
template<
2031
classTag
2132
,classDirective

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ template <
3434
classT
3535
>
3636
inline
37-
authority_directive<T>authority(const T &value){
37+
authority_directive<T>authority(const T &value) {
3838
return authority_directive<T>(value);
3939
}
4040
}// namespace uri

‎boost/network/uri/uri.hpp‎

Lines changed: 61 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,24 @@ class basic_uri
4848
public:
4949

5050
typedeftypename string<Tag>::type string_type;
51-
typedeftypename string_type::iteratoriterator_type;
52-
typedef boost::iterator_range<iterator_type> range_type;
53-
typedeftypename string_type::const_iteratorconst_iterator_type;
54-
typedef boost::iterator_range<const_iterator_type> const_range_type;
51+
typedeftypename string_type::iteratoriterator;
52+
typedef boost::iterator_range<iterator> range_type;
53+
typedeftypename string_type::const_iteratorconst_iterator;
54+
typedef boost::iterator_range<const_iterator> const_range_type;
5555

56-
basic_uri() : is_valid_(false) {
56+
basic_uri()
57+
: is_valid_(false) {
5758

5859
}
5960

61+
template<
62+
classFwdIter
63+
>
64+
basic_uri(const FwdIter &first,const FwdIter &last)
65+
: uri_(first, last), is_valid_(false) {
66+
parse();
67+
}
68+
6069
basic_uri(const string_type &uri)
6170
: uri_(uri), is_valid_(false) {
6271
parse();
@@ -88,19 +97,19 @@ class basic_uri
8897
parse();
8998
}
9099

91-
iterator_typebegin() {
100+
iteratorbegin() {
92101
return uri_.begin();
93102
}
94103

95-
const_iterator_typebegin()const {
104+
const_iteratorbegin()const {
96105
return uri_.begin();
97106
}
98107

99-
iterator_typeend() {
108+
iteratorend() {
100109
return uri_.end();
101110
}
102111

103-
const_iterator_typeend()const {
112+
const_iteratorend()const {
104113
return uri_.end();
105114
}
106115

@@ -195,9 +204,9 @@ class basic_uri
195204
}
196205

197206
template<
198-
classIterator
207+
classFwdIter
199208
>
200-
voidappend(Iteratorfirst,Iteratorlast) {
209+
voidappend(const FwdIter &first,const FwdIter &last) {
201210
uri_.append(first, last);
202211
parse();
203212
}
@@ -217,18 +226,10 @@ template <
217226
>
218227
inline
219228
void basic_uri<Tag>::parse() {
220-
const_iterator_typefirst(boost::begin(uri_)),last(boost::end(uri_));
229+
const_iteratorfirst(boost::begin(uri_)),last(boost::end(uri_));
221230
is_valid_ =detail::parse(first, last, uri_parts_);
222231
}
223232

224-
template<
225-
classTag
226-
>
227-
inline
228-
voidswap(basic_uri<Tag> &lhs, basic_uri<Tag> &rhs) {
229-
lhs.swap(rhs);
230-
}
231-
232233
template<
233234
classTag
234235
>
@@ -358,6 +359,46 @@ bool operator == (const basic_uri<Tag> &lhs, const basic_uri<Tag> &rhs) {
358359
}
359360
}// namespace uri
360361
}// namespace network
362+
363+
template<
364+
classTag
365+
>
366+
inline
367+
typename network::uri::basic_uri<Tag>::iteratorbegin(network::uri::basic_uri<Tag> &uri) {
368+
return uri.begin();
369+
}
370+
371+
template<
372+
classTag
373+
>
374+
inline
375+
typename network::uri::basic_uri<Tag>::iteratorend(network::uri::basic_uri<Tag> &uri) {
376+
return uri.end();
377+
}
378+
379+
template<
380+
classTag
381+
>
382+
inline
383+
typename network::uri::basic_uri<Tag>::const_iteratorbegin(const network::uri::basic_uri<Tag> &uri) {
384+
return uri.begin();
385+
}
386+
387+
template<
388+
classTag
389+
>
390+
inline
391+
typename network::uri::basic_uri<Tag>::const_iteratorend(const network::uri::basic_uri<Tag> &uri) {
392+
return uri.end();
393+
}
394+
395+
template<
396+
classTag
397+
>
398+
inline
399+
voidswap(network::uri::basic_uri<Tag> &lhs, network::uri::basic_uri<Tag> &rhs) {
400+
lhs.swap(rhs);
401+
}
361402
}// namespace boost
362403

363404

‎libs/network/test/uri/url_builder_test.cpp‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,30 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(fragment_test, T, tag_types)
205205
BOOST_CHECK(boost::equal(uri::fragment(instance), fragment));
206206
}
207207

208+
BOOST_AUTO_TEST_CASE_TEMPLATE(from_root_test, T, tag_types)
209+
{
210+
typedef uri::basic_uri<T> uri_type;
211+
typedeftypename uri_type::string_type string_type;
212+
213+
const std::stringroot("http://www.example.com");
214+
const std::stringscheme("http");
215+
const std::stringhost("www.example.com");
216+
const std::stringpath("/");
217+
const std::stringfragment("fragment");
218+
219+
uri_typeroot_uri(boost::begin(root),boost::end(root));
220+
uri_type instance;
221+
//instance << uri::uri("http://www.example.com") << uri::path("/") << uri::fragment("fragment");
222+
instance << root_uri
223+
<<uri::path(string_type(boost::begin(path),boost::end(path)))
224+
<<uri::fragment(string_type(boost::begin(fragment),boost::end(fragment)));
225+
BOOST_REQUIRE(uri::is_valid(instance));
226+
BOOST_CHECK(boost::equal(uri::scheme(instance), scheme));
227+
BOOST_CHECK(boost::equal(uri::host(instance), host));
228+
BOOST_CHECK(boost::equal(uri::path(instance), path));
229+
BOOST_CHECK(boost::equal(uri::fragment(instance), fragment));
230+
}
231+
208232
//BOOST_AUTO_TEST_CASE_TEMPLATE(scheme_test, T, tag_types)
209233
//{
210234
// typedef uri::basic_uri<T> uri_type;

‎libs/network/test/uri/url_test.cpp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,15 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(xmpp_query_map_test, T, tag_types) {
312312
BOOST_CHECK(boost::equal((++queries.begin())->first, key_2));
313313
BOOST_CHECK(boost::equal((++queries.begin())->second, value_2));
314314
}
315+
316+
BOOST_AUTO_TEST_CASE_TEMPLATE(range_test, T, tag_types)
317+
{
318+
typedef uri::basic_uri<T> uri_type;
319+
typedeftypename uri_type::string_type string_type;
320+
321+
const std::stringurl("http://www.example.com/");
322+
323+
uri_typeinstance(string_type(boost::begin(url),boost::end(url)));
324+
BOOST_REQUIRE(uri::is_valid(instance));
325+
BOOST_CHECK(boost::equal(instance, url));
326+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp