Skip to content

Commit 2e18f32

Browse files
committed
Merging from master to the netbook repo.
2 parents 0ea9725 + 9e4899e commit 2e18f32

File tree

168 files changed

+8834
-2107
lines changed

Some content is hidden

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

168 files changed

+8834
-2107
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ CMakeCache.txt
55
CMakeFiles
66
Makefile
77
Testing
8+
build
9+
_build
810
bin
911
*.gch
1012

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ endif()
1414
enable_testing()
1515
add_subdirectory(libs/network/test)
1616
add_subdirectory(libs/mime/test)
17-
17+
add_subdirectory(libs/network/example)

boost/mime.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ namespace detail {
362362

363363

364364
template<typename Iterator, typename traits>
365-
boost::shared_ptr< basic_mime<traits> > parse_mime ( Iterator &begin, Iterator end, const char *default_content_type = "text/plain" );
365+
static boost::shared_ptr< basic_mime<traits> > parse_mime ( Iterator &begin, Iterator end, const char *default_content_type = "text/plain" );
366366
}
367367

368368

boost/network/constants.hpp

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#ifndef BOOST_NETWORK_CONSTANTS_HPP_20100808
2+
#define BOOST_NETWORK_CONSTANTS_HPP_20100808
3+
4+
// Copyright 2010 (C) Dean Michael Berris
5+
// Distributed under the Boost Software License, Version 1.0.
6+
// (See accompanying file LICENSE_1_0.txt or copy at
7+
// http://www.boost.org/LICENSE_1_0.txt)
8+
9+
#include <boost/network/support/is_default_string.hpp>
10+
#include <boost/network/support/is_default_wstring.hpp>
11+
#include <boost/mpl/if.hpp>
12+
13+
namespace boost { namespace network {
14+
15+
namespace impl {
16+
template <class Tag>
17+
struct constants_narrow {
18+
19+
static char const * crlf() {
20+
static char crlf_[] = { '\r', '\n', 0 };
21+
return crlf_;
22+
}
23+
24+
static char const * dot() {
25+
static char dot_[] = { '.', 0 };
26+
return dot_;
27+
}
28+
29+
static char const * http_slash() {
30+
static char http_slash_[] = { 'H', 'T', 'T', 'P', '/', 0 };
31+
return http_slash_;
32+
}
33+
34+
static char const * space() {
35+
static char space_[] = {' ', 0};
36+
return space_;
37+
}
38+
39+
static char const * slash() {
40+
static char slash_[] = {'/', 0};
41+
return slash_;
42+
}
43+
44+
static char const * host() {
45+
static char host_[] = {'H', 'o', 's', 't', 0};
46+
return host_;
47+
}
48+
49+
static char const * colon() {
50+
static char colon_[] = {':', 0};
51+
return colon_;
52+
}
53+
54+
static char const * accept() {
55+
static char accept_[] = {'A', 'c', 'c', 'e', 'p', 't', 0};
56+
return accept_;
57+
}
58+
59+
static char const * default_accept_mime() {
60+
static char mime_[] = {
61+
'*', '/', '*', 0
62+
};
63+
return mime_;
64+
}
65+
66+
static char const * accept_encoding() {
67+
static char accept_encoding_[] = {
68+
'A','c','c','e','p','t','-','E','n','c','o','d','i','n','g',0
69+
};
70+
return accept_encoding_;
71+
}
72+
73+
static char const * default_accept_encoding() {
74+
static char default_accept_encoding_[] = {
75+
'i','d','e','n','t','i','t','y',';','q','=','1','.','0',',',' ','*',';','q','=','0',0
76+
};
77+
return default_accept_encoding_;
78+
}
79+
80+
static char const * user_agent() {
81+
static char user_agent_[] = {
82+
'U','s','e','r','-','A','g','e','n','t',0
83+
};
84+
return user_agent_;
85+
}
86+
87+
static char const * cpp_netlib_slash() {
88+
static char cpp_netlib_slash_[] = {
89+
'c','p','p','-','n','e','t','l','i','b','/',0
90+
};
91+
return cpp_netlib_slash_;
92+
}
93+
94+
};
95+
96+
template <class Tag>
97+
struct constants_wide {
98+
};
99+
}
100+
101+
template <class Tag>
102+
struct constants :
103+
mpl::if_<
104+
is_default_string<Tag>,
105+
impl::constants_narrow<Tag>,
106+
typename mpl::if_<
107+
is_default_wstring<Tag>,
108+
impl::constants_wide<Tag>,
109+
unsupported_tag<Tag>
110+
>::type
111+
>::type
112+
{};
113+
114+
} // namespace network
115+
116+
} // namespace boost
117+
118+
#endif // BOOST_NETWORK_CONSTANTS_HPP_20100808

