use ToString and FromString

on invalid value, default to default
This commit is contained in:
Glenn Maynard
2006-10-07 06:26:40 +00:00
parent d882f21348
commit 8d44405523
+6 -3
View File
@@ -60,10 +60,11 @@ public:
LoadDefault(); LoadDefault();
} }
RString ToString() const { return PrefToString( (const BasicType &) m_currentValue ); } RString ToString() const { return ::ToString( (const BasicType &) m_currentValue ); }
void FromString( const RString &s ) void FromString( const RString &s )
{ {
PrefFromString( s, (BasicType &)m_currentValue ); if( !::FromString(s, (BasicType &)m_currentValue) )
m_currentValue = m_defaultValue;
if( m_pfnValidate ) if( m_pfnValidate )
m_pfnValidate( m_currentValue ); m_pfnValidate( m_currentValue );
} }
@@ -84,7 +85,9 @@ public:
} }
void SetDefaultFromString( const RString &s ) void SetDefaultFromString( const RString &s )
{ {
PrefFromString( s, (BasicType &)m_defaultValue ); T def = m_defaultValue;
if( !::FromString(s, (BasicType &)m_defaultValue) )
m_defaultValue = def;
} }
const T &Get() const const T &Get() const