From a5be4c9d0ed0c2d0077ba64c48d14e94007497f7 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 14 Jun 2016 11:55:44 -0400 Subject: [PATCH] moved std::to_string to util.h from android --- ClientContext.cpp | 8 +------- HTTP.cpp | 19 ++----------------- HTTPServer.cpp | 10 ++-------- I2PControl.cpp | 8 +------- Reseed.cpp | 9 +-------- RouterContext.cpp | 8 +------- util.h | 11 +++++++++++ 7 files changed, 19 insertions(+), 54 deletions(-) diff --git a/ClientContext.cpp b/ClientContext.cpp index 3e69510c..d545ea78 100644 --- a/ClientContext.cpp +++ b/ClientContext.cpp @@ -8,12 +8,6 @@ #include "Identity.h" #include "ClientContext.h" -#ifdef ANDROID -# include "to_string.h" -#else -# define to_string(x) std::to_string(x) -#endif - namespace i2p { namespace client @@ -298,7 +292,7 @@ namespace client template std::string ClientContext::GetI2CPOption (const Section& section, const std::string& name, const Type& value) const { - return section.second.get (boost::property_tree::ptree::path_type (name, '/'), to_string (value)); + return section.second.get (boost::property_tree::ptree::path_type (name, '/'), std::to_string (value)); } template diff --git a/HTTP.cpp b/HTTP.cpp index dbb115af..fa7809a5 100644 --- a/HTTP.cpp +++ b/HTTP.cpp @@ -10,13 +10,6 @@ #include #include -#ifdef ANDROID -# include "to_string.h" -# include -#else -# define to_string(x) std::to_string(x) -#endif - namespace i2p { namespace http { const std::vector HTTP_METHODS = { @@ -187,11 +180,7 @@ namespace http { out += user + "@"; } if (port) { -#ifndef ANDROID - out += host + ":" + to_string(port); -#else - out += host + ":" + tostr::to_string(port); -#endif + out += host + ":" + std::to_string(port); } else { out += host; } @@ -349,11 +338,7 @@ namespace http { if (status == "OK" && code != 200) status = HTTPCodeToStatus(code); // update if (body.length() > 0 && headers.count("Content-Length") == 0) -#ifndef ANDROID - add_header("Content-Length", to_string(body.length()).c_str()); -#else - add_header("Content-Length", tostr::to_string(body.length()).c_str()); -#endif + add_header("Content-Length", std::to_string(body.length()).c_str()); /* build response */ std::stringstream ss; ss << version << " " << code << " " << status << CRLF; diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 583c02da..ff693313 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -25,12 +25,6 @@ // For image and info #include "version.h" -#ifdef ANDROID -# include "to_string.h" -#else -# define to_string(x) std::to_string(x) -#endif - namespace i2p { namespace http { const char *itoopieFavicon = @@ -236,8 +230,8 @@ namespace http { clientTunnelCount += i2p::tunnel::tunnels.CountInboundTunnels(); size_t transitTunnelCount = i2p::tunnel::tunnels.CountTransitTunnels(); - s << "Client Tunnels: " << to_string(clientTunnelCount) << " "; - s << "Transit Tunnels: " << to_string(transitTunnelCount) << "
\r\n"; + s << "Client Tunnels: " << std::to_string(clientTunnelCount) << " "; + s << "Transit Tunnels: " << std::to_string(transitTunnelCount) << "
\r\n"; } void ShowJumpServices (std::stringstream& s, const std::string& address) diff --git a/I2PControl.cpp b/I2PControl.cpp index bad25f37..9eebb389 100644 --- a/I2PControl.cpp +++ b/I2PControl.cpp @@ -25,12 +25,6 @@ #include "version.h" #include "I2PControl.h" -#ifdef ANDROID -# include "to_string.h" -#else -# define to_string(x) std::to_string(x) -#endif - namespace i2p { namespace client @@ -321,7 +315,7 @@ namespace client } InsertParam (results, "API", api); results << ","; - std::string token = to_string(i2p::util::GetSecondsSinceEpoch ()); + std::string token = std::to_string(i2p::util::GetSecondsSinceEpoch ()); m_Tokens.insert (token); InsertParam (results, "Token", token); } diff --git a/Reseed.cpp b/Reseed.cpp index b707429a..722d7eff 100644 --- a/Reseed.cpp +++ b/Reseed.cpp @@ -16,13 +16,6 @@ #include "NetDb.h" #include "util.h" - -#ifdef ANDROID -# include "to_string.h" -#else -# define to_string(x) std::to_string(x) -#endif - namespace i2p { namespace data @@ -379,7 +372,7 @@ namespace data boost::asio::io_service service; boost::system::error_code ecode; auto it = boost::asio::ip::tcp::resolver(service).resolve ( - boost::asio::ip::tcp::resolver::query (u.host_, to_string (u.port_)), ecode); + boost::asio::ip::tcp::resolver::query (u.host_, std::to_string (u.port_)), ecode); if (!ecode) { boost::asio::ssl::context ctx(service, boost::asio::ssl::context::sslv23); diff --git a/RouterContext.cpp b/RouterContext.cpp index 34d49553..768750bb 100644 --- a/RouterContext.cpp +++ b/RouterContext.cpp @@ -12,12 +12,6 @@ #include "Family.h" #include "RouterContext.h" -#ifdef ANDROID -# include "to_string.h" -#else -# define to_string(x) std::to_string(x) -#endif - namespace i2p { RouterContext context; @@ -62,7 +56,7 @@ namespace i2p routerInfo.AddNTCPAddress (host.c_str(), port); routerInfo.SetCaps (i2p::data::RouterInfo::eReachable | i2p::data::RouterInfo::eSSUTesting | i2p::data::RouterInfo::eSSUIntroducer); // LR, BC - routerInfo.SetProperty ("netId", to_string (I2PD_NET_ID)); + routerInfo.SetProperty ("netId", std::to_string (I2PD_NET_ID)); routerInfo.SetProperty ("router.version", I2P_VERSION); routerInfo.CreateBuffer (m_Keys); m_RouterInfo.SetRouterIdentity (GetIdentity ()); diff --git a/util.h b/util.h index f5dbc9aa..9f797158 100644 --- a/util.h +++ b/util.h @@ -7,6 +7,17 @@ #include #include +#ifdef ANDROID +namespace std +{ +template +std::string to_string(T value) +{ + return boost::lexical_cast(value); +} +} +#endif + namespace i2p { namespace util