update openddl-parser.

Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>
pull/502/head
Kim Kulling 2015-02-14 16:11:46 +01:00
parent bd1168af30
commit f5f0c9f7cf
2 changed files with 19 additions and 1 deletions

View File

@ -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 <openddlparser/Value.h>
#include <iostream>
#include <cassert>
@ -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 ];
}

View File

@ -26,6 +26,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <openddlparser/OpenDDLCommon.h>
#include <string>
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;