10
10
#include < map>
11
11
#include < string>
12
12
13
- // forward declarations
14
- namespace boost { namespace network {
15
- template <class tag >
16
- class basic_message ;
17
- }; // namespace network
18
13
19
- }; // namespace boost
14
+ // include message declaration
15
+ #include " boost/network/message_fwd.hpp"
16
+
17
+ // include traits implementation
18
+ #include < boost/network/message/traits.hpp>
20
19
20
+ // include directives base
21
21
#include < boost/network/detail/directive_base.hpp>
22
+
23
+ // include wrappers base
22
24
#include < boost/network/detail/wrapper_base.hpp>
23
25
24
26
/* * message.hpp
@@ -31,33 +33,50 @@ namespace boost { namespace network {
31
33
*/
32
34
namespace boost { namespace network {
33
35
34
- struct tags {
35
- struct default_ {
36
- typedef std::string str_type;
37
- typedef std::ostringstream ostringstream_type;
38
- };
39
- };
40
-
41
36
/* * The common message type.
42
37
*/
43
- template <class tag =tags::default_ >
38
+ template <class Tag >
44
39
class basic_message {
45
40
public:
46
- typedef std::multimap<std::string, std::string> headers_container_type;
47
41
48
- headers_container_type & headers () const {
42
+ typedef Tag tag;
43
+
44
+ typedef typename headers_container<tag>::type headers_container_type;
45
+ typedef typename string<tag>::type string_type;
46
+
47
+ basic_message ()
48
+ : _headers(), _body(), _source(), _destination()
49
+ { };
50
+
51
+ basic_message (const basic_message & other)
52
+ : _headers(other._headers), _body(other._body), _source(other._source), _destination(other._destination)
53
+ { };
54
+
55
+ basic_message & operator =(basic_message<tag> rhs) {
56
+ rhs.swap (*this );
57
+ return *this ;
58
+ };
59
+
60
+ void swap (basic_message<tag> & other) {
61
+ other._headers .swap (_headers);
62
+ other._body .swap (_body);
63
+ other._source .swap (_source);
64
+ other._destination .swap (_destination);
65
+ };
66
+
67
+ headers_container_type & headers () {
49
68
return _headers;
50
69
};
51
70
52
- std::string & body () const {
71
+ string_type & body () {
53
72
return _body;
54
73
};
55
74
56
- std::string & source () const {
75
+ string_type & source () {
57
76
return _source;
58
77
};
59
78
60
- std::string & destination () const {
79
+ string_type & destination () {
61
80
return _destination;
62
81
};
63
82
@@ -66,16 +85,21 @@ namespace boost { namespace network {
66
85
friend struct detail ::directive_base<tag> ;
67
86
friend struct detail ::wrapper_base<tag> ;
68
87
69
- mutable headers_container_type _headers;
70
- mutable std::string _body;
71
- mutable std::string _source;
72
- mutable std::string _destination;
88
+ headers_container_type _headers;
89
+ string_type _body;
90
+ string_type _source;
91
+ string_type _destination;
92
+ };
93
+
94
+ template <class Tag >
95
+ void swap (basic_message<Tag> & left, basic_message<Tag> & right) {
96
+ // swap for ADL
97
+ left.swap (right);
73
98
};
74
99
75
- typedef basic_message<> message; // default message type
100
+ } // namespace network
76
101
77
- }; // namespace network
78
- }; // namespace boost
102
+ } // namespace boost
79
103
80
104
#include < boost/network/message/directives.hpp>
81
105
// pull in directives header file
0 commit comments