From b344749c498c618bf8bdeaf69e2a5ca7f3198a9f Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Thu, 18 Sep 2014 10:32:32 -0700 Subject: [PATCH] Revert "Replace to_string and stoi" We have decided that sprintf is not stable/future proof enough, so we are going to revert this change (and the other one) and investigate what it would take to make android-only implementations of tostring and stoi This reverts commit dcfe2eb3bee0296aee3cc4453f4237c784251671. Change-Id: I82bb37e42aa5b6809bdf6a6522dac678ba74aac0 --- examples/ocicuc/light_resource.hpp | 4 +--- include/OCApi.h | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/examples/ocicuc/light_resource.hpp b/examples/ocicuc/light_resource.hpp index 84cafba..f4b2cd6 100644 --- a/examples/ocicuc/light_resource.hpp +++ b/examples/ocicuc/light_resource.hpp @@ -57,9 +57,7 @@ class LightResource private: inline std::string make_URI(const unsigned int resource_number) { - char rn[16]; - snprintf(rn, 16, "%d", resource_number); - std::string uri = std::string("/a/light") + "_" + rn; + std::string uri = std::string("/a/light") + "_" + std::to_string(resource_number); m_rep.setUri(uri); return uri; } diff --git a/include/OCApi.h b/include/OCApi.h index a3d869d..5b15f49 100644 --- a/include/OCApi.h +++ b/include/OCApi.h @@ -143,9 +143,7 @@ namespace OC // TODO different int sizes std::string operator() (const int i) const { - char i_str[16]; - snprintf(i_str, 16, "%d", i); - return i_str; + return std::to_string(i); } std::string operator() (const std::string& str) const @@ -195,7 +193,7 @@ namespace OC void operator() (int& i) const { - i = atoi(m_str.c_str()); + i = std::stoi(m_str); } void operator() (std::string& str) const -- 2.7.4