From dcfe2eb3bee0296aee3cc4453f4237c784251671 Mon Sep 17 00:00:00 2001 From: Caiwen Zhang Date: Fri, 19 Sep 2014 01:56:05 +0800 Subject: [PATCH] Replace to_string and stoi Part of C++11 features aren't supported by Android NDK, includes to_string and stoi. Replace them with snprintf and atoi. Change-Id: I6edda1856ab34c0e1dcc23daef0b105875a09189 --- examples/ocicuc/light_resource.hpp | 4 +++- include/OCApi.h | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/ocicuc/light_resource.hpp b/examples/ocicuc/light_resource.hpp index f4b2cd6..84cafba 100644 --- a/examples/ocicuc/light_resource.hpp +++ b/examples/ocicuc/light_resource.hpp @@ -57,7 +57,9 @@ class LightResource private: inline std::string make_URI(const unsigned int resource_number) { - std::string uri = std::string("/a/light") + "_" + std::to_string(resource_number); + char rn[16]; + snprintf(rn, 16, "%d", resource_number); + std::string uri = std::string("/a/light") + "_" + rn; m_rep.setUri(uri); return uri; } diff --git a/include/OCApi.h b/include/OCApi.h index 5b15f49..a3d869d 100644 --- a/include/OCApi.h +++ b/include/OCApi.h @@ -143,7 +143,9 @@ namespace OC // TODO different int sizes std::string operator() (const int i) const { - return std::to_string(i); + char i_str[16]; + snprintf(i_str, 16, "%d", i); + return i_str; } std::string operator() (const std::string& str) const @@ -193,7 +195,7 @@ namespace OC void operator() (int& i) const { - i = std::stoi(m_str); + i = atoi(m_str.c_str()); } void operator() (std::string& str) const -- 2.7.4