use C++11 type traits to reduce code size in integral->string conversion
This commit is contained in:
@@ -38,7 +38,7 @@ void Reply::SetSize(const unsigned size)
|
||||
{
|
||||
if ("Content-Length" == h.name)
|
||||
{
|
||||
h.value = UintToString(size);
|
||||
h.value = IntegralToString(size);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,8 +87,7 @@ Reply Reply::StockReply(Reply::status_type status)
|
||||
const std::string status_string = reply.ToString(status);
|
||||
reply.content.insert(reply.content.end(), status_string.begin(), status_string.end());
|
||||
reply.headers.emplace_back("Access-Control-Allow-Origin", "*");
|
||||
reply.headers.emplace_back("Content-Length",
|
||||
UintToString(static_cast<unsigned>(reply.content.size())));
|
||||
reply.headers.emplace_back("Content-Length", IntegralToString(reply.content.size()));
|
||||
reply.headers.emplace_back("Content-Type", "text/html");
|
||||
return reply;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ void RequestHandler::handle_request(const http::Request &req, http::Reply &reply
|
||||
JSON::Object json_result;
|
||||
json_result.values["status"] = 400;
|
||||
std::string message = "Query string malformed close to position ";
|
||||
message += UintToString(position);
|
||||
message += IntegralToString(position);
|
||||
json_result.values["status_message"] = message;
|
||||
JSON::render(reply.content, json_result);
|
||||
return;
|
||||
@@ -113,8 +113,7 @@ void RequestHandler::handle_request(const http::Request &req, http::Reply &reply
|
||||
}
|
||||
|
||||
// set headers
|
||||
reply.headers.emplace_back("Content-Length",
|
||||
UintToString(static_cast<unsigned>(reply.content.size())));
|
||||
reply.headers.emplace_back("Content-Length", IntegralToString(reply.content.size()));
|
||||
if ("gpx" == route_parameters.output_format)
|
||||
{ // gpx file
|
||||
reply.headers.emplace_back("Content-Type", "application/gpx+xml; charset=UTF-8");
|
||||
|
||||
+1
-4
@@ -62,7 +62,7 @@ class Server
|
||||
: thread_pool_size(thread_pool_size), acceptor(io_service),
|
||||
new_connection(new http::Connection(io_service, request_handler)), request_handler()
|
||||
{
|
||||
const std::string port_string = IntToString(port);
|
||||
const std::string port_string = IntegralToString(port);
|
||||
|
||||
boost::asio::ip::tcp::resolver resolver(io_service);
|
||||
boost::asio::ip::tcp::resolver::query query(address, port_string);
|
||||
@@ -77,9 +77,6 @@ class Server
|
||||
boost::bind(&Server::HandleAccept, this, boost::asio::placeholders::error));
|
||||
}
|
||||
|
||||
// Server() = delete;
|
||||
// Server(const Server &) = delete;
|
||||
|
||||
void Run()
|
||||
{
|
||||
std::vector<std::shared_ptr<std::thread>> threads;
|
||||
|
||||
Reference in New Issue
Block a user