boost/network/message.hpp

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@
66
#ifndef __NETWORK_MESSAGE_HPP__
77
#define __NETWORK_MESSAGE_HPP__
88

9-
#include <map>
10-
#include <string>
11-
12-
13-
// include message declaration
149
#include "boost/network/message_fwd.hpp"
15-
16-
// include traits implementation
1710
#include <boost/network/traits/string.hpp>
1811
#include <boost/network/traits/ostringstream.hpp>
1912
#include <boost/network/traits/headers_container.hpp>
20-
21-
// include directives base
2213
#include <boost/network/detail/directive_base.hpp>
23-
24-
// include wrappers base
2514
#include <boost/network/detail/wrapper_base.hpp>
15+
#include <boost/network/message/directives.hpp>
16+
#include <boost/network/message/wrappers.hpp>
17+
#include <boost/network/message/transformers.hpp>
18+
19+
#include <boost/network/message/modifiers/add_header.hpp>
20+
#include <boost/network/message/modifiers/remove_header.hpp>
21+
#include <boost/network/message/modifiers/clear_headers.hpp>
22+
#include <boost/network/message/modifiers/source.hpp>
23+
#include <boost/network/message/modifiers/destination.hpp>
24+
#include <boost/network/message/modifiers/body.hpp>
2625

2726
#include <boost/network/message/message_concept.hpp>
2827

