replace boost::tuple by std::tuple
This commit is contained in:
parent
cf21074f10
commit
69b3457e83
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
Copyright (c) 2013, Project OSRM, Dennis Luxen, others
|
Copyright (c) 2015, Project OSRM, Dennis Luxen, others
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
@ -52,8 +52,7 @@ void Connection::start()
|
|||||||
{
|
{
|
||||||
TCP_socket.async_read_some(
|
TCP_socket.async_read_some(
|
||||||
boost::asio::buffer(incoming_data_buffer),
|
boost::asio::buffer(incoming_data_buffer),
|
||||||
strand.wrap(boost::bind(&Connection::handle_read,
|
strand.wrap(boost::bind(&Connection::handle_read, this->shared_from_this(),
|
||||||
this->shared_from_this(),
|
|
||||||
boost::asio::placeholders::error,
|
boost::asio::placeholders::error,
|
||||||
boost::asio::placeholders::bytes_transferred)));
|
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
|
// no error detected, let's parse the request
|
||||||
CompressionType compression_type(noCompression);
|
CompressionType compression_type(noCompression);
|
||||||
boost::tribool result;
|
boost::tribool result;
|
||||||
boost::tie(result, boost::tuples::ignore) =
|
std::tie(result, std::ignore) =
|
||||||
RequestParser().Parse(request,
|
RequestParser().Parse(request, incoming_data_buffer.data(),
|
||||||
incoming_data_buffer.data(),
|
incoming_data_buffer.data() + bytes_transferred, compression_type);
|
||||||
incoming_data_buffer.data() + bytes_transferred,
|
|
||||||
compression_type);
|
|
||||||
|
|
||||||
// the request has been parsed
|
// the request has been parsed
|
||||||
if (result)
|
if (result)
|
||||||
@ -110,29 +107,26 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// write result to stream
|
// write result to stream
|
||||||
boost::asio::async_write(TCP_socket,
|
boost::asio::async_write(
|
||||||
output_buffer,
|
TCP_socket, output_buffer,
|
||||||
strand.wrap(boost::bind(&Connection::handle_write,
|
strand.wrap(boost::bind(&Connection::handle_write, this->shared_from_this(),
|
||||||
this->shared_from_this(),
|
boost::asio::placeholders::error)));
|
||||||
boost::asio::placeholders::error)));
|
|
||||||
}
|
}
|
||||||
else if (!result)
|
else if (!result)
|
||||||
{ // request is not parseable
|
{ // request is not parseable
|
||||||
reply = Reply::StockReply(Reply::badRequest);
|
reply = Reply::StockReply(Reply::badRequest);
|
||||||
|
|
||||||
boost::asio::async_write(TCP_socket,
|
boost::asio::async_write(
|
||||||
reply.ToBuffers(),
|
TCP_socket, reply.ToBuffers(),
|
||||||
strand.wrap(boost::bind(&Connection::handle_write,
|
strand.wrap(boost::bind(&Connection::handle_write, this->shared_from_this(),
|
||||||
this->shared_from_this(),
|
boost::asio::placeholders::error)));
|
||||||
boost::asio::placeholders::error)));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// we don't have a result yet, so continue reading
|
// we don't have a result yet, so continue reading
|
||||||
TCP_socket.async_read_some(
|
TCP_socket.async_read_some(
|
||||||
boost::asio::buffer(incoming_data_buffer),
|
boost::asio::buffer(incoming_data_buffer),
|
||||||
strand.wrap(boost::bind(&Connection::handle_read,
|
strand.wrap(boost::bind(&Connection::handle_read, this->shared_from_this(),
|
||||||
this->shared_from_this(),
|
|
||||||
boost::asio::placeholders::error,
|
boost::asio::placeholders::error,
|
||||||
boost::asio::placeholders::bytes_transferred)));
|
boost::asio::placeholders::bytes_transferred)));
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ RequestParser::RequestParser() : state_(method_start), header({"", ""}) {}
|
|||||||
|
|
||||||
void RequestParser::Reset() { state_ = method_start; }
|
void RequestParser::Reset() { state_ = method_start; }
|
||||||
|
|
||||||
boost::tuple<boost::tribool, char *>
|
std::tuple<boost::tribool, char *>
|
||||||
RequestParser::Parse(Request &req, char *begin, char *end, http::CompressionType &compression_type)
|
RequestParser::Parse(Request &req, char *begin, char *end, http::CompressionType &compression_type)
|
||||||
{
|
{
|
||||||
while (begin != end)
|
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);
|
boost::tribool result = consume(req, *begin++, compression_type);
|
||||||
if (result || !result)
|
if (result || !result)
|
||||||
{
|
{
|
||||||
return boost::make_tuple(result, begin);
|
return std::make_tuple(result, begin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boost::tribool result = boost::indeterminate;
|
boost::tribool result = boost::indeterminate;
|
||||||
return boost::make_tuple(result, begin);
|
return std::make_tuple(result, begin);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::tribool
|
boost::tribool
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
Copyright (c) 2013, Project OSRM, Dennis Luxen, others
|
Copyright (c) 2015, Project OSRM, Dennis Luxen, others
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification,
|
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 "Http/Header.h"
|
||||||
|
|
||||||
#include <boost/logic/tribool.hpp>
|
#include <boost/logic/tribool.hpp>
|
||||||
#include <boost/tuple/tuple.hpp>
|
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
@ -45,7 +46,7 @@ class RequestParser
|
|||||||
RequestParser();
|
RequestParser();
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
||||||
boost::tuple<boost::tribool, char *>
|
std::tuple<boost::tribool, char *>
|
||||||
Parse(Request &req, char *begin, char *end, CompressionType &compression_type);
|
Parse(Request &req, char *begin, char *end, CompressionType &compression_type);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -60,27 +61,29 @@ class RequestParser
|
|||||||
inline bool isDigit(int c);
|
inline bool isDigit(int c);
|
||||||
|
|
||||||
enum state
|
enum state
|
||||||
{ method_start,
|
{
|
||||||
method,
|
method_start,
|
||||||
uri_start,
|
method,
|
||||||
uri,
|
uri_start,
|
||||||
http_version_h,
|
uri,
|
||||||
http_version_t_1,
|
http_version_h,
|
||||||
http_version_t_2,
|
http_version_t_1,
|
||||||
http_version_p,
|
http_version_t_2,
|
||||||
http_version_slash,
|
http_version_p,
|
||||||
http_version_major_start,
|
http_version_slash,
|
||||||
http_version_major,
|
http_version_major_start,
|
||||||
http_version_minor_start,
|
http_version_major,
|
||||||
http_version_minor,
|
http_version_minor_start,
|
||||||
expecting_newline_1,
|
http_version_minor,
|
||||||
header_line_start,
|
expecting_newline_1,
|
||||||
header_lws,
|
header_line_start,
|
||||||
header_name,
|
header_lws,
|
||||||
space_before_header_value,
|
header_name,
|
||||||
header_value,
|
space_before_header_value,
|
||||||
expecting_newline_2,
|
header_value,
|
||||||
expecting_newline_3 } state_;
|
expecting_newline_2,
|
||||||
|
expecting_newline_3
|
||||||
|
} state_;
|
||||||
|
|
||||||
Header header;
|
Header header;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user