Skip to content

Commit fdff8f4

Browse files
committed
Boost is back, baby!
1 parent 769be88 commit fdff8f4

Some content is hidden

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

42 files changed

+442
-432
lines changed

CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ add_definitions(-DBOOST_TEST_DYN_LINK)
4545
# Always use multi-threaded Boost libraries.
4646
set(Boost_USE_MULTI_THREADED ON)
4747

48-
find_package(Boost 1.57.0 REQUIRED)
48+
find_package(Boost 1.57.0 REQUIRED COMPONENTS system)
4949

5050
if (CPP-NETLIB_ENABLE_HTTPS)
5151
find_package( OpenSSL )
@@ -97,9 +97,9 @@ if (Boost_FOUND)
9797
endif(WIN32)
9898
include_directories(${Boost_INCLUDE_DIRS})
9999

100-
# Asio
101-
add_definitions(-DASIO_STANDALONE)
102-
include_directories(deps/asio/asio/include)
100+
# # Asio
101+
# add_definitions(-DASIO_STANDALONE)
102+
# include_directories(deps/asio/asio/include)
103103

104104
enable_testing()
105105
add_subdirectory(libs/network/src)

boost/network/protocol/http/client/async_impl.hpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include <thread>
1212
#include <memory>
1313
#include <functional>
14-
#include <asio/io_service.hpp>
15-
#include <asio/strand.hpp>
14+
#include <boost/asio/io_service.hpp>
15+
#include <boost/asio/strand.hpp>
1616
#include <boost/network/protocol/http/traits/connection_policy.hpp>
1717

1818
namespace boost {
@@ -32,14 +32,14 @@ struct async_client
3232
typedef typename string<Tag>::type string_type;
3333

3434
typedef std::function<void(boost::iterator_range<char const*> const&,
35-
std::error_code const&)>
35+
boost::system::error_code const&)>
3636
body_callback_function_type;
3737

3838
typedef std::function<bool(string_type&)> body_generator_function_type;
3939

4040
async_client(bool cache_resolved, bool follow_redirect,
4141
bool always_verify_peer, int timeout,
42-
std::shared_ptr<::asio::io_service> service,
42+
std::shared_ptr<boost::asio::io_service> service,
4343
optional<string_type> certificate_filename,
4444
optional<string_type> verify_path,
4545
optional<string_type> certificate_file,
@@ -48,10 +48,10 @@ struct async_client
4848
optional<string_type> sni_hostname, long ssl_options)
4949
: connection_base(cache_resolved, follow_redirect, timeout),
5050
service_ptr(service.get() ? service
51-
: std::make_shared<::asio::io_service>()),
51+
: std::make_shared<boost::asio::io_service>()),
5252
service_(*service_ptr),
5353
resolver_(service_),
54-
sentinel_(new ::asio::io_service::work(service_)),
54+
sentinel_(new boost::asio::io_service::work(service_)),
5555
certificate_filename_(std::move(certificate_filename)),
5656
verify_path_(std::move(verify_path)),
5757
certificate_file_(std::move(certificate_file)),
@@ -61,7 +61,7 @@ struct async_client
6161
ssl_options_(ssl_options),
6262
always_verify_peer_(always_verify_peer) {
6363
connection_base::resolver_strand_.reset(
64-
new ::asio::io_service::strand(service_));
64+
new boost::asio::io_service::strand(service_));
6565
if (!service)
6666
lifetime_thread_.reset(new std::thread([this]() { service_.run(); }));
6767
}
@@ -89,10 +89,10 @@ struct async_client
8989
generator);
9090
}
9191

92-
std::shared_ptr<::asio::io_service> service_ptr;
93-
::asio::io_service& service_;
92+
std::shared_ptr<boost::asio::io_service> service_ptr;
93+
boost::asio::io_service& service_;
9494
resolver_type resolver_;
95-
std::shared_ptr<::asio::io_service::work> sentinel_;
95+
std::shared_ptr<boost::asio::io_service::work> sentinel_;
9696
std::shared_ptr<std::thread> lifetime_thread_;
9797
optional<string_type> certificate_filename_;
9898
optional<string_type> verify_path_;

