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

Commitc44e28c

Browse files
author
mikhail_beris
committed
Adding destination directive and wrapper, with appropriate unit test.
1 parentd318a5e commitc44e28c

File tree

7 files changed

+105
-2
lines changed

7 files changed

+105
-2
lines changed

‎boost/network/message.hpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ namespace boost { namespace network {
5454
return _source;
5555
};
5656

57+
std::string &destination()const {
58+
return _destination;
59+
};
60+
5761
private:
5862

5963
friendstructdetail::directive_base<tag> ;
@@ -62,6 +66,7 @@ namespace boost { namespace network {
6266
mutable headers_container_type _headers;
6367
mutable std::string _body;
6468
mutable std::string _source;
69+
mutable std::string _destination;
6570
};
6671

6772
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
@@ -13,6 +13,7 @@
1313
#include<boost/network/message/directives/header.hpp>
1414
#include<boost/network/message/directives/body.hpp>
1515
#include<boost/network/message/directives/source.hpp>
16+
#include<boost/network/message/directives/destination.hpp>
1617

1718
namespaceboost {namespacenetwork {
1819

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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_DESTINATION_HPP__
8+
#define__NETWORK_MESSAGE_DIRECTIVES_DESTINATION_HPP__
9+
10+
/** destination.hpp
11+
*
12+
* Defines the types involved and the semantics of adding
13+
* destination information 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+
structdestination_directive :publicdetail::directive_base<Tag> {
24+
typedef Tag tag;
25+
26+
explicitdestination_directive ( std::stringconst & destination)
27+
: _destination(destination)
28+
{ };
29+
30+
voidoperator() (basic_message<tag> & msg)const {
31+
msg.destination() = _destination;
32+
};
33+
34+
private:
35+
36+
std::string _destination;
37+
};
38+
};// namespace impl
39+
40+
inline impl::destination_directive<tags::default_>
41+
destination(std::stringconst & destination_) {
42+
return impl::destination_directive<tags::default_>(destination_);
43+
};
44+
45+
};// namespace network
46+
47+
};// namespace boost
48+
49+
#endif// __NETWORK_MESSAGE_DIRECTIVES_DESTINATION_HPP__

‎boost/network/message/directives/source.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#ifndef __NETWORK_MESSAGE_DIRECTIVES_SOURCE_HPP__
88
#define__NETWORK_MESSAGE_DIRECTIVES_SOURCE_HPP__
99

10-
/**header.hpp
10+
/**source.hpp
1111
*
1212
* Defines the types involved and the semantics of adding
1313
* source information into message objects.

‎boost/network/message/wrappers.hpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
#include<boost/network/message/wrappers/headers.hpp>
1515
#include<boost/network/message/wrappers/body.hpp>
1616
#include<boost/network/message/wrappers/source.hpp>
17+
#include<boost/network/message/wrappers/destination.hpp>
1718

1819
#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_DESTINATION_HPP__
8+
#define__NETWORK_MESSAGE_WRAPPERS_DESTINATION_HPP__
9+
10+
namespaceboost {namespacenetwork {
11+
12+
namespaceimpl {
13+
template<classTag>
14+
structdestination_wrapper :publicdetail::wrapper_base<Tag> {
15+
typedef Tag tag;
16+
typedef basic_message<tag> message_type;
17+
18+
explicitdestination_wrapper(message_type & message_)
19+
: detail::wrapper_base<tag>(message_)
20+
{ };
21+
22+
operatorstd::string ()const {
23+
returnstd::string(detail::wrapper_base<tag>::_message.destination());
24+
};
25+
};
26+
};// namespace impl
27+
28+
template<classTag>
29+
inline std::string
30+
destination(basic_message<Tag> & message_) {
31+
return impl::destination_wrapper<Tag>(message_);
32+
};
33+
34+
};// namespace network
35+
36+
};// namespace boost
37+
38+
#endif __NETWORK_MESSAGE_WRAPPERS_DESTINATION_HPP__
39+

‎libs/network/test/message_test.cpp‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,12 @@ BOOST_AUTO_TEST_CASE(source_directive_test) {
4848
msg <<source("Somewhere Out There") ;
4949

5050
BOOST_CHECK_EQUAL(source(msg),"Somewhere Out There");
51-
}
51+
}
52+
53+
BOOST_AUTO_TEST_CASE(destination_directive_test) {
54+
usingnamespaceboost::network;
55+
message msg;
56+
msg <<destination("Somewhere Out There");
57+
58+
BOOST_CHECK_EQUAL(destination(msg),"Somewhere Out There");
59+
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp