Browse Source

moved std::to_string to util.h from android

pull/520/head
orignal 8 years ago
parent
commit
a5be4c9d0e
  1. 8
      ClientContext.cpp
  2. 19
      HTTP.cpp
  3. 10
      HTTPServer.cpp
  4. 8
      I2PControl.cpp
  5. 9
      Reseed.cpp
  6. 8
      RouterContext.cpp
  7. 11
      util.h

8
ClientContext.cpp

@ -8,12 +8,6 @@ @@ -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 @@ -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>

19
HTTP.cpp

@ -10,13 +10,6 @@ @@ -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 { @@ -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 { @@ -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;

10
HTTPServer.cpp

@ -25,12 +25,6 @@ @@ -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 { @@ -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)

8
I2PControl.cpp

@ -25,12 +25,6 @@ @@ -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 @@ -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);
}

9
Reseed.cpp

@ -16,13 +16,6 @@ @@ -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 @@ -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);

8
RouterContext.cpp

@ -12,12 +12,6 @@ @@ -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 @@ -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

@ -7,6 +7,17 @@ @@ -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

Loading…
Cancel
Save