From 69b3457e83171fba5d58fd8aa95e70d51bbf039c Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Fri, 23 Jan 2015 17:14:12 +0100 Subject: [PATCH] replace boost::tuple by std::tuple --- Server/Connection.cpp | 34 +++++++++++---------------- Server/RequestParser.cpp | 6 ++--- Server/RequestParser.h | 51 +++++++++++++++++++++------------------- 3 files changed, 44 insertions(+), 47 deletions(-) diff --git a/Server/Connection.cpp b/Server/Connection.cpp index 82402a649..8777eb215 100644 --- a/Server/Connection.cpp +++ b/Server/Connection.cpp @@ -1,6 +1,6 @@ /* -Copyright (c) 2013, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -52,8 +52,7 @@ void Connection::start() { TCP_socket.async_read_some( boost::asio::buffer(incoming_data_buffer), - strand.wrap(boost::bind(&Connection::handle_read, - this->shared_from_this(), + strand.wrap(boost::bind(&Connection::handle_read, this->shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred))); } @@ -68,11 +67,9 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t // no error detected, let's parse the request CompressionType compression_type(noCompression); boost::tribool result; - boost::tie(result, boost::tuples::ignore) = - RequestParser().Parse(request, - incoming_data_buffer.data(), - incoming_data_buffer.data() + bytes_transferred, - compression_type); + std::tie(result, std::ignore) = + RequestParser().Parse(request, incoming_data_buffer.data(), + incoming_data_buffer.data() + bytes_transferred, compression_type); // the request has been parsed if (result) @@ -110,29 +107,26 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t break; } // write result to stream - boost::asio::async_write(TCP_socket, - output_buffer, - strand.wrap(boost::bind(&Connection::handle_write, - this->shared_from_this(), - boost::asio::placeholders::error))); + boost::asio::async_write( + TCP_socket, output_buffer, + strand.wrap(boost::bind(&Connection::handle_write, this->shared_from_this(), + boost::asio::placeholders::error))); } else if (!result) { // request is not parseable reply = Reply::StockReply(Reply::badRequest); - boost::asio::async_write(TCP_socket, - reply.ToBuffers(), - strand.wrap(boost::bind(&Connection::handle_write, - this->shared_from_this(), - boost::asio::placeholders::error))); + boost::asio::async_write( + TCP_socket, reply.ToBuffers(), + strand.wrap(boost::bind(&Connection::handle_write, this->shared_from_this(), + boost::asio::placeholders::error))); } else { // we don't have a result yet, so continue reading TCP_socket.async_read_some( boost::asio::buffer(incoming_data_buffer), - strand.wrap(boost::bind(&Connection::handle_read, - this->shared_from_this(), + strand.wrap(boost::bind(&Connection::handle_read, this->shared_from_this(), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred))); } diff --git a/Server/RequestParser.cpp b/Server/RequestParser.cpp index a599381f0..2c8358f8b 100644 --- a/Server/RequestParser.cpp +++ b/Server/RequestParser.cpp @@ -36,7 +36,7 @@ RequestParser::RequestParser() : state_(method_start), header({"", ""}) {} void RequestParser::Reset() { state_ = method_start; } -boost::tuple +std::tuple RequestParser::Parse(Request &req, char *begin, char *end, http::CompressionType &compression_type) { while (begin != end) @@ -44,11 +44,11 @@ RequestParser::Parse(Request &req, char *begin, char *end, http::CompressionType boost::tribool result = consume(req, *begin++, compression_type); if (result || !result) { - return boost::make_tuple(result, begin); + return std::make_tuple(result, begin); } } boost::tribool result = boost::indeterminate; - return boost::make_tuple(result, begin); + return std::make_tuple(result, begin); } boost::tribool diff --git a/Server/RequestParser.h b/Server/RequestParser.h index 07cdd86da..40c22954b 100644 --- a/Server/RequestParser.h +++ b/Server/RequestParser.h @@ -1,6 +1,6 @@ /* -Copyright (c) 2013, Project OSRM, Dennis Luxen, others +Copyright (c) 2015, Project OSRM, Dennis Luxen, others All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -32,7 +32,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "Http/Header.h" #include -#include + +#include namespace http { @@ -45,7 +46,7 @@ class RequestParser RequestParser(); void Reset(); - boost::tuple + std::tuple Parse(Request &req, char *begin, char *end, CompressionType &compression_type); private: @@ -60,27 +61,29 @@ class RequestParser inline bool isDigit(int c); enum state - { method_start, - method, - uri_start, - uri, - http_version_h, - http_version_t_1, - http_version_t_2, - http_version_p, - http_version_slash, - http_version_major_start, - http_version_major, - http_version_minor_start, - http_version_minor, - expecting_newline_1, - header_line_start, - header_lws, - header_name, - space_before_header_value, - header_value, - expecting_newline_2, - expecting_newline_3 } state_; + { + method_start, + method, + uri_start, + uri, + http_version_h, + http_version_t_1, + http_version_t_2, + http_version_p, + http_version_slash, + http_version_major_start, + http_version_major, + http_version_minor_start, + http_version_minor, + expecting_newline_1, + header_line_start, + header_lws, + header_name, + space_before_header_value, + header_value, + expecting_newline_2, + expecting_newline_3 + } state_; Header header; };