Combined overloaded definitions of fp2str and int2str
This commit is contained in:
parent
5967e952e6
commit
910b75fc26
2 changed files with 2 additions and 41 deletions
|
|
@ -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
|
||||
/*!
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue