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

Commit4846166

Browse files
committed
Done with modifier organization.
1 parent862b94a commit4846166

File tree

7 files changed

+38
-95
lines changed

7 files changed

+38
-95
lines changed

‎boost/network/message/modifiers/add_header.hpp‎

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,54 @@
88
// http://www.boost.org/LICENSE_1_0.txt)
99

1010
#include<boost/network/support/is_async.hpp>
11+
#include<boost/network/support/is_pod.hpp>
12+
#include<boost/utility/enable_if.hpp>
13+
#include<boost/mpl/and.hpp>
14+
#include<boost/mpl/not.hpp>
1115

1216
namespaceboost {namespacenetwork {
1317

1418
namespaceimpl {
15-
template<classMessage,classKeyType,classValueType>
16-
inlinevoidadd_header(Messageconst & message, KeyTypeconst & key, ValueTypeconst & value, tags::default_stringconst &, mpl::false_const &) {
19+
template<classMessage,classKeyType,classValueType,classTag>
20+
inlinetypename enable_if<
21+
mpl::and_<
22+
mpl::not_<is_pod<Tag> >
23+
, mpl::not_<is_async<Tag> >
24+
>
25+
,void
26+
>::type
27+
add_header(Message & message, KeyTypeconst & key, ValueTypeconst & value, Tag) {
1728
message.headers().insert(std::make_pair(key, value));
1829
}
1930

20-
template<classMessage,classKeyType,classValueType>
21-
inlinevoidadd_header(Messageconst & message, KeyTypeconst & key, ValueTypeconst & value, tags::default_wstringconst &, mpl::false_const &) {
22-
message.headers().insert(std::make_pair(key, value));
31+
template<classMessage,classKeyType,classValueType,classTag>
32+
inlinetypename enable_if<
33+
mpl::and_<
34+
mpl::not_<is_pod<Tag> >
35+
, is_async<Tag>
36+
>
37+
,void
38+
>::type
39+
add_header(Message & message, KeyTypeconst & key, ValueTypeconst & value, Tag) {
40+
typedeftypename Message::header_type header_type;
41+
message.add_header(header_type(key,value));
2342
}
2443

25-
template<classMessage,classKeyType,classValueType>
26-
inlinevoidadd_header(Messageconst & message, KeyTypeconst & key, ValueTypeconst & value, tags::asyncconst &, mpl::true_const &) {
27-
message.add_header(std::make_pair(key, value));
44+
template<classMessage,classKeyType,classValueType,classTag>
45+
inlinetypename enable_if<
46+
is_pod<Tag>
47+
,void
48+
>::type
49+
add_header(Message & message, KeyTypeconst & key, ValueTypeconst & value, Tag) {
50+
typename Message::header_type header = { key, value };
51+
message.headers.insert(message.headers.end(), header);
2852
}
2953

3054
}
3155

3256
template<classTag,template<class>classMessage,classKeyType,classValueType>
33-
inlinevoidadd_header(Message<Tag>const& message, KeyTypeconst & key, ValueTypeconst & value) {
34-
impl::add_header(message, key, value,Tag(), is_async<Tag>());
57+
inlinevoidadd_header(Message<Tag> & message, KeyTypeconst & key, ValueTypeconst & value) {
58+
impl::add_header(message, key, value,Tag());
3559
}
3660

3761
}// namespace network

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ namespace boost { namespace network { namespace http {
122122
structnot_quite_pod_request_base {
123123
typedef Tag tag;
124124
typedeftypename string<Tag>::type string_type;
125+
typedef request_header<Tag> header_type;
125126
typedeftypename vector<tags::http_server>::
126-
templateapply<request_header<Tag>>::type
127+
templateapply<header_type>::type
127128
vector_type;
128129
typedef vector_type headers_container_type;
129130
typedef boost::uint16_t port_type;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include<boost/network/protocol/http/message/header/name.hpp>
1717
#include<boost/network/protocol/http/message/header/value.hpp>
1818
#include<boost/network/protocol/http/message/header_concept.hpp>
19-
#include<boost/network/protocol/http/message/modifiers/add_header.hpp>
20-
#include<boost/network/protocol/http/message/modifiers/remove_header.hpp>
2119
#include<boost/network/message.hpp>
2220
#include<boost/network/tags.hpp>
2321
#include<string>

‎boost/network/protocol/http/message/async_message.hpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace boost { namespace network { namespace http {
2929

3030
typedeftypename string<Tag>::type string_type;
3131
typedeftypename headers_container<Tag>::type headers_container_type;
32+
typedeftypename headers_container_type::value_type header_type;
3233

3334
async_message()
3435
: status_message_(),
@@ -104,7 +105,7 @@ namespace boost { namespace network { namespace http {
104105
}
105106

106107
voidadd_header(typename headers_container_type::value_typeconst & pair_)const {
107-
added_headers.insert(pair_);
108+
added_headers.insert(added_headers.end(),pair_);
108109
}
109110

110111
voidremove_header(typename headers_container_type::key_typeconst & key_)const {

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

Lines changed: 0 additions & 30 deletions
This file was deleted.

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

Lines changed: 0 additions & 49 deletions
This file was deleted.

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#include<boost/network/tags.hpp>
1313
#include<boost/network/message_fwd.hpp>
1414
#include<boost/network/message/wrappers.hpp>
15-
#include<boost/network/protocol/http/message/modifiers/add_header.hpp>
16-
#include<boost/network/protocol/http/message/modifiers/remove_header.hpp>
1715

1816
#include<boost/network/protocol/http/message/directives/uri.hpp>
1917
#include<boost/network/protocol/http/message/modifiers/uri.hpp>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp