1010#include < map>
1111#include < string>
1212
13- // forward declarations
14- namespace boost {namespace network {
15- template <class tag >
16- class basic_message ;
17- };// namespace network
1813
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>
2019
20+ // include directives base
2121#include < boost/network/detail/directive_base.hpp>
22+
23+ // include wrappers base
2224#include < boost/network/detail/wrapper_base.hpp>
2325
2426/* * message.hpp
@@ -31,33 +33,50 @@ namespace boost { namespace network {
3133*/
3234namespace boost {namespace network {
3335
34- struct tags {
35- struct default_ {
36- typedef std::string str_type;
37- typedef std::ostringstream ostringstream_type;
38- };
39- };
40-
4136/* * The common message type.
4237*/
43- template <class tag =tags::default_ >
38+ template <class Tag >
4439class basic_message {
4540public:
46- typedef std::multimap<std::string, std::string> headers_container_type;
4741
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 () {
4968return _headers;
5069 };
5170
52- std::string &body ()const {
71+ string_type &body () {
5372return _body;
5473 };
5574
56- std::string &source ()const {
75+ string_type &source () {
5776return _source;
5877 };
5978
60- std::string &destination ()const {
79+ string_type &destination () {
6180return _destination;
6281 };
6382
@@ -66,16 +85,21 @@ namespace boost { namespace network {
6685friend struct detail ::directive_base<tag> ;
6786friend struct detail ::wrapper_base<tag> ;
6887
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);
7398 };
7499
75- typedef basic_message<> message; // default message type
100+ } // namespace network
76101
77- };// namespace network
78- };// namespace boost
102+ }// namespace boost
79103
80104#include < boost/network/message/directives.hpp>
81105// pull in directives header file