maybe workaround g++ 3.3 weirdness
This commit is contained in:
@@ -61,7 +61,7 @@ const RString &EnumToString( int iVal, int iMax, const char **szNameArray, auto_
|
||||
static auto_ptr<RString> as_##X##Name[NUM_##X+2]; \
|
||||
return EnumToString( x, NUM_##X, X##Names, as_##X##Name ); \
|
||||
} \
|
||||
template<> RString ToString<X>( const X &value ) { return X##ToString(value); }
|
||||
namespace StringConversion { template<> RString ToString<X>( const X &value ) { return X##ToString(value); } }
|
||||
#define XToString(X, CNT) XToString2(X)
|
||||
|
||||
#define XToLocalizedString(X) \
|
||||
@@ -89,7 +89,7 @@ const RString &EnumToString( int iVal, int iMax, const char **szNameArray, auto_
|
||||
return (X)i; \
|
||||
return (X)(i+1); /*invalid*/ \
|
||||
} \
|
||||
template<> bool FromString<X>( const RString &sValue, X &out ) { out = StringTo##X(sValue); return out != X##_Invalid; }
|
||||
namespace StringConversion { template<> bool FromString<X>( const RString &sValue, X &out ) { out = StringTo##X(sValue); return out != X##_Invalid; } }
|
||||
|
||||
// currently unused
|
||||
#define LuaDeclareType(X)
|
||||
|
||||
@@ -225,7 +225,7 @@ void Model::LoadMaterialsFromMilkshapeAscii( const RString &_sPath )
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
float fShininess;
|
||||
if( !FromString(sLine, fShininess) )
|
||||
if( !StringConversion::FromString(sLine, fShininess) )
|
||||
THROW;
|
||||
Material.fShininess = fShininess;
|
||||
|
||||
@@ -233,7 +233,7 @@ void Model::LoadMaterialsFromMilkshapeAscii( const RString &_sPath )
|
||||
if( f.GetLine( sLine ) <= 0 )
|
||||
THROW;
|
||||
float fTransparency;
|
||||
if( !FromString(sLine, fTransparency) )
|
||||
if( !StringConversion::FromString(sLine, fTransparency) )
|
||||
THROW;
|
||||
Material.fTransparency = fTransparency;
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ void PlayerOptions::FromString( const RString &sOptions, bool bWarnOnInvalid )
|
||||
vector<RString> matches;
|
||||
if( mult.Compare(sBit, matches) )
|
||||
{
|
||||
::FromString( matches[0], level );
|
||||
StringConversion::FromString( matches[0], level );
|
||||
SET_FLOAT( fScrollSpeed )
|
||||
SET_FLOAT( fTimeSpacing )
|
||||
m_fTimeSpacing = 0;
|
||||
|
||||
@@ -57,10 +57,10 @@ public:
|
||||
LoadDefault();
|
||||
}
|
||||
|
||||
RString ToString() const { return ::ToString<T>( m_currentValue ); }
|
||||
RString ToString() const { return StringConversion::ToString<T>( m_currentValue ); }
|
||||
void FromString( const RString &s )
|
||||
{
|
||||
if( !::FromString<T>(s, m_currentValue) )
|
||||
if( !StringConversion::FromString<T>(s, m_currentValue) )
|
||||
m_currentValue = m_defaultValue;
|
||||
if( m_pfnValidate )
|
||||
m_pfnValidate( m_currentValue );
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
void SetDefaultFromString( const RString &s )
|
||||
{
|
||||
T def = m_defaultValue;
|
||||
if( !::FromString<T>(s, m_defaultValue) )
|
||||
if( !StringConversion::FromString<T>(s, m_defaultValue) )
|
||||
m_defaultValue = def;
|
||||
}
|
||||
|
||||
|
||||
+54
-53
@@ -1883,65 +1883,66 @@ void CollapsePath( RString &sPath, bool bRemoveLeadingDot )
|
||||
sOut.swap( sPath );
|
||||
}
|
||||
|
||||
|
||||
template<> bool FromString<int>( const RString &sValue, int &out )
|
||||
namespace StringConversion
|
||||
{
|
||||
if( sscanf( sValue.c_str(), "%d", &out ) == 1 )
|
||||
return true;
|
||||
template<> bool FromString<int>( const RString &sValue, int &out )
|
||||
{
|
||||
if( sscanf( sValue.c_str(), "%d", &out ) == 1 )
|
||||
return true;
|
||||
|
||||
out = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
template<> bool FromString<unsigned>( const RString &sValue, unsigned &out )
|
||||
{
|
||||
if( sscanf( sValue.c_str(), "%u", &out ) == 1 )
|
||||
return true;
|
||||
|
||||
out = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
template<> bool FromString<float>( const RString &sValue, float &out )
|
||||
{
|
||||
const char *endptr = sValue.data() + sValue.size();
|
||||
out = strtof( sValue, (char **) &endptr );
|
||||
if( endptr != sValue.data() && isfinite( out ) )
|
||||
return true;
|
||||
out = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
template<> bool FromString<bool>( const RString &sValue, bool &out )
|
||||
{
|
||||
if( sValue.size() == 0 )
|
||||
out = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
out = (atoi(sValue) != 0);
|
||||
return true;
|
||||
template<> bool FromString<unsigned>( const RString &sValue, unsigned &out )
|
||||
{
|
||||
if( sscanf( sValue.c_str(), "%u", &out ) == 1 )
|
||||
return true;
|
||||
|
||||
out = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
template<> bool FromString<float>( const RString &sValue, float &out )
|
||||
{
|
||||
const char *endptr = sValue.data() + sValue.size();
|
||||
out = strtof( sValue, (char **) &endptr );
|
||||
if( endptr != sValue.data() && isfinite( out ) )
|
||||
return true;
|
||||
out = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
template<> bool FromString<bool>( const RString &sValue, bool &out )
|
||||
{
|
||||
if( sValue.size() == 0 )
|
||||
return false;
|
||||
|
||||
out = (atoi(sValue) != 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
template<> RString ToString<int>( const int &value )
|
||||
{
|
||||
return ssprintf( "%i", value );
|
||||
}
|
||||
|
||||
template<> RString ToString<unsigned>( const unsigned &value )
|
||||
{
|
||||
return ssprintf( "%u", value );
|
||||
}
|
||||
|
||||
template<> RString ToString<float>( const float &value )
|
||||
{
|
||||
return ssprintf( "%f", value );
|
||||
}
|
||||
|
||||
template<> RString ToString<bool>( const bool &value )
|
||||
{
|
||||
return ssprintf( "%i", value );
|
||||
}
|
||||
}
|
||||
|
||||
template<> RString ToString<int>( const int &value )
|
||||
{
|
||||
return ssprintf( "%i", value );
|
||||
}
|
||||
|
||||
template<> RString ToString<unsigned>( const unsigned &value )
|
||||
{
|
||||
return ssprintf( "%u", value );
|
||||
}
|
||||
|
||||
template<> RString ToString<float>( const float &value )
|
||||
{
|
||||
return ssprintf( "%f", value );
|
||||
}
|
||||
|
||||
template<> RString ToString<bool>( const bool &value )
|
||||
{
|
||||
return ssprintf( "%i", value );
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Helper function for reading/writing scores
|
||||
//
|
||||
|
||||
@@ -532,27 +532,17 @@ void FlushDirCache();
|
||||
void FixSlashesInPlace( RString &sPath );
|
||||
void CollapsePath( RString &sPath, bool bRemoveLeadingDot=false );
|
||||
|
||||
/* If the specified value is not a valid value for this type, and the type
|
||||
* has a corresponding "invalid" value, out will be assigned the invalid
|
||||
* value if bAllowInvalid is true, or a sensible default if false. (An example
|
||||
* "invalid" sentinels is NULL for pointers.) In either case, false will
|
||||
* be returned. */
|
||||
template<typename T>
|
||||
bool FromString( const RString &sValue, T &out );
|
||||
namespace StringConversion
|
||||
{
|
||||
template<typename T>
|
||||
bool FromString( const RString &sValue, T &out );
|
||||
|
||||
template<> bool FromString<int>( const RString &sValue, int &out );
|
||||
template<> bool FromString<unsigned>( const RString &sValue, unsigned &out );
|
||||
template<> bool FromString<float>( const RString &sValue, float &out );
|
||||
template<> bool FromString<bool>( const RString &sValue, bool &out );
|
||||
template<> inline bool FromString<RString>( const RString &sValue, RString &out ) { out = sValue; return true; }
|
||||
template<typename T>
|
||||
RString ToString( const T &value );
|
||||
|
||||
template<typename T>
|
||||
RString ToString( const T &value );
|
||||
template<> RString ToString<int>( const int &value );
|
||||
template<> RString ToString<unsigned>( const unsigned &value );
|
||||
template<> RString ToString<float>( const float &value );
|
||||
template<> RString ToString<bool>( const bool &value );
|
||||
template<> inline RString ToString<RString>( const RString &value ) { return value; }
|
||||
template<> inline bool FromString<RString>( const RString &sValue, RString &out ) { out = sValue; return true; }
|
||||
template<> inline RString ToString<RString>( const RString &value ) { return value; }
|
||||
}
|
||||
|
||||
// helper file functions used by Bookkeeper and ProfileManager
|
||||
class RageFileBasic;
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "SpecialFiles.h"
|
||||
#include "RageLog.h"
|
||||
|
||||
using namespace StringConversion;
|
||||
|
||||
static void GetPrefsDefaultModifiers( PlayerOptions &po, SongOptions &so )
|
||||
{
|
||||
po.FromString( PREFSMAN->m_sDefaultModifiers );
|
||||
|
||||
Reference in New Issue
Block a user