From 76d19efe0c47d528697f819b0f85e93759d41364 Mon Sep 17 00:00:00 2001 From: badaix Date: Tue, 29 Dec 2015 13:30:29 +0100 Subject: [PATCH] to_string and stoul for Android c++11 --- client/clientConnection.cpp | 2 +- common/utils.h | 16 ++++++++++++++++ message/sampleFormat.cpp | 6 +++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/client/clientConnection.cpp b/client/clientConnection.cpp index 9b5b9cbb..23610b9e 100644 --- a/client/clientConnection.cpp +++ b/client/clientConnection.cpp @@ -57,7 +57,7 @@ void ClientConnection::socketRead(void* _to, size_t _bytes) void ClientConnection::start() { tcp::resolver resolver(io_service_); - tcp::resolver::query query(tcp::v4(), host_, std::to_string(port_), asio::ip::resolver_query_base::numeric_service); + tcp::resolver::query query(tcp::v4(), host_, utl::to_string(port_), asio::ip::resolver_query_base::numeric_service); auto iterator = resolver.resolve(query); logO << "Connecting\n"; socket_.reset(new tcp::socket(io_service_)); diff --git a/common/utils.h b/common/utils.h index e8e36265..5dc34a10 100644 --- a/common/utils.h +++ b/common/utils.h @@ -159,6 +159,22 @@ static std::string getMacAddress(int sock) } +namespace utl +{ + template + static std::string to_string(const T& t) + { + std::stringstream ss; + ss << t; + return ss.str(); + } + + static long stoul(const std::string& s) + { + return atol(s.c_str()); + } +} + #endif diff --git a/message/sampleFormat.cpp b/message/sampleFormat.cpp index acd90f3d..384f6a1d 100644 --- a/message/sampleFormat.cpp +++ b/message/sampleFormat.cpp @@ -61,9 +61,9 @@ void SampleFormat::setFormat(const std::string& format) strs = split(format, ':'); if (strs.size() == 3) setFormat( - std::stoul(strs[0]), - std::stoul(strs[1]), - std::stoul(strs[2])); + utl::stoul(strs[0]), + utl::stoul(strs[1]), + utl::stoul(strs[2])); }