Skip to content

Commit fbfb69a

Browse files
complete boost->std migration, make the library compile on linux/gcc4.7
1 parent e10bdf1 commit fbfb69a

File tree

3 files changed

+75
-67
lines changed

3 files changed

+75
-67
lines changed

include/network/protocol/http/client/connection/async_normal.ipp

Lines changed: 54 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,21 @@ struct http_async_connection_pimpl : std::enable_shared_from_this<http_async_con
6868
boost::uint16_t port_ = port(request);
6969
NETWORK_MESSAGE("port: " << port_);
7070
this->host_ = host(request);
71-
71+
72+
using namespace std::placeholders;
73+
7274
resolver_delegate_->resolve(
7375
this->host_,
7476
port_,
7577
request_strand_.wrap(
76-
boost::bind(
78+
std::bind(
7779
&this_type::handle_resolved,
78-
this_type::shared_from_this(),
80+
std::ref(*this_type::shared_from_this()),
7981
port_,
8082
get_body,
8183
callback,
82-
boost::asio::placeholders::error,
83-
boost::asio::placeholders::bytes_transferred)));
84+
std::placeholders::_1,
85+
std::placeholders::_2)));
8486
return response_;
8587
}
8688

@@ -141,20 +143,22 @@ struct http_async_connection_pimpl : std::enable_shared_from_this<http_async_con
141143
NETWORK_MESSAGE("trying connection to: "
142144
<< iter->endpoint().address() << ":" << port);
143145
boost::asio::ip::tcp::endpoint endpoint(iter->endpoint().address(), port);
144-
146+
147+
using namespace std::placeholders;
148+
145149
connection_delegate_->connect(
146150
endpoint,
147151
this->host_,
148152
request_strand_.wrap(
149-
boost::bind(
153+
std::bind(
150154
&this_type::handle_connected,
151-
this_type::shared_from_this(),
155+
this,
152156
port,
153157
get_body,
154158
callback,
155159
std::make_pair(++iter,
156160
resolver_iterator()),
157-
boost::asio::placeholders::error)));
161+
std::placeholders::_1)));
158162
} else {
159163
NETWORK_MESSAGE("error encountered while resolving.");
160164
set_errors(ec ? ec : boost::asio::error::host_not_found);
@@ -174,13 +178,13 @@ struct http_async_connection_pimpl : std::enable_shared_from_this<http_async_con
174178

175179
connection_delegate_->write(command_streambuf,
176180
request_strand_.wrap(
177-
boost::bind(
181+
std::bind(
178182
&this_type::handle_sent_request,
179-
this_type::shared_from_this(),
183+
this,
180184
get_body,
181185
callback,
182-
boost::asio::placeholders::error,
183-
boost::asio::placeholders::bytes_transferred)));
186+
std::placeholders::_1,
187+
std::placeholders::_2)));
184188
} else {
185189
NETWORK_MESSAGE("connection unsuccessful");
186190
if (!boost::empty(endpoint_range)) {
@@ -191,15 +195,15 @@ struct http_async_connection_pimpl : std::enable_shared_from_this<http_async_con
191195
connection_delegate_->connect(endpoint,
192196
this->host_,
193197
request_strand_.wrap(
194-
boost::bind(
198+
std::bind(
195199
&this_type::handle_connected,
196-
this_type::shared_from_this(),
200+
this,
197201
port,
198202
get_body,
199203
callback,
200204
std::make_pair(++iter,
201205
resolver_iterator()),
202-
boost::asio::placeholders::error)));
206+
std::placeholders::_1)));
203207
} else {
204208
set_errors(ec ? ec : boost::asio::error::host_not_found);
205209
}
@@ -222,11 +226,11 @@ struct http_async_connection_pimpl : std::enable_shared_from_this<http_async_con
222226
boost::asio::mutable_buffers_1(this->part.c_array(),
223227
this->part.size()),
224228
request_strand_.wrap(
225-
boost::bind(&this_type::handle_received_data,
229+
std::bind(&this_type::handle_received_data,
226230
this_type::shared_from_this(),
227231
version, get_body, callback,
228-
boost::asio::placeholders::error,
229-
boost::asio::placeholders::bytes_transferred)));
232+
std::placeholders::_1,
233+
std::placeholders::_2)));
230234
} else {
231235
NETWORK_MESSAGE("request sent unsuccessfully; setting errors");
232236
set_errors(ec);
@@ -258,36 +262,37 @@ struct http_async_connection_pimpl : std::enable_shared_from_this<http_async_con
258262
NETWORK_MESSAGE("parsing version...");
259263
parsed_ok =
260264
this->parse_version(request_strand_.wrap(
261-
boost::bind(
265+
std::bind(
262266
&this_type::handle_received_data,
263-
this_type::shared_from_this(),
267+
this,
264268
version, get_body, callback,
265-
boost::asio::placeholders::error,
266-
boost::asio::placeholders::bytes_transferred)),
269+
std::placeholders::_1,
270+
std::placeholders::_2)),
267271
bytes_transferred);
268272
if (!parsed_ok || indeterminate(parsed_ok)) return;
269273
case status:
270274
NETWORK_MESSAGE("parsing status...");
271275
parsed_ok =
272276
this->parse_status(request_strand_.wrap(
273-
boost::bind(
277+
std::bind(
274278
&this_type::handle_received_data,
275-
this_type::shared_from_this(),
279+
this,
276280
status, get_body, callback,
277-
boost::asio::placeholders::error,
278-
boost::asio::placeholders::bytes_transferred)),
281+
std::placeholders::_1,
282+
std::placeholders::_2)),
279283
bytes_transferred);
280284
if (!parsed_ok || indeterminate(parsed_ok)) return;
281285
case status_message:
282286
NETWORK_MESSAGE("parsing status message...");
283287
parsed_ok =
284288
this->parse_status_message(
285289
request_strand_.wrap(
286-
boost::bind(
290+
std::bind(
287291
&this_type::handle_received_data,
288-
this_type::shared_from_this(),
292+
this,
289293
status_message, get_body, callback,
290-
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred
294+
std::placeholders::_1,
295+
std::placeholders::_2
291296
)
292297
),
293298
bytes_transferred
@@ -302,11 +307,12 @@ struct http_async_connection_pimpl : std::enable_shared_from_this<http_async_con
302307
boost::fusion::tie(parsed_ok, remainder) =
303308
this->parse_headers(
304309
request_strand_.wrap(
305-
boost::bind(
310+
std::bind(
306311
&this_type::handle_received_data,
307312
this_type::shared_from_this(),
308313
headers, get_body, callback,
309-
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred
314+
std::placeholders::_1,
315+
std::placeholders::_2
310316
)
311317
),
312318
bytes_transferred
@@ -353,24 +359,25 @@ struct http_async_connection_pimpl : std::enable_shared_from_this<http_async_con
353359
boost::asio::mutable_buffers_1(this->part.c_array(),
354360
this->part.size()),
355361
request_strand_.wrap(
356-
boost::bind(&this_type::handle_received_data,
357-
this_type::shared_from_this(),
362+
std::bind(&this_type::handle_received_data,
363+
this,
358364
body,
359365
get_body,
360366
callback,
361-
boost::asio::placeholders::error,
362-
boost::asio::placeholders::bytes_transferred)));
367+
std::placeholders::_1,
368+
std::placeholders::_2)));
363369
} else {
364370
NETWORK_MESSAGE("no callback provided, appending to body...");
365371
// Here we handle the body data ourself and append to an
366372
// ever-growing string buffer.
367373
this->parse_body(
368374
request_strand_.wrap(
369-
boost::bind(
375+
std::bind(
370376
&this_type::handle_received_data,
371-
this_type::shared_from_this(),
377+
this,
372378
body, get_body, callback,
373-
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred
379+
std::placeholders::_1,
380+
std::placeholders::_2
374381
)
375382
),
376383
remainder);
@@ -428,14 +435,14 @@ struct http_async_connection_pimpl : std::enable_shared_from_this<http_async_con
428435
this->part.c_array(),
429436
this->part.size()),
430437
request_strand_.wrap(
431-
boost::bind(
438+
std::bind(
432439
&this_type::handle_received_data,
433-
this_type::shared_from_this(),
440+
this,
434441
body,
435442
get_body,
436443
callback,
437-
boost::asio::placeholders::error,
438-
boost::asio::placeholders::bytes_transferred)));
444+
std::placeholders::_1,
445+
std::placeholders::_2)));
439446
} else {
440447
NETWORK_MESSAGE("no callback provided, appending to body...");
441448
bool get_more = true;
@@ -453,14 +460,14 @@ struct http_async_connection_pimpl : std::enable_shared_from_this<http_async_con
453460
// that's still in the buffer.
454461
if (get_more) {
455462
this->parse_body(request_strand_.wrap(
456-
boost::bind(
463+
std::bind(
457464
&this_type::handle_received_data,
458-
this_type::shared_from_this(),
465+
this,
459466
body,
460467
get_body,
461468
callback,
462-
boost::asio::placeholders::error,
463-
boost::asio::placeholders::bytes_transferred)),
469+
std::placeholders::_1,
470+
std::placeholders::_2)),
464471
bytes_transferred);
465472
} else {
466473
std::string body_string;

include/network/protocol/http/server.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class async_server {
5757
~async_server();
5858

5959
typedef http::request request;
60-
typedef boost::shared_ptr<async_server_connection> connection_ptr;
60+
typedef std::shared_ptr<async_server_connection> connection_ptr;
6161
private:
6262
async_server_impl *pimpl_;
6363
async_server(async_server const &other); // = delete

include/network/protocol/http/server/connection/async.hpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,12 @@ namespace network { namespace http {
267267
socket().async_read_some(
268268
boost::asio::buffer(read_buffer_)
269269
, strand.wrap(
270-
boost::bind(
270+
std::bind(
271271
&async_server_connection::wrap_read_handler
272-
, async_server_connection::shared_from_this()
272+
, std::ref(*async_server_connection::shared_from_this())
273273
, callback
274-
, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)));
274+
, std::placeholders::_1
275+
, std::placeholders::_2)));
275276
}
276277

277278
boost::asio::ip::tcp::socket & socket() { return socket_; }
@@ -342,12 +343,12 @@ namespace network { namespace http {
342343
socket_.async_read_some(
343344
boost::asio::buffer(read_buffer_)
344345
, strand.wrap(
345-
boost::bind(
346+
std::bind(
346347
&async_server_connection::handle_read_data,
347-
async_server_connection::shared_from_this(),
348+
std::ref(*async_server_connection::shared_from_this()),
348349
state,
349-
boost::asio::placeholders::error,
350-
boost::asio::placeholders::bytes_transferred
350+
std::placeholders::_1,
351+
std::placeholders::_2
351352
)
352353
)
353354
);
@@ -486,11 +487,11 @@ namespace network { namespace http {
486487
socket()
487488
, boost::asio::buffer(bad_request, strlen(bad_request))
488489
, strand.wrap(
489-
boost::bind(
490+
std::bind(
490491
&async_server_connection::client_error_sent
491-
, async_server_connection::shared_from_this()
492-
, boost::asio::placeholders::error
493-
, boost::asio::placeholders::bytes_transferred)));
492+
, std::ref(*async_server_connection::shared_from_this())
493+
, std::placeholders::_1
494+
, std::placeholders::_2)));
494495
}
495496

496497
void client_error_sent(boost::system::error_code const & ec, std::size_t bytes_transferred) {
@@ -512,12 +513,12 @@ namespace network { namespace http {
512513
socket()
513514
, headers_buffer
514515
, strand.wrap(
515-
boost::bind(
516+
std::bind(
516517
&async_server_connection::handle_write_headers
517-
, async_server_connection::shared_from_this()
518+
, std::ref(*async_server_connection::shared_from_this())
518519
, callback
519-
, boost::asio::placeholders::error
520-
, boost::asio::placeholders::bytes_transferred)));
520+
, std::placeholders::_1
521+
, std::placeholders::_2)));
521522
}
522523

523524
void handle_write_headers(std::function<void()> callback, boost::system::error_code const & ec, std::size_t bytes_transferred) {
@@ -630,14 +631,14 @@ namespace network { namespace http {
630631
boost::asio::async_write(
631632
socket_
632633
,seq
633-
,boost::bind(
634+
,std::bind(
634635
&async_server_connection::handle_write
635-
,async_server_connection::shared_from_this()
636+
,std::ref(*async_server_connection::shared_from_this())
636637
,callback_function
637638
,temporaries
638639
,buffers
639-
,boost::asio::placeholders::error
640-
,boost::asio::placeholders::bytes_transferred)
640+
,std::placeholders::_1
641+
,std::placeholders::_2)
641642
);
642643
}
643644
};

0 commit comments

Comments
 (0)