diff --git a/contrib/openddlparser/code/Value.cpp b/contrib/openddlparser/code/Value.cpp index 802e8dd61..5e88d6572 100644 --- a/contrib/openddlparser/code/Value.cpp +++ b/contrib/openddlparser/code/Value.cpp @@ -21,6 +21,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -----------------------------------------------------------------------------------------------*/ #include + #include #include @@ -109,6 +110,15 @@ double Value::getDouble() const { return v; } +void Value::setString( const std::string &str ) { + assert( ddl_string == m_type ); + ::memcpy( m_data, str.c_str(), str.size() ); + m_data[ str.size() ] = '\0'; +} +const char *Value::getString() const { + return (const char*) m_data; +} + void Value::dump() { switch( m_type ) { case ddl_none: @@ -223,7 +233,11 @@ Value *ValueAllocator::allocPrimData( Value::ValueType type, size_t len ) { } if( data->m_size ) { - data->m_size *= len; + size_t len1( len ); + if( Value::ddl_string == type ) { + len1++; + } + data->m_size *= len1; data->m_data = new unsigned char[ data->m_size ]; } diff --git a/contrib/openddlparser/include/openddlparser/Value.h b/contrib/openddlparser/include/openddlparser/Value.h index 0d719f994..48eb6e771 100644 --- a/contrib/openddlparser/include/openddlparser/Value.h +++ b/contrib/openddlparser/include/openddlparser/Value.h @@ -26,6 +26,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include +#include + BEGIN_ODDLPARSER_NS ///------------------------------------------------------------------------------------------------ @@ -73,6 +75,8 @@ public: float getFloat() const; void setDouble( double value ); double getDouble() const; + void setString( const std::string &str ); + const char *getString() const; void dump(); void setNext( Value *next ); Value *getNext() const;