00001 #include "StringProperty.h" 00002 #include "AbstractPropertyContainer.h" 00003 #include "Util.h" 00004 00005 namespace RenderTools { 00006 00007 StringProperty::StringProperty( const shared_ptr< string > & pointer ): 00008 AbstractProperty(), 00009 m_pointer( pointer ){ 00010 } 00011 00012 void StringProperty::onInitialize( void ){ 00013 00014 } 00015 00016 bool StringProperty::isString( void ) const { 00017 return( true ); 00018 } 00019 00020 bool StringProperty::setValue( const string toValue, int element ){ 00021 string value = toValue; 00022 if( toValue == "" ){ 00023 value = string( " " ); 00024 } 00025 00026 stringstream s( AbstractPropertyContainer::interpret( value ) ); 00027 string prevValue = getValue(); 00028 00029 if( value == " " ){ 00030 noskipws( s ); 00031 } 00032 else{ 00033 skipws( s ); 00034 } 00035 00036 s >> ( * m_pointer.get() ); 00037 00038 return( getValue() != prevValue ); 00039 } 00040 00041 const string StringProperty::getValue( int element ) const { 00042 stringstream s; 00043 s << ( * m_pointer.get() ) << string( " " ); 00044 return( trim( s.str() ) ); 00045 } 00046 00047 const void * StringProperty::getPointer( unsigned int offset ) const { 00048 return( ( void * ) & ( * m_pointer.get() )[ offset ] ); 00049 } 00050 00051 const string StringProperty::getTypeName( bool ofComponent ) const { 00052 if( ofComponent ){ 00053 return( "char" ); 00054 } 00055 else{ 00056 return( "string" ); 00057 } 00058 } 00059 00060 }; // namespace 00061