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

Commite1cee56

Browse files
committed
Making Linearize more Generic
This implementation of linearize turns it into a generic algorithm thatworks on types that model the Client Request concept. This is importantbecause it means any type that models the Client Request concept canthen be linearized into an output iterator.
1 parent00b27b7 commite1cee56

File tree

7 files changed

+78
-40
lines changed

7 files changed

+78
-40
lines changed

‎boost/network/message.hpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ namespace boost { namespace network {
4444
typedef Tag tag;
4545

4646
typedeftypename headers_container<Tag>::type headers_container_type;
47+
typedeftypename headers_container_type::value_type header_type;
4748
typedeftypename string<Tag>::type string_type;
4849

4950
basic_message()

‎boost/network/protocol/http/algorithms/linearize.hpp‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include<boost/network/protocol/http/message/header/name.hpp>
1111
#include<boost/network/protocol/http/message/header/value.hpp>
1212
#include<boost/network/protocol/http/message/header_concept.hpp>
13+
#include<boost/network/protocol/http/request_concept.hpp>
1314
#include<boost/network/constants.hpp>
1415
#include<boost/concept/requires.hpp>
1516
#include<boost/range/algorithm/copy.hpp>
@@ -43,15 +44,19 @@ namespace boost { namespace network { namespace http {
4344
}
4445
};
4546

46-
template<classTag,classOutputIterator>
47-
OutputIteratorlinearize(
48-
basic_request<Tag>const & request,
49-
typename string<Tag>::typeconst & method,
47+
template<classRequest,classOutputIterator>
48+
BOOST_CONCEPT_REQUIRES(
49+
((ClientRequest<Request>)),
50+
(OutputIterator)
51+
) linearize(
52+
Requestconst & request,
53+
typename Request::string_typeconst & method,
5054
unsigned version_major,
5155
unsigned version_minor,
5256
OutputIterator oi
5357
)
5458
{
59+
typedeftypename Request::tag Tag;
5560
typedef constants<Tag> consts;
5661
typedeftypename string<Tag>::type string_type;
5762
static string_type
@@ -103,7 +108,7 @@ namespace boost { namespace network { namespace http {
103108
boost::copy(default_accept_encoding, oi);
104109
boost::copy(crlf, oi);
105110
}
106-
typedeftypename headers_range<basic_request<Tag>>::type headers_range;
111+
typedeftypename headers_range<Request>::type headers_range;
107112
typedeftypename range_iterator<headers_range>::type headers_iterator;
108113
headers_range request_headers =headers(request);
109114
headers_iterator iterator =boost::begin(request_headers),
@@ -125,7 +130,7 @@ namespace boost { namespace network { namespace http {
125130
boost::copy(crlf, oi);
126131
}
127132
boost::copy(crlf, oi);
128-
typename body_range<basic_request<Tag>>::type body_data =body(request).range();
133+
typename body_range<Request>::type body_data =body(request).range();
129134
returnboost::copy(body_data, oi);
130135
}
131136

‎boost/network/protocol/http/message/modifiers/body.hpp‎

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include<boost/network/protocol/http/tags.hpp>
1010
#include<boost/network/support/is_async.hpp>
11+
#include<boost/network/protocol/http/support/client_or_server.hpp>
1112
#include<boost/thread/future.hpp>
1213
#include<boost/concept/requires.hpp>
1314
#include<boost/network/message/directives.hpp>
@@ -37,26 +38,40 @@ namespace boost { namespace network { namespace http {
3738
request.body = value;
3839
}
3940

41+
template<classTag,classT>
42+
voidbody(basic_request<Tag> & request, Tconst & value, tags::clientconst &) {
43+
request << ::boost::network::body(value);
44+
}
45+
4046
}
4147

4248
template<classTag,classT>
43-
inline
44-
BOOST_CONCEPT_REQUIRES(((Response<basic_response<Tag> >)),
45-
(void))
49+
inlinevoid
4650
body(basic_response<Tag> & response, Tconst & value) {
4751
impl::body(response, value, is_async<Tag>());
4852
}
4953

54+
template<classTag,classT>
55+
inlinevoid
56+
body_impl(basic_request<Tag> & request, Tconst & value, tags::server) {
57+
impl::body(request, value,Tag());
58+
}
59+
5060
template<classR>
51-
structServerRequest;
61+
structClientRequest;
5262

5363
template<classTag,classT>
54-
inlineBOOST_CONCEPT_REQUIRES(((ServerRequest<basic_request<Tag> >)),
55-
(void))
56-
body(basic_request<Tag> & request, Tconst & value) {
64+
inlinevoid
65+
body_impl(basic_request<Tag> & request, Tconst & value, tags::client) {
5766
impl::body(request, value,Tag());
5867
}
5968

69+
template<classTag,classT>
70+
inlinevoid
71+
body(basic_request<Tag> & request, Tconst & value) {
72+
body_impl(request, value,typename client_or_server<Tag>::type());
73+
}
74+
6075
}// namespace http
6176

6277
namespaceimpl {

‎boost/network/protocol/http/message/modifiers/destination.hpp‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// (See accompanying file LICENSE_1_0.txt or copy at
77
// http://www.boost.org/LICENSE_1_0.txt)
88

9+
#include<boost/network/protocol/http/support/client_or_server.hpp>
910
#include<boost/network/support/is_async.hpp>
1011
#include<boost/thread/future.hpp>
1112
#include<boost/concept/requires.hpp>
@@ -35,15 +36,15 @@ namespace boost { namespace network { namespace http {
3536
request.destination = value;
3637
}
3738

38-
}
39+
template<classTag,classT>
40+
voiddestination(basic_request<Tag> & request, Tconst & value, tags::clientconst &) {
41+
request << ::boost::network::destination(value);
42+
}
3943

40-
template<classR>
41-
structResponse;
44+
}
4245

4346
template<classTag,classT>
44-
inline
45-
BOOST_CONCEPT_REQUIRES(((Response<basic_response<Tag> >)),
46-
(void))
47+
inlinevoid
4748
destination(basic_response<Tag> & response, Tconst & value) {
4849
impl::destination(response, value, is_async<Tag>());
4950
}
@@ -52,13 +53,23 @@ namespace boost { namespace network { namespace http {
5253
structServerRequest;
5354

5455
template<classTag,classT>
55-
inline
56-
BOOST_CONCEPT_REQUIRES(((ServerRequest<basic_request<Tag> >)),
57-
(void))
58-
destination(basic_request<Tag> & request, Tconst & value) {
56+
inlinevoid
57+
destination_impl(basic_request<Tag> & request, Tconst & value, tags::server) {
58+
impl::destination(request, value,Tag());
59+
}
60+
61+
template<classTag,classT>
62+
inlinevoid
63+
destination_impl(basic_request<Tag> & request, Tconst & value, tags::client) {
5964
impl::destination(request, value,Tag());
6065
}
6166

67+
template<classTag,classT>
68+
inlinevoid
69+
destination(basic_request<Tag> & request, Tconst & value) {
70+
destination_impl(request, value,typename client_or_server<Tag>::type());
71+
}
72+
6273
}// namespace http
6374

6475
namespaceimpl {

‎boost/network/protocol/http/message/modifiers/headers.hpp‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,13 @@ namespace boost { namespace network { namespace http {
3838
}
3939

4040
template<classTag,classT>
41-
inline
42-
BOOST_CONCEPT_REQUIRES(((Response<basic_response<Tag> >)),
43-
(void))
41+
inlinevoid
4442
headers(basic_response<Tag> & response, Tconst & value) {
4543
impl::headers(response, value, is_async<Tag>());
4644
}
4745

4846
template<classTag,classT>
49-
inlineBOOST_CONCEPT_REQUIRES(((ServerRequest<basic_request<Tag> >)),
50-
(void))
47+
inlinevoid
5148
headers(basic_request<Tag> & request, Tconst & value) {
5249
impl::headers(request, value,Tag());
5350
}

‎boost/network/protocol/http/message/modifiers/source.hpp‎

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// http://www.boost.org/LICENSE_1_0.txt)
88

99
#include<boost/network/support/is_async.hpp>
10+
#include<boost/network/protocol/http/support/client_or_server.hpp>
1011
#include<boost/thread/future.hpp>
1112
#include<boost/concept/requires.hpp>
1213
#include<boost/network/protocol/http/tags.hpp>
@@ -34,28 +35,35 @@ namespace boost { namespace network { namespace http {
3435
request.source = value;
3536
}
3637

37-
}
38+
template<classTag,classT>
39+
voidsource(basic_request<Tag> & request, Tconst & value, tags::clientconst &) {
40+
request << ::boost::network::source(value);
41+
}
3842

39-
template<classR>
40-
structResponse;
43+
}
4144

4245
template<classTag,classT>
43-
inline
44-
BOOST_CONCEPT_REQUIRES(((Response<basic_response<Tag> >)),
45-
(void))
46+
inlinevoid
4647
source(basic_response<Tag> & response, Tconst & value) {
4748
impl::source(response, value, is_async<Tag>());
4849
}
4950

50-
template<classR>
51-
structServerRequest;
51+
template<classTag,classT>
52+
inlinevoid
53+
source_impl(basic_request<Tag> & request, Tconst & value, tags::server) {
54+
impl::source(request, value,Tag());
55+
}
56+
57+
template<classTag,classT>
58+
inlinevoid
59+
source_impl(basic_request<Tag> & request, Tconst & value, tags::client) {
60+
impl::source(request, value,Tag());
61+
}
5262

5363
template<classTag,classT>
54-
inline
55-
BOOST_CONCEPT_REQUIRES(((ServerRequest<basic_request<Tag> >)),
56-
(void))
64+
inlinevoid
5765
source(basic_request<Tag> & request, Tconst & value) {
58-
impl::source(request, value,Tag());
66+
source_impl(request, value,typename client_or_server<Tag>::type());
5967
}
6068

6169
}// namespace http

‎boost/network/protocol/http/request.hpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include<boost/network/protocol/http/message/modifiers/destination.hpp>
3838
#include<boost/network/protocol/http/message/modifiers/headers.hpp>
3939
#include<boost/network/protocol/http/message/modifiers/body.hpp>
40+
#include<boost/network/protocol/http/message/modifiers/clear_headers.hpp>
4041
#include<boost/network/protocol/http/message/wrappers/major_version.hpp>
4142
#include<boost/network/protocol/http/message/wrappers/minor_version.hpp>
4243
#include<boost/network/protocol/http/message/wrappers/source.hpp>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp