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

Commit862b94a

Browse files
committed
WIP: organizing and fixing base modifiers, using SFINAE for proper overload selection.
1 parent49ac5a3 commit862b94a

File tree

16 files changed

+114
-80
lines changed

16 files changed

+114
-80
lines changed

‎boost/network/message/directives/detail/string_directive.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ namespace boost { namespace network { namespace detail {
9393
typename boost::network::detail::string_value< \
9494
typename Message::tag \
9595
>::typeconst & value \
96-
)const{ \
96+
) { \
9797
pod_body; \
9898
} \
9999
template<classT>voidoperator()(Tconst &)const { \

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,38 @@
1111
#include<boost/thread/future.hpp>
1212
#include<boost/utility/enable_if.hpp>
1313
#include<boost/mpl/not.hpp>
14+
#include<boost/mpl/and.hpp>
1415

1516
namespaceboost {namespacenetwork {
1617

1718
namespaceimpl {
1819
template<classMessage,classTag>
19-
inlinetypename enable_if<mpl::not_<is_pod<Tag> >,void>::type
20-
clear_headers(Messageconst & message, Tagconst &, mpl::false_const &) {
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+
clear_headers(Messageconst & message, Tagconst &) {
2128
(typenameMessage::headers_container_type()).swap(message.headers());
2229
}
2330

2431
template<classMessage,classTag>
2532
inlinetypename enable_if<is_pod<Tag>,void>::type
26-
clear_headers(Messageconst & message, Tagconst &, mpl::false_const &) {
33+
clear_headers(Messageconst & message, Tagconst &) {
2734
(typenameMessage::headers_container_type()).swap(message.headers);
2835
}
2936

3037
template<classMessage,classTag>
31-
inlinevoidclear_headers(Messageconst & message, Tagconst &, mpl::true_const &) {
38+
inlinetypename enable_if<
39+
mpl::and_<
40+
mpl::not_<is_pod<Tag> >
41+
, is_async<Tag>
42+
>
43+
,void
44+
>::type
45+
clear_headers(Messageconst & message, Tagconst &) {
3246
boost::promise<typename Message::headers_container_type> header_promise;
3347
boost::shared_future<typename Message::headers_container_type>headers_future(header_promise.get_future());
3448
message.headers(headers_future);
@@ -39,7 +53,7 @@ namespace boost { namespace network {
3953

4054
template<classTag,template<class>classMessage>
4155
inlinevoidclear_headers(Message<Tag>const & message) {
42-
impl::clear_headers(message,Tag(), is_async<Tag>());
56+
impl::clear_headers(message,Tag());
4357
}
4458

4559
}// namespace network

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

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,78 @@
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/range/algorithm/remove_if.hpp>
14+
#include<boost/algorithm/string/predicate.hpp>
15+
#include<boost/mpl/not.hpp>
1116

1217
namespaceboost {namespacenetwork {
1318

1419
namespaceimpl {
1520

16-
template<classMessage,classKeyType>
17-
inlinevoidremove_header(Messageconst & message, KeyTypeconst & key, tags::default_stringconst &, mpl::false_const &) {
21+
template<classMessage,classKeyType,classTag>
22+
inlinetypename enable_if<
23+
mpl::and_<
24+
mpl::not_<is_pod<Tag> >
25+
, mpl::not_<is_async<Tag> >
26+
>
27+
,void
28+
>::type
29+
remove_header(Message & message, KeyTypeconst & key, Tag) {
1830
message.headers().erase(key);
1931
}
2032

21-
template<classMessage,classKeyType>
22-
inlinevoidremove_header(Messageconst & message, KeyTypeconst & key, tags::default_wstringconst &, mpl::false_const &) {
23-
message.headers().erase(key);
33+
template<classMessage,classKeyType,classTag>
34+
inlinetypename enable_if<
35+
mpl::and_<
36+
mpl::not_<is_pod<Tag> >
37+
, is_async<Tag>
38+
>
39+
,void
40+
>::type
41+
remove_header(Message & message, KeyTypeconst & key, Tag) {
42+
message.remove_header(key);
2443
}
2544

45+
template<classKeyType>
46+
structiequals_pred {
47+
KeyTypeconst & key;
48+
iequals_pred(KeyTypeconst & key)
49+
: key(key) {}
50+
template<classHeader>
51+
booloperator()(Header & other)const {
52+
returnboost::iequals(key,name(other));
53+
}
54+
};
55+
2656
template<classMessage,classKeyType,classTag>
27-
inlinevoidremove_header(Messageconst & message, KeyTypeconst & key, Tagconst &, mpl::true_const &) {
28-
message.remove_header(key);
57+
inlinetypename enable_if<
58+
is_pod<Tag>
59+
,void
60+
>::type
61+
remove_header(Message & message, KeyTypeconst & key, Tag) {
62+
typedeftypename Message::headers_container_type headers;
63+
message.headers.erase(
64+
boost::remove_if(
65+
message.headers,
66+
iequals_pred<KeyType>(key)
67+
)
68+
, message.headers.end()
69+
);
2970
}
3071

3172

3273
}// namespace impl
3374

3475
template<classTag,template<class>classMessage,classKeyType>
35-
inlinevoidremove_header(Message<Tag>const& message, KeyTypeconst & key) {
36-
impl::remove_header(message, key,Tag(), is_async<Tag>());
76+
inlinevoidremove_header(Message<Tag> & message, KeyTypeconst & key) {
77+
impl::remove_header(message, key,Tag());
3778
}
3879

3980
}// namespace network
4081

4182
}// namespace boost
4283

4384
#endif// BOOST_NETWORK_MESSAGE_MODIFIER_REMOVE_HEADER_HPP_20100824
85+

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
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/server/header/name.hpp>
10-
#include<boost/network/protocol/http/server/header/value.hpp>
11-
#include<boost/network/protocol/http/server/header/concept.hpp>
9+
#include<boost/network/protocol/http/message/header/name.hpp>
10+
#include<boost/network/protocol/http/message/header/value.hpp>
11+
#include<boost/network/protocol/http/message/header_concept.hpp>
1212
#include<boost/network/constants.hpp>
1313
#include<boost/concept_check.hpp>
1414

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include<boost/fusion/sequence/intrinsic/value_at_key.hpp>
1616

1717
#include<boost/network/uri.hpp>
18-
#include<boost/network/protocol/http/header.hpp>
1918
#include<boost/network/traits/vector.hpp>
2019

2120
#include<boost/network/protocol/http/message/async_message.hpp>

‎boost/network/protocol/http/impl/response.ipp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include<boost/network/protocol/http/tags.hpp>
2020
#include<boost/network/traits/string.hpp>
2121
#include<boost/network/protocol/http/traits/vector.hpp>
22-
#include<boost/network/protocol/http/header.hpp>
22+
#include<boost/network/protocol/http/message/header.hpp>
2323

2424
namespaceboost {namespacenetwork {namespacehttp {
2525

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HPP
1414

1515
#include<boost/network/protocol/http/traits.hpp>
16+
#include<boost/network/protocol/http/message/header/name.hpp>
17+
#include<boost/network/protocol/http/message/header/value.hpp>
18+
#include<boost/network/protocol/http/message/header_concept.hpp>
1619
#include<boost/network/protocol/http/message/modifiers/add_header.hpp>
1720
#include<boost/network/protocol/http/message/modifiers/remove_header.hpp>
1821
#include<boost/network/message.hpp>

‎boost/network/protocol/http/header.hpp‎renamed to ‎boost/network/protocol/http/message/header.hpp‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
1111
//
1212

13-
#ifndefHTTP_SERVER3_HEADER_HPP
14-
#defineHTTP_SERVER3_HEADER_HPP
13+
#ifndefBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122
14+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122
1515

1616
#include<boost/network/traits/string.hpp>
1717
#include<boost/fusion/adapted/struct/adapt_struct.hpp>
@@ -34,6 +34,19 @@ namespace boost { namespace network { namespace http {
3434
swap(l.value, r.value);
3535
}
3636

37+
template<classTag>
38+
structresponse_header {
39+
typedef Tag tag;
40+
typedeftypename string<Tag>::type string_type;
41+
string_type name, value;
42+
};
43+
44+
template<classTag>
45+
voidswap(response_header<Tag> & l, response_header<Tag> & r) {
46+
std::swap(l.name, r.name);
47+
std::swap(l.value, r.value);
48+
}
49+
3750
}// namespace http
3851

3952
}// namespace network
@@ -47,4 +60,11 @@ BOOST_FUSION_ADAPT_TPL_STRUCT(
4760
(typename boost::network::string<Tag>::type, value)
4861
)
4962

50-
#endif// HTTP_SERVER3_HEADER_HPP
63+
BOOST_FUSION_ADAPT_TPL_STRUCT(
64+
(Tag),
65+
(boost::network::http::response_header) (Tag),
66+
(typename boost::network::string<Tag>::type, name)
67+
(typename boost::network::string<Tag>::type, value)
68+
)
69+
70+
#endif// BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_HPP_20101122

‎boost/network/protocol/http/server/header/name.hpp‎renamed to ‎boost/network/protocol/http/message/header/name.hpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndefBOOST_NETWORK_PROTOCOL_HTTP_SERVER_HEADER_NAME_HPP_20101028
2-
#defineBOOST_NETWORK_PROTOCOL_HTTP_SERVER_HEADER_NAME_HPP_20101028
1+
#ifndefBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_NAME_HPP_20101028
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_NAME_HPP_20101028
33

44
// Copyright 2010 Dean Michael Berris.
55
// Distributed under the Boost Software License, Version 1.0.
@@ -40,4 +40,4 @@ namespace boost { namespace network { namespace http {
4040

4141
}/* boost*/
4242

43-
#endif/*BOOST_NETWORK_PROTOCOL_HTTP_SERVER_HEADER_NAME_HPP_20101028*/
43+
#endif/*BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_NAME_HPP_20101028*/

‎boost/network/protocol/http/server/header/value.hpp‎renamed to ‎boost/network/protocol/http/message/header/value.hpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndefBOOST_NETWORK_PROTOCOL_HTTP_SERVER_HEADER_VALUE_HPP_20101028
2-
#defineBOOST_NETWORK_PROTOCOL_HTTP_SERVER_HEADER_VALUE_HPP_20101028
1+
#ifndefBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_VALUE_HPP_20101028
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_VALUE_HPP_20101028
33

44
// Copyright 2010 Dean Michael Berris.
55
// Distributed under the Boost Software License, Version 1.0.
@@ -39,5 +39,5 @@ namespace boost { namespace network { namespace http {
3939

4040
}/* boost*/
4141

42-
#endif/*BOOST_NETWORK_PROTOCOL_HTTP_SERVER_HEADER_VALUE_HPP_20101028*/
42+
#endif/*BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_HEADER_VALUE_HPP_20101028*/
4343

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp