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

Commit0c1b508

Browse files
author
mikhail_beris
committed
Add support for body(...) directives and wrapper.
1 parent43e2285 commit0c1b508

File tree

7 files changed

+106
-0
lines changed

7 files changed

+106
-0
lines changed

‎boost/network/.message.hpp.swp‎

-12 KB
Binary file not shown.

‎boost/network/message.hpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,17 @@ namespace boost { namespace network {
4646
return _headers;
4747
};
4848

49+
std::string &body()const {
50+
return _body;
51+
};
52+
4953
private:
5054

5155
friendstructdetail::directive_base<tag> ;
5256
friendstructdetail::wrapper_base<tag> ;
5357

5458
mutable headers_container_type _headers;
59+
mutable std::string _body;
5560
};
5661

5762
typedef basic_message<> message;// default message type

‎boost/network/message/directives.hpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212

1313
#include<boost/network/message/directives/header.hpp>
14+
#include<boost/network/message/directives/body.hpp>
1415

1516
namespaceboost {namespacenetwork {
1617

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
// Copyright Dean Michael Berris 2007.
3+
// Distributed under the Boost Software License, Version 1.0.
4+
// (See accompanying file LICENSE_1_0.txt or copy at
5+
// http://www.boost.org/LICENSE_1_0.txt)
6+
7+
#ifndef __NETWORK_MESSAGE_DIRECTIVES_BODY_HPP__
8+
#define__NETWORK_MESSAGE_DIRECTIVES_BODY_HPP__
9+
10+
/** body.hpp
11+
*
12+
* Defines the types involved and the semantics of adding
13+
* body contents into message objects.
14+
*
15+
* WARNING: DO NOT INCLUDE THIS HEADER DIRECTLY. THIS REQUIRES
16+
* TYPES TO BE DEFINED FROM EARLIER FILES THAT INCLUDE THIS
17+
* HEADER.
18+
*/
19+
namespaceboost {namespacenetwork {
20+
21+
namespaceimpl {
22+
template<classTag>
23+
structbody_directive :publicdetail::directive_base<Tag> {
24+
typedef Tag tag;
25+
26+
explicitbody_directive(
27+
std::stringconst & body
28+
) :
29+
_body(body)
30+
{ };
31+
32+
voidoperator() (basic_message<tag> & msg)const {
33+
msg.body() = _body;
34+
};
35+
36+
private:
37+
38+
std::string _body;
39+
};
40+
};// namespace impl
41+
42+
inline impl::body_directive<tags::default_>
43+
body(std::stringconst & body_) {
44+
return impl::body_directive<tags::default_>(body_);
45+
};
46+
47+
};// namespace network
48+
49+
};// namespace boost
50+
51+
#endif// __NETWORK_MESSAGE_DIRECTIVES_BODY_HPP__
52+

‎boost/network/message/wrappers.hpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
* Pulls in all the wrapper header files.
1313
*/
1414
#include<boost/network/message/wrappers/headers.hpp>
15+
#include<boost/network/message/wrappers/body.hpp>
1516

1617
#endif// __NETWORK_MESSAGE_WRAPPERS_HPP__
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
// Copyright Dean Michael Berris 2007.
3+
// Distributed under the Boost Software License, Version 1.0.
4+
// (See accompanying file LICENSE_1_0.txt or copy at
5+
// http://www.boost.org/LICENSE_1_0.txt)
6+
7+
#ifndef __NETWORK_MESSAGE_WRAPPERS_BODY_HPP__
8+
#define__NETWORK_MESSAGE_WRAPPERS_BODY_HPP__
9+
10+
namespaceboost {namespacenetwork {
11+
12+
namespaceimpl {
13+
template<classTag>
14+
structbody_wrapper :publicdetail::wrapper_base<Tag> {
15+
typedef Tag tag;
16+
typedef basic_message<tag> message_type;
17+
18+
explicitbody_wrapper(basic_message<tag> & message_)
19+
: detail::wrapper_base<tag>(message_)
20+
{ };
21+
22+
operatorstd::string ()const {
23+
returnstd::string(_message.body());
24+
};
25+
};
26+
};// namespace impl
27+
28+
template<classTag>
29+
inline std::string
30+
body(basic_message<Tag> & message_) {
31+
return impl::body_wrapper<Tag>(message_);
32+
};
33+
34+
};// namespace network
35+
36+
};// namespace boost
37+
38+
#endif// __NETWORK_MESSAGE_WRAPPERS_BODY_HPP__
39+

‎libs/network/test/message_test.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,11 @@ BOOST_AUTO_TEST_CASE(header_directives_test) {
3030
headers_range<message>::type range =headers(msg)["SOME_HEADER"];
3131
BOOST_CHECK( range.first != range.second );
3232
}
33+
34+
BOOST_AUTO_TEST_CASE(body_directive_test) {
35+
usingnamespaceboost::network;
36+
message msg;
37+
msg <<body("The quick brown fox jumps over the lazy dog.") ;
38+
39+
BOOST_CHECK_EQUAL(body(msg),"The quick brown fox jumps over the lazy dog.");
40+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp