Skip to content

Commit 603c71a

Browse files
author
mikhail_beris
committed
Merging from http_integration r1-r71 .
1 parent f0fcc16 commit 603c71a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3939
-247
lines changed

Jamroot

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# (See accompanying file LICENSE_1_0.txt or copy at
55
# http://www.boost.org/LICENSE_1_0.txt)
66

7-
import modules ;
7+
import os ;
88

9-
local BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ;
9+
local BOOST_ROOT = [ os.environ BOOST_ROOT ] ;
1010

1111
use-project /boost : $(BOOST_ROOT) ;
1212

boost/network/detail/directive_base.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ namespace boost { namespace network { namespace detail {
2424
// mutable basic_message<tag> & _message;
2525
};
2626

27-
}; // namespace detail
27+
} // namespace detail
2828

29-
}; // namespace network
29+
} // namespace network
3030

31-
}; // namespace boost
31+
} // namespace boost
3232

3333
#endif // __NETWORK_DETAIL_DIRECTIVE_BASE_HPP__
3434

boost/network/detail/wrapper_base.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ namespace boost { namespace network { namespace detail {
2323
mutable basic_message<tag> & _message;
2424
};
2525

26-
}; // namespace detail
26+
} // namespace detail
2727

28-
}; // namespace network
28+
} // namespace network
2929

30-
}; // namespace boost
30+
} // namespace boost
3131

3232
#endif // __NETWORK_DETAIL_WRAPPER_BASE_HPP__
3333

boost/network/message.hpp

+50-26
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@
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
*/
3234
namespace 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>
4439
class basic_message {
4540
public:
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() {
4968
return _headers;
5069
};
5170

52-
std::string & body() const {
71+
string_type & body() {
5372
return _body;
5473
};
5574

56-
std::string & source() const {
75+
string_type & source() {
5776
return _source;
5877
};
5978

60-
std::string & destination() const {
79+
string_type & destination() {
6180
return _destination;
6281
};
6382

@@ -66,16 +85,21 @@ namespace boost { namespace network {
6685
friend struct detail::directive_base<tag> ;
6786
friend 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

boost/network/message/directives.hpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,20 @@
1414
#include <boost/network/message/directives/body.hpp>
1515
#include <boost/network/message/directives/source.hpp>
1616
#include <boost/network/message/directives/destination.hpp>
17+
#include <boost/network/message/directives/remove_header.hpp>
1718

1819
namespace boost { namespace network {
1920

20-
template <class Tag, template <class> class Directive>
21+
template <class Tag, class Directive>
2122
inline basic_message<Tag> &
22-
operator<< (basic_message<Tag> & message_, Directive<Tag> const & directive) {
23+
operator<< (basic_message<Tag> & message_, Directive const & directive) {
2324
directive(message_);
2425
return message_;
25-
};
26+
}
2627

27-
}; // namespace network
28+
} // namespace network
2829

29-
}; // namespace boost
30+
} // namespace boost
3031

3132
#endif // __NETWORK_MESSAGE_DIRECTIVES_HPP__
3233

boost/network/message/directives/body.hpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,25 @@ namespace boost { namespace network {
2929
_body(body)
3030
{ };
3131

32-
void operator() (basic_message<tag> & msg) const {
32+
template <class MessageTag>
33+
void operator() (basic_message<MessageTag> & msg) const {
3334
msg.body() = _body;
34-
};
35+
}
3536

3637
private:
3738

3839
std::string _body;
3940
};
40-
}; // namespace impl
41+
} // namespace impl
4142

4243
inline impl::body_directive<tags::default_>
4344
body(std::string const & body_) {
4445
return impl::body_directive<tags::default_>(body_);
45-
};
46+
}
4647

47-
}; // namespace network
48+
} // namespace network
4849

49-
}; // namespace boost
50+
} // namespace boost
5051

5152
#endif // __NETWORK_MESSAGE_DIRECTIVES_BODY_HPP__
5253

boost/network/message/directives/destination.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ namespace boost { namespace network {
3535

3636
std::string _destination;
3737
};
38-
}; // namespace impl
38+
} // namespace impl
3939

4040
inline impl::destination_directive<tags::default_>
4141
destination(std::string const & destination_) {
4242
return impl::destination_directive<tags::default_>(destination_);
43-
};
43+
}
4444

