moved std::to_string to util.h from android

This commit is contained in:
orignal 2016-06-14 11:55:44 -04:00
parent 07cc547bab
commit a5be4c9d0e
7 changed files with 19 additions and 54 deletions

View File

@ -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<typename Section, typename Type>
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<typename Section>

View File

@ -10,13 +10,6 @@
#include <algorithm>
#include <ctime>
#ifdef ANDROID
# include "to_string.h"
# include <errno.h>
#else
# define to_string(x) std::to_string(x)
#endif
namespace i2p {
namespace http {
const std::vector<std::string> 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;

View File

@ -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 << "<b>Client Tunnels:</b> " << to_string(clientTunnelCount) << " ";
s << "<b>Transit Tunnels:</b> " << to_string(transitTunnelCount) << "<br>\r\n";
s << "<b>Client Tunnels:</b> " << std::to_string(clientTunnelCount) << " ";
s << "<b>Transit Tunnels:</b> " << std::to_string(transitTunnelCount) << "<br>\r\n";
}
void ShowJumpServices (std::stringstream& s, const std::string& address)

View File

@ -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);
}

View File

@ -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);

View File

@ -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 ());

11
util.h
View File

@ -7,6 +7,17 @@
#include <boost/asio.hpp>
#include <boost/lexical_cast.hpp>
#ifdef ANDROID
namespace std
{
template <typename T>
std::string to_string(T value)
{
return boost::lexical_cast<std::string>(value);
}
}
#endif
namespace i2p
{
namespace util