boost/network/protocol/http/client/connection/async_base.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct async_connection_base {
3333
typedef basic_response<Tag> response;
3434
typedef typename std::array<typename char_<Tag>::type, 1024>::const_iterator const_iterator;
3535
typedef iterator_range<const_iterator> char_const_range;
36-
typedef std::function<void(char_const_range const &, std::error_code const &)>
36+
typedef std::function<void(char_const_range const &, boost::system::error_code const &)>
3737
body_callback_function_type;
3838
typedef std::function<bool(string_type &)> body_generator_function_type;
3939
typedef std::shared_ptr<this_type> connection_ptr;

boost/network/protocol/http/client/connection/async_normal.hpp

+49-49
Large diffs are not rendered by default.

boost/network/protocol/http/client/connection/async_protocol_handler.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ struct http_async_protocol_handler {
139139
std::end(result_range));
140140
part_begin = part.begin();
141141
delegate_->read_some(
142-
::asio::mutable_buffers_1(part.data(), part.size()),
142+
boost::asio::mutable_buffers_1(part.data(), part.size()),
143143
callback);
144144
}
145145
return parsed_ok;
@@ -185,7 +185,7 @@ struct http_async_protocol_handler {
185185
std::end(result_range));
186186
part_begin = part.begin();
187187
delegate_->read_some(
188-
::asio::mutable_buffers_1(part.data(), part.size()),
188+
boost::asio::mutable_buffers_1(part.data(), part.size()),
189189
callback);
190190
}
191191
return parsed_ok;
@@ -230,7 +230,7 @@ struct http_async_protocol_handler {
230230
std::end(result_range));
231231
part_begin = part.begin();
232232
delegate_->read_some(
233-
::asio::mutable_buffers_1(part.data(), part.size()),
233+
boost::asio::mutable_buffers_1(part.data(), part.size()),
234234
callback);
235235
}
236236
return parsed_ok;
@@ -317,7 +317,7 @@ struct http_async_protocol_handler {
317317
std::end(result_range));
318318
part_begin = part.begin();
319319
delegate_->read_some(
320-
::asio::mutable_buffers_1(part.data(), part.size()),
320+
boost::asio::mutable_buffers_1(part.data(), part.size()),
321321
callback);
322322
}
323323
return std::make_tuple(
@@ -331,7 +331,7 @@ struct http_async_protocol_handler {
331331
partial_parsed.append(part_begin, bytes);
332332
part_begin = part.begin();
333333
delegate_->read_some(
334-
::asio::mutable_buffers_1(part.data(), part.size()), callback);
334+
boost::asio::mutable_buffers_1(part.data(), part.size()), callback);
335335
}
336336

337337
typedef response_parser<Tag> response_parser_type;

boost/network/protocol/http/client/connection/connection_delegate.hpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99

1010
#include <cstdint>
1111
#include <functional>
12-
#include <asio/ip/tcp.hpp>
13-
#include <asio/streambuf.hpp>
12+
#include <boost/asio/ip/tcp.hpp>
13+
#include <boost/asio/streambuf.hpp>
1414