45-
}; // namespace network
45+
} // namespace network
4646

47-
}; // namespace boost
47+
} // namespace boost
4848

4949
#endif // __NETWORK_MESSAGE_DIRECTIVES_DESTINATION_HPP__

boost/network/message/directives/header.hpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,34 @@ namespace boost { namespace network {
3131
_header_value(header_value)
3232
{ };
3333

34-
void operator() (basic_message<tag> & msg) const {
34+
template <class MessageTag>
35+
void operator() (basic_message<MessageTag> & msg) const {
3536
msg.headers().insert(
36-
typename basic_message<tag>::headers_container_type::value_type(
37+
typename basic_message<MessageTag>::headers_container_type::value_type(
3738
_header_name,
3839
_header_value
3940
)
4041
);
41-
};
42+
}
4243

4344
private:
4445

4546
mutable std::string _header_name;
4647
mutable std::string _header_value;
4748
};
48-
}; // namespace impl
49+
} // namespace impl
4950

51+
template <class T1, class T2>
5052
inline impl::header_directive<tags::default_>
51-
header(std::string const & header_name,
52-
std::string const & header_value) {
53+
header(T1 header_name,
54+
T2 header_value) {
5355
return impl::header_directive<tags::default_>(header_name,
5456
header_value);
55-
};
57+
}
5658

57-
};
59+
}
5860

59-
};
61+
}
6062

6163
#endif // __NETWORK_MESSAGE_DIRECTIVES_HEADER_HPP__
6264

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
// Copyright Dean Michael Berris 2008.
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_REMOVE_HEADER_HPP
8+
#define NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP
9+
10+
namespace boost { namespace network {
11+
12+
namespace impl {
13+
template <class Tag>
14+
struct remove_header_directive : public detail::directive_base<Tag> {
15+
typedef Tag tag;
16+
explicit remove_header_directive(
17+
std::string const & header_name
18+
) :
19+
header_name_(header_name)
20+
{ };
21+
22+
template <class MessageTag>
23+
void operator() (basic_message<MessageTag> & msg) const {
24+
msg.headers().erase(header_name_);
25+
}
26+
27+
private:
28+
mutable std::string header_name_;
29+
};
30+
31+
} // namespace impl
32+
33+
template <class T1>
34+
inline impl::remove_header_directive<tags::default_>
35+
remove_header(T1 header_name) {
36+
return impl::remove_header_directive<tags::default_>(header_name);
37+
}
38+
39+
} // namespace network
40+
41+
} // namespace boost
42+
43+
#endif // NETWORK_MESSAGE_DIRECTIVES_REMOVE_HEADER_HPP
44+

boost/network/message/directives/source.hpp

+20-21
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,31 @@
1919
namespace boost { namespace network {
2020

2121
namespace impl {
22-
template <class Tag>
23-
struct source_directive : public detail::directive_base<Tag> {
24-
typedef Tag tag;
25-
26-
explicit source_directive ( std::string const & source)
27-
: _source(source)
28-
{ };
29-
30-
void operator() (basic_message<tag> & msg) const {
31-
msg.source() = _source;
32-
};
33-
34-
private:
35-
36-
mutable std::string _source;
37-
};
22+
struct source_directive : public detail::directive_base<tags::default_> {
23+
24+
explicit source_directive ( std::string const & source)
25+
: _source(source)
26+
{ };
27+
28+
template <class Tag>
29+
void operator() (basic_message<Tag> & msg) const {
30+
msg.source() = _source;
31+
}
32+
33+
private:
34+
35+
mutable std::string _source;
36+
};
3837
} // namespace impl
3938

40-
inline impl::source_directive<tags::default_>
39+
inline impl::source_directive
4140
source(std::string const & source_) {
42-
return impl::source_directive<tags::default_>(source_);
43-
};
41+
return impl::source_directive(source_);
42+
}
4443

45-
}; // namespace network
44+
} // namespace network
4645

47-
}; // namespace boost
46+
} // namespace boost
4847

4948
#endif // __NETWORK_MESSAGE_DIRECTIVES_SOURCE_HPP__
5049

0 commit comments

Comments
 (0)