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 @@
#include "Identity.h" #include "Identity.h"
#include "ClientContext.h" #include "ClientContext.h"
#ifdef ANDROID
# include "to_string.h"
#else
# define to_string(x) std::to_string(x)
#endif
namespace i2p namespace i2p
{ {
namespace client namespace client
@ -298,7 +292,7 @@ namespace client
template<typename Section, typename Type> template<typename Section, typename Type>
std::string ClientContext::GetI2CPOption (const Section& section, const std::string& name, const Type& value) const 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> template<typename Section>

19
HTTP.cpp

@ -10,13 +10,6 @@
#include <algorithm> #include <algorithm>
#include <ctime> #include <ctime>
#ifdef ANDROID
# include "to_string.h"
# include <errno.h>
#else
# define to_string(x) std::to_string(x)
#endif
namespace i2p { namespace i2p {
namespace http { namespace http {
const std::vector<std::string> HTTP_METHODS = { const std::vector<std::string> HTTP_METHODS = {
@ -187,11 +180,7 @@ namespace http {
out += user + "@"; out += user + "@";
} }
if (port) { if (port) {
#ifndef ANDROID out += host + ":" + std::to_string(port);
out += host + ":" + to_string(port);
#else
out += host + ":" + tostr::to_string(port);
#endif
} else { } else {
out += host; out += host;
} }
@ -349,11 +338,7 @@ namespace http {
if (status == "OK" && code != 200) if (status == "OK" && code != 200)
status = HTTPCodeToStatus(code); // update status = HTTPCodeToStatus(code); // update
if (body.length() > 0 && headers.count("Content-Length") == 0) if (body.length() > 0 && headers.count("Content-Length") == 0)
#ifndef ANDROID add_header("Content-Length", std::to_string(body.length()).c_str());
add_header("Content-Length", to_string(body.length()).c_str());
#else
add_header("Content-Length", tostr::to_string(body.length()).c_str());
#endif
/* build response */ /* build response */
std::stringstream ss; std::stringstream ss;
ss << version << " " << code << " " << status << CRLF; ss << version << " " << code << " " << status << CRLF;

10
HTTPServer.cpp

@ -25,12 +25,6 @@
// For image and info // For image and info
#include "version.h" #include "version.h"
#ifdef ANDROID
# include "to_string.h"
#else
# define to_string(x) std::to_string(x)
#endif
namespace i2p { namespace i2p {
namespace http { namespace http {
const char *itoopieFavicon = const char *itoopieFavicon =
@ -236,8 +230,8 @@ namespace http {
clientTunnelCount += i2p::tunnel::tunnels.CountInboundTunnels(); clientTunnelCount += i2p::tunnel::tunnels.CountInboundTunnels();
size_t transitTunnelCount = i2p::tunnel::tunnels.CountTransitTunnels(); size_t transitTunnelCount = i2p::tunnel::tunnels.CountTransitTunnels();
s << "<b>Client Tunnels:</b> " << to_string(clientTunnelCount) << " "; s << "<b>Client Tunnels:</b> " << std::to_string(clientTunnelCount) << " ";
s << "<b>Transit Tunnels:</b> " << to_string(transitTunnelCount) << "<br>\r\n"; s << "<b>Transit Tunnels:</b> " << std::to_string(transitTunnelCount) << "<br>\r\n";
} }
void ShowJumpServices (std::stringstream& s, const std::string& address) void ShowJumpServices (std::stringstream& s, const std::string& address)

8
I2PControl.cpp

@ -25,12 +25,6 @@
#include "version.h" #include "version.h"
#include "I2PControl.h" #include "I2PControl.h"
#ifdef ANDROID
# include "to_string.h"
#else
# define to_string(x) std::to_string(x)
#endif
namespace i2p namespace i2p
{ {
namespace client namespace client
@ -321,7 +315,7 @@ namespace client
} }
InsertParam (results, "API", api); InsertParam (results, "API", api);
results << ","; results << ",";
std::string token = to_string(i2p::util::GetSecondsSinceEpoch ()); std::string token = std::to_string(i2p::util::GetSecondsSinceEpoch ());
m_Tokens.insert (token); m_Tokens.insert (token);
InsertParam (results, "Token", token); InsertParam (results, "Token", token);
} }

9
Reseed.cpp

@ -16,13 +16,6 @@
#include "NetDb.h" #include "NetDb.h"
#include "util.h" #include "util.h"
#ifdef ANDROID
# include "to_string.h"
#else
# define to_string(x) std::to_string(x)
#endif
namespace i2p namespace i2p
{ {
namespace data namespace data
@ -379,7 +372,7 @@ namespace data
boost::asio::io_service service; boost::asio::io_service service;
boost::system::error_code ecode; boost::system::error_code ecode;
auto it = boost::asio::ip::tcp::resolver(service).resolve ( 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) if (!ecode)
{ {
boost::asio::ssl::context ctx(service, boost::asio::ssl::context::sslv23); boost::asio::ssl::context ctx(service, boost::asio::ssl::context::sslv23);

8
RouterContext.cpp

@ -12,12 +12,6 @@
#include "Family.h" #include "Family.h"
#include "RouterContext.h" #include "RouterContext.h"
#ifdef ANDROID
# include "to_string.h"
#else
# define to_string(x) std::to_string(x)
#endif
namespace i2p namespace i2p
{ {
RouterContext context; RouterContext context;
@ -62,7 +56,7 @@ namespace i2p
routerInfo.AddNTCPAddress (host.c_str(), port); routerInfo.AddNTCPAddress (host.c_str(), port);
routerInfo.SetCaps (i2p::data::RouterInfo::eReachable | routerInfo.SetCaps (i2p::data::RouterInfo::eReachable |
i2p::data::RouterInfo::eSSUTesting | i2p::data::RouterInfo::eSSUIntroducer); // LR, BC 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.SetProperty ("router.version", I2P_VERSION);
routerInfo.CreateBuffer (m_Keys); routerInfo.CreateBuffer (m_Keys);
m_RouterInfo.SetRouterIdentity (GetIdentity ()); m_RouterInfo.SetRouterIdentity (GetIdentity ());

11
util.h

@ -7,6 +7,17 @@
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <boost/lexical_cast.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 i2p
{ {
namespace util namespace util

Loading…
Cancel
Save