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 {
5454 return _source;
5555 };
5656
57+ std::string & destination () const {
58+ return _destination;
59+ };
60+
5761 private:
5862
5963 friend struct detail ::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
Original file line number Diff line number Diff line change 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
1718namespace boost { namespace network {
1819
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 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.
Original file line number Diff line number Diff line change 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__
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) {
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+ 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