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

Commit788cb16

Browse files
committed
Turning the wrapper definition into a preprocessor macro "BOOST_NETWORK_DEFINE_HTTP_WRAPPER".
1 parent301269f commit788cb16

File tree

4 files changed

+78
-99
lines changed

4 files changed

+78
-99
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +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/response_concept.hpp>
10-
#include<boost/network/protocol/http/request_concept.hpp>
11-
#include<boost/concept/requires.hpp>
9+
#include<boost/network/protocol/http/message/wrappers/helper.hpp>
1210

1311
namespaceboost {namespacenetwork {namespacehttp {
1412

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

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +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/response_concept.hpp>
10-
#include<boost/network/protocol/http/request_concept.hpp>
11-
#include<boost/concept/requires.hpp>
9+
#include<boost/network/protocol/http/message/wrappers/helper.hpp>
1210

1311
namespaceboost {namespacenetwork {namespacehttp {
1412

@@ -18,38 +16,7 @@ namespace boost { namespace network { namespace http {
1816
template<classTag>
1917
structbasic_request;
2018

21-
namespaceimpl {
22-
23-
template<classMessage>
24-
structdestination_wrapper {
25-
typedeftypename string<typename Message::tag>::type string_type;
26-
Messageconst & message_;
27-
destination_wrapper(Messageconst & message)
28-
: message_(message) {}
29-
destination_wrapper(destination_wrapperconst & other)
30-
: message_(other.message_) {}
31-
operator string_typeconst () {
32-
return message_.source();
33-
}
34-
};
35-
36-
}// namespace impl
37-
38-
template<classTag>
39-
inline
40-
BOOST_CONCEPT_REQUIRES(((Response<basic_response<Tag> >)),
41-
(impl::destination_wrapper<basic_response<Tag> >const))
42-
destination(basic_response<Tag>const & message) {
43-
return impl::destination_wrapper<basic_response<Tag> >(message);
44-
}
45-
46-
template<classTag>
47-
inline
48-
BOOST_CONCEPT_REQUIRES(((Request<basic_request<Tag> >)),
49-
(impl::destination_wrapper<basic_request<Tag> >const))
50-
destination(basic_request<Tag>const & message) {
51-
return impl::destination_wrapper<basic_request<Tag> >(message);
52-
}
19+
BOOST_NETWORK_DEFINE_HTTP_WRAPPER(destination, destination);
5320

5421
}// namespace http
5522

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HELPER_20101013
2+
#defineBOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HELPER_20101013
3+
4+
// Copyright 2010 (c) Dean Michael Berris
5+
// Distributed under the Boost Software License, Version 1.0.
6+
// (See accompanying file LICENSE_1_0.txt or copy at
7+
// http://www.boost.org/LICENSE_1_0.txt)
8+
9+
#include<boost/network/protocol/http/response_concept.hpp>
10+
#include<boost/network/protocol/http/request_concept.hpp>
11+
#include<boost/mpl/if.hpp>
12+
#include<boost/concept/requires.hpp>
13+
14+
#ifndef BOOST_NETWORK_DEFINE_HTTP_WRAPPER
15+
#defineBOOST_NETWORK_DEFINE_HTTP_WRAPPER(name, accessor) \
16+
structname##_pod_accessor { \
17+
protected: \
18+
template<classMessage> \
19+
typename Message::string_typeconst & \
20+
get_value(Messageconst & message)const { \
21+
return message.accessor; \
22+
} \
23+
}; \
24+
\
25+
structname##_member_accessor { \
26+
protected: \
27+
template<classMessage> \
28+
typename Message::string_type \
29+
get_value(Messageconst & message)const { \
30+
return message.accessor(); \
31+
} \
32+
}; \
33+
\
34+
template<classTag> \
35+
structname##_wrapper_impl : \
36+
mpl::if_< \
37+
is_base_of<tags::pod, Tag>, \
38+
name##_pod_accessor, \
39+
name##_member_accessor \
40+
> \
41+
{}; \
42+
\
43+
template<classMessage> \
44+
structname##_wrapper : \
45+
name##_wrapper_impl<typename Message::tag>::type { \
46+
typedeftypename string<typename Message::tag>::type \
47+
string_type; \
48+
Messageconst & message_; \
49+
name##_wrapper(Messageconst & message) \
50+
: message_(message) {} \
51+
name##_wrapper(name##_wrapperconst & other) \
52+
: message_(other.message_) {} \
53+
operatorstring_type () { \
54+
returnthis->get_value(message_); \
55+
} \
56+
}; \
57+
\
58+
template<classTag> \
59+
inlineBOOST_CONCEPT_REQUIRES(((Response<basic_response<Tag> >)), \
60+
(name##_wrapper<basic_response<Tag> >const)) \
61+
name (basic_response<Tag>const & message) { \
62+
return name##_wrapper<basic_response<Tag> >(message); \
63+
} \
64+
\
65+
template<classTag> \
66+
inlineBOOST_CONCEPT_REQUIRES(((Request<basic_request<Tag> >)), \
67+
(name##_wrapper<basic_request<Tag> >const)) \
68+
name (basic_request<Tag>const & message) { \
69+
return name##_wrapper<basic_request<Tag> >(message); \
70+
}
71+
#endif/* BOOST_NETWORK_DEFINE_HTTP_WRAPPER*/
72+
73+
#endif/* BOOST_NETWORK_PROTOCOL_HTTP_MESSAGE_WRAPPERS_HELPER_20101013*/
74+

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

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +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/response_concept.hpp>
10-
#include<boost/network/protocol/http/request_concept.hpp>
11-
#include<boost/mpl/if.hpp>
12-
#include<boost/concept/requires.hpp>
9+
#include<boost/network/protocol/http/message/wrappers/helper.hpp>
1310

1411
namespaceboost {namespacenetwork {namespacehttp {
1512

@@ -19,63 +16,6 @@ namespace boost { namespace network { namespace http {
1916
template<classTag>
2017
structbasic_request;
2118

22-
#defineBOOST_NETWORK_DEFINE_HTTP_WRAPPER(name, accessor) \
23-
structname##_pod_accessor { \
24-
protected: \
25-
template<classMessage> \
26-
typename Message::string_typeconst & \
27-
get_value(Messageconst & message)const { \
28-
return message.accessor; \
29-
} \
30-
}; \
31-
\
32-
structname##_member_accessor { \
33-
protected: \
34-
template<classMessage> \
35-
typename Message::string_type \
36-
get_value(Messageconst & message)const { \
37-
return message.accessor(); \
38-
} \
39-
}; \
40-
\
41-
template<classTag> \
42-
structname##_wrapper_impl : \
43-
mpl::if_< \
44-
is_base_of<tags::pod, Tag>, \
45-
name##_pod_accessor, \
46-
name##_member_accessor \
47-
> \
48-
{}; \
49-
\
50-
template<classMessage> \
51-
structname##_wrapper : \
52-
name##_wrapper_impl<typename Message::tag>::type { \
53-
typedeftypename string<typename Message::tag>::type \
54-
string_type; \
55-
Messageconst & message_; \
56-
name##_wrapper(Messageconst & message) \
57-
: message_(message) {} \
58-
name##_wrapper(name##_wrapperconst & other) \
59-
: message_(other.message_) {} \
60-
operator string_typeconst () { \
61-
returnthis->get_value(message_); \
62-
} \
63-
}; \
64-
\
65-
template<classTag> \
66-
inlineBOOST_CONCEPT_REQUIRES(((Response<basic_response<Tag> >)), \
67-
(name##_wrapper<basic_response<Tag> >const)) \
68-
name (basic_response<Tag>const & message) { \
69-
return name##_wrapper<basic_response<Tag> >(message); \
70-
} \
71-
\
72-
template<classTag> \
73-
inlineBOOST_CONCEPT_REQUIRES(((Request<basic_request<Tag> >)), \
74-
(name##_wrapper<basic_request<Tag> >const)) \
75-
name (basic_request<Tag>const & message) { \
76-
return name##_wrapper<basic_request<Tag> >(message); \
77-
}
78-
7919
BOOST_NETWORK_DEFINE_HTTP_WRAPPER(source, source);
8020

8121
}// namespace http

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp