From 910b75fc265032512f9495046750a58cb9a59fa2 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 12 Apr 2013 23:07:23 +0000 Subject: [PATCH] Combined overloaded definitions of fp2str and int2str --- include/cantera/base/stringUtils.h | 21 ++------------------- src/base/stringUtils.cpp | 22 ---------------------- 2 files changed, 2 insertions(+), 41 deletions(-) diff --git a/include/cantera/base/stringUtils.h b/include/cantera/base/stringUtils.h index 514353b58..9cfd09d0c 100644 --- a/include/cantera/base/stringUtils.h +++ b/include/cantera/base/stringUtils.h @@ -19,34 +19,17 @@ class ThermoPhase; //! Convert a double into a c++ string /*! - * This routine doesn't assume a formatting. You must supply the formatting - * * @param x double to be converted * @param fmt Format to be used (printf style) */ -std::string fp2str(const double x, const std::string& fmt); - -//! Convert a double into a c++ string -/*! - * The default format to use is equivalent to the default - * format used by printf's "`%g`" formatting. - * - * @param x double to be converted - */ -std::string fp2str(const double x); +std::string fp2str(const double x, const std::string& fmt="%g"); //! Convert an int to a string using a format converter /*! * @param n int to be converted * @param fmt format converter for an int int the printf command */ -std::string int2str(const int n, const std::string& fmt); - -//! Convert an int to a string -/*! - * @param n int to be converted - */ -std::string int2str(const int n); +std::string int2str(const int n, const std::string& fmt="%d"); //! Convert an unsigned integer to a string /*! diff --git a/src/base/stringUtils.cpp b/src/base/stringUtils.cpp index f8bbd55c1..726165f22 100644 --- a/src/base/stringUtils.cpp +++ b/src/base/stringUtils.cpp @@ -41,17 +41,6 @@ std::string fp2str(const double x, const std::string& fmt) return std::string(" "); } -std::string fp2str(const double x) -{ - char buf[64]; - int n = SNPRINTF(buf, 64, "%g" , x); - if (n > 0) { - buf[29] = '\0'; - return std::string(buf); - } - return std::string(" "); -} - std::string int2str(const int n, const std::string& fmt) { char buf[30]; @@ -63,17 +52,6 @@ std::string int2str(const int n, const std::string& fmt) return std::string(" "); } -std::string int2str(const int n) -{ - char buf[30]; - int m = SNPRINTF(buf, 30, "%d", n); - if (m > 0) { - buf[29] = '\0'; - return std::string(buf); - } - return std::string(" "); -} - std::string int2str(const size_t n) { std::stringstream ss;