Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd0ab2cb

Browse files
committed
Making necessary changes to make the one-liner example work.
1 parentdd7dd8c commitd0ab2cb

File tree

5 files changed

+89
-24
lines changed

5 files changed

+89
-24
lines changed

‎boost/network/detail/wrapper_base.hpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,29 @@ namespace boost { namespace network { namespace detail {
1111

1212
template<classTag>
1313
structwrapper_base {
14-
typedef Tag tag;
15-
explicitwrapper_base(basic_message<tag> & message_)
14+
explicitwrapper_base(basic_message<Tag> & message_)
1615
: _message(message_)
17-
{};
16+
{};
1817

1918
protected:
20-
virtual~wrapper_base()
21-
{ };// for extending only
19+
~wrapper_base() {};// for extending only
2220

23-
mutablebasic_message<tag> & _message;
21+
basic_message<Tag> & _message;
2422
};
2523

24+
template<classTag>
25+
structwrapper_base_const {
26+
explicitwrapper_base_const(basic_message<Tag>const & message_)
27+
: _message(message_)
28+
{}
29+
30+
protected:
31+
~wrapper_base_const() {};// for extending only
32+
33+
basic_message<Tag>const & _message;
34+
};
35+
36+
2637
}// namespace detail
2738

2839
}// namespace network

‎boost/network/message.hpp

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,49 +44,65 @@ namespace boost { namespace network {
4444

4545
typedef Tag tag;
4646

47-
typedeftypename headers_container<tag>::type headers_container_type;
48-
typedeftypename string<tag>::type string_type;
47+
typedeftypename headers_container<Tag>::type headers_container_type;
48+
typedeftypename string<Tag>::type string_type;
4949

5050
basic_message()
5151
: _headers(), _body(), _source(), _destination()
52-
{ };
52+
{ }
5353

5454
basic_message(const basic_message & other)
5555
: _headers(other._headers), _body(other._body), _source(other._source), _destination(other._destination)
56-
{ };
56+
{ }
5757

58-
basic_message &operator=(basic_message<tag> rhs) {
58+
basic_message &operator=(basic_message<Tag> rhs) {
5959
rhs.swap(*this);
6060
return *this;
61-
};
61+
}
6262

63-
voidswap(basic_message<tag> & other) {
63+
voidswap(basic_message<Tag> & other) {
6464
other._headers.swap(_headers);
6565
other._body.swap(_body);
6666
other._source.swap(_source);
6767
other._destination.swap(_destination);
68-
};
68+
}
6969

7070
headers_container_type &headers() {
7171
return _headers;
72-
};
72+
}
73+
74+
headers_container_typeheaders()const {
75+
return _headers;
76+
}
7377

7478
string_type &body() {
7579
return _body;
76-
};
80+
}
81+
82+
string_typebody()const {
83+
return _body;
84+
}
7785

7886
string_type &source() {
7987
return _source;
80-
};
88+
}
89+
90+
string_typesource()const {
91+
return _source;
92+
}
8193

8294
string_type &destination() {
8395
return _destination;
84-
};
96+
}
97+
98+
string_typedestination()const {
99+
return _destination;
100+
}
85101

86102
private:
87103

88-
friendstructdetail::directive_base<tag> ;
89-
friendstructdetail::wrapper_base<tag> ;
104+
friendstructdetail::directive_base<Tag> ;
105+
friendstructdetail::wrapper_base<Tag> ;
90106

91107
headers_container_type _headers;
92108
string_type _body;

‎boost/network/message/wrappers/body.hpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,32 @@ namespace boost { namespace network {
1616
namespaceimpl {
1717
template<classTag>
1818
structbody_wrapper :publicdetail::wrapper_base<Tag> {
19-
typedef Tag tag;
20-
typedef basic_message<tag> message_type;
19+
typedef basic_message<Tag> message_type;
2120
typedeftypename string<Tag>::type string_type;
2221

23-
explicitbody_wrapper(basic_message<tag> & message_)
24-
: detail::wrapper_base<tag>(message_)
22+
explicitbody_wrapper(basic_message<Tag> & message_)
23+
: detail::wrapper_base<Tag>(message_)
2524
{ };
2625

2726
operatorstring_type ()const {
2827
returnstring_type(detail::wrapper_base<Tag>::_message.body());
2928
};
3029
};
30+
31+
template<classTag>
32+
structbody_wrapper_const :publicdetail::wrapper_base_const<Tag> {
33+
typedef basic_message<Tag> message_type;
34+
typedeftypename string<Tag>::type string_type;
35+
36+
explicitbody_wrapper_const(basic_message<Tag>const & message_)
37+
: detail::wrapper_base_const<Tag>(message_)
38+
{};
39+
40+
operatorstring_type ()const {
41+
returnstring_type(detail::wrapper_base_const<Tag>::_message.body());
42+
}
43+
};
44+
3145
}// namespace impl
3246

3347
template<classTag>
@@ -36,6 +50,12 @@ namespace boost { namespace network {
3650
return impl::body_wrapper<Tag>(message_);
3751
}
3852

53+
template<classTag>
54+
inlinetypename string<Tag>::type
55+
body(basic_message<Tag>const & message_) {
56+
return impl::body_wrapper_const<Tag>(message_);
57+
}
58+
3959
}// namespace network
4060

4161
}// namespace boost

‎libs/network/example/Jamfile.v2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,5 @@ exe simple_wget : simple_wget.cpp ;
3131
exe hello_world_server : http/hello_world_server.cpp ;
3232

3333
exe hello_world_client : http/hello_world_client.cpp ;
34+
35+
exe one_liner : http/one_liner.cpp ;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
// Copyright Dean Michael Berris 2010.
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+
#include<boost/network.hpp>
8+
9+
usingnamespacestd;
10+
usingnamespaceboost::network;
11+
usingnamespaceboost::network::http;
12+
13+
intmain(int argc,constchar *argv[]) {
14+
cout <<body(client().get(client::request("http://www.boost.org/")));
15+
return0;
16+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp