Repository navigation
Expand file tree
/
Copy pathmessage.hpp
More file actions
115 lines (85 loc) · 2.95 KB
/
Copy pathmessage.hpp
File metadata and controls
115 lines (85 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright Dean Michael Berris 2007.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef __NETWORK_MESSAGE_HPP__
#define __NETWORK_MESSAGE_HPP__
#include <map>
#include <string>
// include message declaration
#include "boost/network/message_fwd.hpp"
// include traits implementation
#include <boost/network/traits/string.hpp>
#include <boost/network/traits/ostringstream.hpp>
#include <boost/network/traits/headers_container.hpp>
// include directives base
#include <boost/network/detail/directive_base.hpp>
// include wrappers base
#include <boost/network/detail/wrapper_base.hpp>
/** message.hpp
*
* This header file implements the common message type which
* all networking implementations under the boost::network
* namespace. The common message type allows for easy message
* construction and manipulation suited for networked
* application development.
*/
namespace boost { namespace network {
/** The common message type.
*/
template <class Tag>
class basic_message {
public:
typedef Tag tag;
typedef typename headers_container<tag>::type headers_container_type;
typedef typename string<tag>::type string_type;
basic_message()
: _headers(), _body(), _source(), _destination()
{ };
basic_message(const basic_message & other)
: _headers(other._headers), _body(other._body), _source(other._source), _destination(other._destination)
{ };
basic_message & operator=(basic_message<tag> rhs) {
rhs.swap(*this);
return *this;
};
void swap(basic_message<tag> & other) {
other._headers.swap(_headers);
other._body.swap(_body);
other._source.swap(_source);
other._destination.swap(_destination);
};
headers_container_type & headers() {
return _headers;
};
string_type & body() {
return _body;
};
string_type & source() {
return _source;
};
string_type & destination() {
return _destination;
};
private:
friend struct detail::directive_base<tag> ;
friend struct detail::wrapper_base<tag> ;
headers_container_type _headers;
string_type _body;
string_type _source;
string_type _destination;
};
template <class Tag>
void swap(basic_message<Tag> & left, basic_message<Tag> & right) {
// swap for ADL
left.swap(right);
}
} // namespace network
} // namespace boost
#include <boost/network/message/directives.hpp>
// pull in directives header file
#include <boost/network/message/wrappers.hpp>
// pull in wrappers header file
#include <boost/network/message/transformers.hpp>
// pull in transformer header file
#endif // __NETWORK_MESSAGE_HPP__