From 70be9cd97f3cc9b175a9f5a94567798eb1b6eafe Mon Sep 17 00:00:00 2001 From: "Jerry (Xinyu Hou)" Date: Mon, 18 May 2015 11:27:54 -0700 Subject: [PATCH] Refactored intToString #4601 --- src/lib/base/String.cpp | 8 ++++++++ src/lib/base/String.h | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib/base/String.cpp b/src/lib/base/String.cpp index 5760e4d4..b873663e 100644 --- a/src/lib/base/String.cpp +++ b/src/lib/base/String.cpp @@ -207,6 +207,14 @@ removeChar(String& subject, const char c) subject.erase(std::remove(subject.begin(), subject.end(), c), subject.end()); } +String +intToString(size_t integer) +{ + std::stringstream ss; + ss << integer; + return ss.str(); +} + // // CaselessCmp // diff --git a/src/lib/base/String.h b/src/lib/base/String.h index 33e4f3d8..81d98a9b 100644 --- a/src/lib/base/String.h +++ b/src/lib/base/String.h @@ -84,10 +84,15 @@ void uppercase(String& subject); //! Remove all specific char in suject /*! -Remove all specific \c char in \c suject +Remove all specific \c c in \c suject */ void removeChar(String& subject, const char c); +//! Convert an integer to a string +/*! +Convert an \c integer to a string +*/ +String intToString(size_t integer); //! Case-insensitive comparisons /*!