1515
namespace boost {
1616
namespace network {
1717
namespace http {
1818
namespace impl {
1919

2020
struct connection_delegate {
21-
virtual void connect(::asio::ip::tcp::endpoint &endpoint, std::string host,
21+
virtual void connect(boost::asio::ip::tcp::endpoint &endpoint, std::string host,
2222
std::uint16_t source_port,
23-
std::function<void(std::error_code const &)> handler) = 0;
23+
std::function<void(boost::system::error_code const &)> handler) = 0;
2424
virtual void write(
25-
::asio::streambuf &command_streambuf,
26-
std::function<void(std::error_code const &, size_t)> handler) = 0;
25+
boost::asio::streambuf &command_streambuf,
26+
std::function<void(boost::system::error_code const &, size_t)> handler) = 0;
2727
virtual void read_some(
28-
::asio::mutable_buffers_1 const &read_buffer,
29-
std::function<void(std::error_code const &, size_t)> handler) = 0;
28+
boost::asio::mutable_buffers_1 const &read_buffer,
29+
std::function<void(boost::system::error_code const &, size_t)> handler) = 0;
3030
virtual void disconnect() = 0;
3131
virtual ~connection_delegate() = default;
3232
};

boost/network/protocol/http/client/connection/connection_delegate_factory.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct connection_delegate_factory {
3434
// This is the factory method that actually returns the delegate instance.
3535
// TODO(dberris): Support passing in proxy settings when crafting connections.
3636
static connection_delegate_ptr new_connection_delegate(
37-
::asio::io_service& service, bool https, bool always_verify_peer,
37+
boost::asio::io_service& service, bool https, bool always_verify_peer,
3838
optional<string_type> certificate_filename,
3939
optional<string_type> verify_path, optional<string_type> certificate_file,
4040
optional<string_type> private_key_file, optional<string_type> ciphers,

boost/network/protocol/http/client/connection/normal_delegate.hpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
#include <memory>
1111
#include <cstdint>
1212
#include <functional>
13-
#include <asio/io_service.hpp>
14-
#include <asio/ip/tcp.hpp>
15-
#include <asio/placeholders.hpp>
16-
#include <asio/streambuf.hpp>
13+
#include <boost/asio/io_service.hpp>
14+
#include <boost/asio/ip/tcp.hpp>
15+
#include <boost/asio/placeholders.hpp>
16+
#include <boost/asio/streambuf.hpp>
1717
#include <boost/network/protocol/http/client/connection/connection_delegate.hpp>
1818

1919
namespace boost {
@@ -22,16 +22,16 @@ namespace http {
2222
namespace impl {
2323

2424
struct normal_delegate : connection_delegate {
25-
explicit normal_delegate(::asio::io_service &service);
25+
explicit normal_delegate(boost::asio::io_service &service);
2626

27-
void connect(::asio::ip::tcp::endpoint &endpoint, std::string host,
27+
void connect(boost::asio::ip::tcp::endpoint &endpoint, std::string host,
2828
std::uint16_t source_port,
29-
std::function<void(std::error_code const &)> handler) override;
30-
void write(::asio::streambuf &command_streambuf,
31-
std::function<void(std::error_code const &, size_t)> handler)
29+
std::function<void(boost::system::error_code const &)> handler) override;
30+
void write(boost::asio::streambuf &command_streambuf,
31+
std::function<void(boost::system::error_code const &, size_t)> handler)
3232
override;
33-
void read_some(::asio::mutable_buffers_1 const &read_buffer,
34-
std::function<void(std::error_code const &, size_t)> handler)
33+
void read_some(boost::asio::mutable_buffers_1 const &read_buffer,
34+
std::function<void(boost::system::error_code const &, size_t)> handler)
3535
override;
3636
void disconnect() override;
3737
~normal_delegate() override = default;
@@ -40,8 +40,8 @@ struct normal_delegate : connection_delegate {
4040
normal_delegate &operator=(normal_delegate) = delete;
4141

4242
private:
43-
::asio::io_service &service_;
44-
std::unique_ptr<::asio::ip::tcp::socket> socket_;
43+
boost::asio::io_service &service_;
44+
std::unique_ptr<boost::asio::ip::tcp::socket> socket_;
4545
};
4646

4747
} // namespace impl

boost/network/protocol/http/client/connection/normal_delegate.ipp

+16-16
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,46 @@
99

1010
#include <cstdint>
1111
#include <functional>
12-
#include <asio/ip/tcp.hpp>
13-
#include <asio/streambuf.hpp>
14-
#include <asio/write.hpp>
15-
#include <asio/buffer.hpp>
12+
#include <boost/asio/ip/tcp.hpp>
13+
#include <boost/asio/streambuf.hpp>
14+
#include <boost/asio/write.hpp>
15+
#include <boost/asio/buffer.hpp>
1616
#include <boost/network/protocol/http/client/connection/normal_delegate.hpp>
1717

1818
boost::network::http::impl::normal_delegate::normal_delegate(
19-
::asio::io_service &service)
19+
boost::asio::io_service &service)
2020
: service_(service) {}
2121

2222
void boost::network::http::impl::normal_delegate::connect(
23-
::asio::ip::tcp::endpoint &endpoint, std::string host,
23+
boost::asio::ip::tcp::endpoint &endpoint, std::string host,
2424
std::uint16_t source_port,
25-
std::function<void(std::error_code const &)> handler) {
25+
std::function<void(boost::system::error_code const &)> handler) {
2626

2727
// TODO(dberris): review parameter necessity.
2828
(void)host;
2929

30-
socket_.reset(new ::asio::ip::tcp::socket(
30+
socket_.reset(new boost::asio::ip::tcp::socket(
3131
service_,
32-
::asio::ip::tcp::endpoint(::asio::ip::address(), source_port)));
32+
boost::asio::ip::tcp::endpoint(boost::asio::ip::address(), source_port)));
3333
socket_->async_connect(endpoint, handler);
3434
}
3535

3636
void boost::network::http::impl::normal_delegate::write(
37-
::asio::streambuf &command_streambuf,
38-
std::function<void(std::error_code const &, size_t)> handler) {
39-
::asio::async_write(*socket_, command_streambuf, handler);
37+
boost::asio::streambuf &command_streambuf,
38+
std::function<void(boost::system::error_code const &, size_t)> handler) {
39+
boost::asio::async_write(*socket_, command_streambuf, handler);
4040
}
4141

4242
void boost::network::http::impl::normal_delegate::read_some(
43-
::asio::mutable_buffers_1 const &read_buffer,
44-
std::function<void(std::error_code const &, size_t)> handler) {
43+
boost::asio::mutable_buffers_1 const &read_buffer,
44+
std::function<void(boost::system::error_code const &, size_t)> handler) {
4545
socket_->async_read_some(read_buffer, handler);
4646
}
4747

4848
void boost::network::http::impl::normal_delegate::disconnect() {
4949
if (socket_.get() && socket_->is_open()) {
50-
std::error_code ignored;
51-
socket_->shutdown(::asio::ip::tcp::socket::shutdown_both, ignored);
50+
boost::system::error_code ignored;
51+
socket_->shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored);
5252
if (!ignored) {
5353
socket_->close(ignored);
5454
}

boost/network/protocol/http/client/connection/ssl_delegate.hpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include <memory>
1111
#include <cstdint>
1212
#include <functional>
13-
#include <asio/io_service.hpp>
14-
#include <asio/ssl.hpp>
13+
#include <boost/asio/io_service.hpp>
14+
#include <boost/asio/ssl.hpp>
1515
#include <boost/network/protocol/http/client/connection/connection_delegate.hpp>
1616
#include <boost/network/support/is_default_string.hpp>
1717
#include <boost/network/support/is_default_wstring.hpp>
@@ -24,45 +24,45 @@ namespace impl {
2424

2525
struct ssl_delegate : public connection_delegate,
2626
public std::enable_shared_from_this<ssl_delegate> {
27-
ssl_delegate(::asio::io_service &service, bool always_verify_peer,
27+
ssl_delegate(boost::asio::io_service &service, bool always_verify_peer,
2828
optional<std::string> certificate_filename,
2929
optional<std::string> verify_path,
3030
optional<std::string> certificate_file,
3131
optional<std::string> private_key_file,
3232
optional<std::string> ciphers,
3333
optional<std::string> sni_hostname, long ssl_options);
3434

35-
void connect(::asio::ip::tcp::endpoint &endpoint, std::string host,
35+
void connect(boost::asio::ip::tcp::endpoint &endpoint, std::string host,
3636
std::uint16_t source_port,
37-
std::function<void(std::error_code const &)> handler) override;
37+
std::function<void(boost::system::error_code const &)> handler) override;
3838
void write(
39-
::asio::streambuf &command_streambuf,
40-
std::function<void(std::error_code const &, size_t)> handler) override;
39+
boost::asio::streambuf &command_streambuf,
40+
std::function<void(boost::system::error_code const &, size_t)> handler) override;
4141
void read_some(
42-
::asio::mutable_buffers_1 const &read_buffer,
43-
std::function<void(std::error_code const &, size_t)> handler) override;
42+
boost::asio::mutable_buffers_1 const &read_buffer,
43+
std::function<void(boost::system::error_code const &, size_t)> handler) override;
4444
void disconnect() override;
4545
~ssl_delegate() override;
4646

4747
private:
48-
::asio::io_service &service_;
48+
boost::asio::io_service &service_;
4949
optional<std::string> certificate_filename_;
5050
optional<std::string> verify_path_;
5151
optional<std::string> certificate_file_;
5252
optional<std::string> private_key_file_;
5353
optional<std::string> ciphers_;
5454
optional<std::string> sni_hostname_;
5555
long ssl_options_;
56-
std::unique_ptr<::asio::ssl::context> context_;
57-
std::unique_ptr<::asio::ip::tcp::socket> tcp_socket_;
58-
std::unique_ptr<::asio::ssl::stream<::asio::ip::tcp::socket &> > socket_;
56+
std::unique_ptr<boost::asio::ssl::context> context_;
57+
std::unique_ptr<boost::asio::ip::tcp::socket> tcp_socket_;
58+
std::unique_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket &> > socket_;
5959
bool always_verify_peer_;
6060

6161
ssl_delegate(ssl_delegate const &); // = delete
6262
ssl_delegate &operator=(ssl_delegate); // = delete
6363

64-
void handle_connected(std::error_code const &ec,
65-
std::function<void(std::error_code const &)> handler);
64+
void handle_connected(boost::system::error_code const &ec,
65+
std::function<void(boost::system::error_code const &)> handler);
6666
};
6767

6868
} // namespace impl

0 commit comments

Comments
 (0)