From 58ddc135eb59ca5f0db07b984439bf9dcea7d828 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Tue, 15 Apr 2008 15:28:53 +0000 Subject: [PATCH] Switched the implementation of intValue() and fpValue() to the .cpp file from the .h file. This also fixes a compile problem a user had involving a header file (that wasn't in the .h file but was in the .cpp file). --- Cantera/src/base/stringUtils.cpp | 7 +++ Cantera/src/base/stringUtils.h | 79 +++++++++++++++++++------------- 2 files changed, 54 insertions(+), 32 deletions(-) diff --git a/Cantera/src/base/stringUtils.cpp b/Cantera/src/base/stringUtils.cpp index 76f92e841..a19ace6fa 100755 --- a/Cantera/src/base/stringUtils.cpp +++ b/Cantera/src/base/stringUtils.cpp @@ -227,7 +227,14 @@ namespace Cantera { return file; } + + int intValue(std::string val) { + return std::atoi(stripws(val).c_str()); + } + doublereal fpValue(std::string val) { + return std::atof(stripws(val).c_str()); + } /** * Generate a logfile name based on an input file name */ diff --git a/Cantera/src/base/stringUtils.h b/Cantera/src/base/stringUtils.h index dec5455e4..21a50b51c 100755 --- a/Cantera/src/base/stringUtils.h +++ b/Cantera/src/base/stringUtils.h @@ -14,43 +14,58 @@ namespace Cantera { - class Phase; - class ThermoPhase; + class Phase; + class ThermoPhase; - std::string fp2str(double x, std::string fmt); + std::string fp2str(double x, 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(double x); - std::string int2str(int n, std::string fmt); - std::string int2str(int n); - std::string stripws(std::string s); - std::string stripnonprint(std::string s); - std::string lowercase(std::string s); - void parseCompString(const std::string ss, compositionMap& x); - void split(const std::string ss, std::vector& w); - int fillArrayFromString(const std::string& str, doublereal* a, char delim = ' '); - std::string report(const ThermoPhase& th, bool show_thermo = true); - std::string formatCompList(const Phase& mix, int xyc); - std::string logfileName(const std::string& infile); - std::string getFileName(const std::string& path); + //! 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(double x); + std::string int2str(int n, std::string fmt); + std::string int2str(int n); + std::string stripws(std::string s); + std::string stripnonprint(std::string s); + std::string lowercase(std::string s); + void parseCompString(const std::string ss, compositionMap& x); + void split(const std::string ss, std::vector& w); + int fillArrayFromString(const std::string& str, doublereal* a, char delim = ' '); + std::string report(const ThermoPhase& th, bool show_thermo = true); + std::string formatCompList(const Phase& mix, int xyc); + std::string logfileName(const std::string& infile); + std::string getFileName(const std::string& path); - inline int intValue(std::string val) { - return std::atoi(stripws(val).c_str()); - } + //! Translate a string into one integer value + /*! + * No error checking is done on the conversion. The c stdlib function + * atoi() is used. + * + * @param val String value of the integer + * + * @return Returns an integer + */ + int intValue(std::string val); - inline doublereal fpValue(std::string val) { - return std::atof(stripws(val).c_str()); - } - std::string wrapString(const std::string& s, int len=70); + //! Translate a string into one doublereal value + /*! + * No error checking is done on the conversion. The c stdlib function + * atof() is used. + * + * @param val String value of the double + * + * @return Returns a doublereal value + */ + doublereal fpValue(std::string val); - int stripLTWScstring(char str[]); - double atofCheck(const char *dptr); + std::string wrapString(const std::string& s, int len=70); + + int stripLTWScstring(char str[]); + double atofCheck(const char *dptr); }