File tree Expand file tree Collapse file tree 7 files changed +105
-2
lines changed Expand file tree Collapse file tree 7 files changed +105
-2
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ namespace boost { namespace network {
54
54
return _source;
55
55
};
56
56
57
+ std::string & destination () const {
58
+ return _destination;
59
+ };
60
+
57
61
private:
58
62
59
63
friend struct detail ::directive_base<tag> ;
@@ -62,6 +66,7 @@ namespace boost { namespace network {
62
66
mutable headers_container_type _headers;
63
67
mutable std::string _body;
64
68
mutable std::string _source;
69
+ mutable std::string _destination;
65
70
};
66
71
67
72
typedef basic_message<> message; // default message type
Original file line number Diff line number Diff line change 13
13
#include < boost/network/message/directives/header.hpp>
14
14
#include < boost/network/message/directives/body.hpp>
15
15
#include < boost/network/message/directives/source.hpp>
16
+ #include < boost/network/message/directives/destination.hpp>
16
17
17
18
namespace boost { namespace network {
18
19
Original file line number Diff line number Diff line change
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
+ namespace boost { namespace network {
20
+
21
+ namespace impl {
22
+ template <class Tag >
23
+ struct destination_directive : public detail ::directive_base<Tag> {
24
+ typedef Tag tag;
25
+
26
+ explicit destination_directive ( std::string const & destination)
27
+ : _destination(destination)
28
+ { };
29
+
30
+ void operator () (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::string const & 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__
Original file line number Diff line number Diff line change 7
7
#ifndef __NETWORK_MESSAGE_DIRECTIVES_SOURCE_HPP__
8
8
#define __NETWORK_MESSAGE_DIRECTIVES_SOURCE_HPP__
9
9
10
- /* * header .hpp
10
+ /* * source .hpp
11
11
*
12
12
* Defines the types involved and the semantics of adding
13
13
* source information into message objects.
Original file line number Diff line number Diff line change 14
14
#include < boost/network/message/wrappers/headers.hpp>
15
15
#include < boost/network/message/wrappers/body.hpp>
16
16
#include < boost/network/message/wrappers/source.hpp>
17
+ #include < boost/network/message/wrappers/destination.hpp>
17
18
18
19
#endif // __NETWORK_MESSAGE_WRAPPERS_HPP__
Original file line number Diff line number Diff line change
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
+ namespace boost { namespace network {
11
+
12
+ namespace impl {
13
+ template <class Tag >
14
+ struct destination_wrapper : public detail ::wrapper_base<Tag> {
15
+ typedef Tag tag;
16
+ typedef basic_message<tag> message_type;
17
+
18
+ explicit destination_wrapper (message_type & message_)
19
+ : detail::wrapper_base<tag>(message_)
20
+ { };
21
+
22
+ operator std::string () const {
23
+ return std::string (detail::wrapper_base<tag>::_message.destination ());
24
+ };
25
+ };
26
+ }; // namespace impl
27
+
28
+ template <class Tag >
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
+
Original file line number Diff line number Diff line change @@ -48,4 +48,12 @@ BOOST_AUTO_TEST_CASE(source_directive_test) {
48
48
msg << source (" Somewhere Out There" ) ;
49
49
50
50
BOOST_CHECK_EQUAL ( source (msg), " Somewhere Out There" );
51
- }
51
+ }
52
+
53
+ BOOST_AUTO_TEST_CASE (destination_directive_test) {
54
+ using namespace boost ::network;
55
+ message msg;
56
+ msg << destination (" Somewhere Out There" );
57
+
58
+ BOOST_CHECK_EQUAL ( destination (msg), " Somewhere Out There" );
59
+ };
You can’t perform that action at this time.
0 commit comments