@@ -61,24 +60,40 @@ namespace boost { namespace network {
6160
}
6261

6362
void swap(basic_message<Tag> & other) {
64-
other._headers.swap(_headers);
65-
other._body.swap(_body);
66-
other._source.swap(_source);
67-
other._destination.swap(_destination);
63+
std::swap(other._headers, _headers);
64+
std::swap(other._body, _body);
65+
std::swap(other._source, _source);
66+
std::swap(other._destination, _destination);
6867
}
6968

7069
headers_container_type & headers() {
7170
return _headers;
7271
}
7372

74-
headers_container_type headers() const {
73+
void headers(headers_container_type const & headers_) const {
74+
_headers = headers_;
75+
}
76+
77+
void add_header(typename headers_container_type::value_type const & pair_) const {
78+
_headers.insert(pair_);
79+
}
80+
81+
void remove_header(typename headers_container_type::key_type const & key) const {
82+
_headers.erase(key);
83+
}
84+
85+
headers_container_type & headers() const {
7586
return _headers;
7687
}
7788

7889
string_type & body() {
7990
return _body;
8091
}
8192

93+
void body(string_type const & body_) const {
94+
_body = body_;
95+
}
96+
8297
string_type body() const {
8398
return _body;
8499
}
@@ -87,6 +102,10 @@ namespace boost { namespace network {
87102
return _source;
88103
}
89104

105+
void source(string_type const & source_) const {
106+
_source = source_;
107+
}
108+
90109
string_type source() const {
91110
return _source;
92111
}
@@ -95,6 +114,10 @@ namespace boost { namespace network {
95114
return _destination;
96115
}
97116

117+
void destination(string_type const & destination_) const {
118+
_destination = destination_;
119+
}
120+
98121
string_type destination() const {
99122
return _destination;
100123
}
@@ -104,10 +127,10 @@ namespace boost { namespace network {
104127
friend struct detail::directive_base<Tag> ;
105128
friend struct detail::wrapper_base<Tag> ;
106129

107-
headers_container_type _headers;
108-
string_type _body;
109-
string_type _source;
110-
string_type _destination;
130+
mutable headers_container_type _headers;
131+
mutable string_type _body;
132+
mutable string_type _source;
133+
mutable string_type _destination;
111134
};
112135

113136
template <class Tag>
@@ -122,14 +145,5 @@ BOOST_CONCEPT_ASSERT((Message<basic_message<boost::network::tags::default_wstrin
122145
} // namespace network
123146
} // namespace boost
124147

125-
#include <boost/network/message/directives.hpp>
126-
// pull in directives header file
127-
128-
#include <boost/network/message/wrappers.hpp>
129-
// pull in wrappers header file
130-
131-
#include <boost/network/message/transformers.hpp>
132-
// pull in transformer header file
133-
134148
#endif // __NETWORK_MESSAGE_HPP__
135149

boost/network/message/directives/body.hpp

Lines changed: 33 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,54 @@
11

2-
// Copyright Dean Michael Berris 2007.
2+
// Copyright Dean Michael Berris 2007-2010.
33
// Distributed under the Boost Software License, Version 1.0.
44
// (See accompanying file LICENSE_1_0.txt or copy at
55
// http://www.boost.org/LICENSE_1_0.txt)
66

77
#ifndef __NETWORK_MESSAGE_DIRECTIVES_BODY_HPP__
88
#define __NETWORK_MESSAGE_DIRECTIVES_BODY_HPP__
99

10-
#include <boost/network/traits/string.hpp>
10+
#include <boost/network/message/directives/detail/string_directive.hpp>
11+
#include <boost/network/message/directives/detail/string_value.hpp>
1112

12-
13-
/** body.hpp
14-
*
15-
* Defines the types involved and the semantics of adding
16-
* body contents into message objects.
17-
*
18-
* WARNING: DO NOT INCLUDE THIS HEADER DIRECTLY. THIS REQUIRES
19-
* TYPES TO BE DEFINED FROM EARLIER FILES THAT INCLUDE THIS
20-
* HEADER.
21-
*/
2213
namespace boost { namespace network {
23-
namespace impl {
24-
template <
25-
class T
26-
>
27-
struct body_directive {
28-
29-
explicit body_directive(T body) :
30-
_body(body)
31-
{ };
32-
33-
template <class MessageTag>
34-
void operator() (basic_message<MessageTag> & msg) const {
35-
msg.body() = _body;
36-
}
3714

38-
private:
15+
namespace impl {
16+
17+
struct body_directive_base {
18+
19+
template <class Message>
20+
struct string_visitor : boost::static_visitor<> {
21+
Message const & message_;
22+
string_visitor(Message const & message)
23+
: message_(message) {}
24+
void operator()(typename detail::string_value<typename Message::tag>::type const & body) const {
25+
message_.body(body);
26+
}
27+
template <class T> void operator()(T const &) const {
28+
// FIXME -- fail here
29+
}
30+
};
3931

40-
T _body;
41-
};
42-
} // namespace impl
32+
};
4333

34+
typedef detail::string_directive<body_directive_base> body_directive;
4435

45-
// template <
46-
// class T
47-
// >
48-
// inline
49-
// impl::body_directive<T>
50-
// body(T body_, boost::disable_if<T::message>::type) {
51-
// return impl::body_directive<T>(body_);
52-
// }
36+
} // namespace impl
5337

5438

55-
inline
56-
impl::body_directive<std::string>
57-
body(std::string body_) {
58-
return impl::body_directive<std::string>(body_);
59-
}
39+
inline impl::body_directive const body(string<tags::default_string>::type const & input) {
40+
return impl::body_directive(input);
41+
}
42+
43+
inline impl::body_directive const body(string<tags::default_wstring>::type const & input) {
44+
return impl::body_directive(input);
45+
}
6046

47+
template <class InputType>
48+
inline impl::body_directive const body(boost::shared_future<InputType> const & input) {
49+
return impl::body_directive(input);
50+
}
6151

62-
inline
63-
impl::body_directive<std::wstring>
64-
body(std::wstring body_) {
65-
return impl::body_directive<std::wstring>(body_);
66-
}
6752
} // namespace network
6853
} // namespace boost
6954

0 commit comments

Comments
 (0)