Standardize conversion processes.

Too many arguments for or against the many methods:
stick to one inside a common function.

This commit will force recompilation of many files.
This commit is contained in:
Jason Felds
2011-05-11 15:58:31 -04:00
parent 212a3b971f
commit da51e26d07
29 changed files with 125 additions and 104 deletions
+18 -3
View File
@@ -10,6 +10,7 @@
#include <numeric>
#include <ctime>
#include <sstream>
#include <map>
#include <sys/types.h>
#include <sys/stat.h>
@@ -193,8 +194,8 @@ float HHMMSSToSeconds( const RString &sHHMMSS )
arrayBits.insert(arrayBits.begin(), "0" ); // pad missing bits
float fSeconds = 0;
fSeconds += atoi( arrayBits[0] ) * 60 * 60;
fSeconds += atoi( arrayBits[1] ) * 60;
fSeconds += StringToInt( arrayBits[0] ) * 60 * 60;
fSeconds += StringToInt( arrayBits[1] ) * 60;
fSeconds += StringToFloat( arrayBits[2] );
return fSeconds;
@@ -1695,6 +1696,20 @@ void MakeLower( wchar_t *p, size_t iLen )
UnicodeUpperLower( p, iLen, g_LowerCase );
}
int StringToInt( const RString &sString )
{
int ret;
istringstream ( sString ) >> ret;
return ret;
}
RString IntToString( const int &iNum )
{
stringstream ss;
ss << iNum;
return ss.str();
}
float StringToFloat( const RString &sString )
{
float ret = strtof( sString, NULL );
@@ -2141,7 +2156,7 @@ namespace StringConversion
if( sValue.size() == 0 )
return false;
out = (atoi(sValue) != 0);
out = (StringToInt(sValue) != 0);
return true;
}