forked from glynos/cpp-netlib
-
Notifications
You must be signed in to change notification settings - Fork 424
Expand file tree
/
Copy pathmessage.hpp
More file actions
82 lines (67 loc) · 2.53 KB
/
message.hpp
File metadata and controls
82 lines (67 loc) · 2.53 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
// Copyright 2011 Dean Michael Berris (dberris@google.com).
// Copyright 2011 Google, Inc.
// 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_MESSAGE_HPP_20111021
#define NETWORK_MESSAGE_MESSAGE_HPP_20111021
#include <string>
#include <map>
#include <functional>
#include <network/message/message_base.hpp>
#include <boost/shared_container_iterator.hpp>
namespace network {
struct message_pimpl;
// The common message type.
struct message : message_base {
// Nested types
typedef boost::iterator_range<
std::multimap<std::string, std::string>::const_iterator> headers_range;
// Constructors
message();
message(message const& other);
#if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
message(message && other) = default;
#endif // !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
// Assignment
message& operator=(message const & other);
message& operator=(message && other);
// Mutators
virtual void set_destination(std::string const& destination);
virtual void set_source(std::string const& source);
virtual void append_header(std::string const& name, std::string const& value);
virtual void remove_headers(std::string const& name);
virtual void remove_headers();
virtual void set_body(std::string const& body);
virtual void append_body(std::string const& data);
// Retrievers
virtual void get_destination(std::string& destination) const;
virtual void get_source(std::string& source) const;
virtual void get_headers(std::function<
void(std::string const&, std::string const&)> inserter) const;
virtual void get_headers(
std::string const& name,
std::function<
void(std::string const&, std::string const&)> inserter) const;
virtual void get_headers(
std::function<bool(std::string const&, std::string const&)> predicate,
std::function<
void(std::string const&, std::string const&)> inserter) const;
virtual void get_body(std::string& body) const;
virtual void get_body(
std::function<void(std::string::const_iterator, size_t)> chunk_reader,
size_t size) const;
void swap(message& other);
// Destructor
virtual ~message();
private:
message_pimpl* pimpl;
};
inline void swap(message& left, message& right) { left.swap(right); }
template <class Directive>
message_base& operator<<(message_base& msg, Directive directive) {
directive(msg);
return msg;
}
} // namespace network
#endif /* NETWORK_MESSAGE_MESSAGE_HPP_20111021 */