From 19ba6448f0d2e990617e3f7c2545ede9f8b5fe19 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Jun 2016 13:13:08 +0200 Subject: [PATCH] OpenDDLParser: latest greatest. --- contrib/openddlparser/code/OpenDDLCommon.cpp | 13 ++++++++++--- contrib/openddlparser/code/OpenDDLExport.cpp | 7 ++++++- contrib/openddlparser/code/OpenDDLParser.cpp | 18 +++++++++++++----- .../include/openddlparser/OpenDDLCommon.h | 2 ++ 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/contrib/openddlparser/code/OpenDDLCommon.cpp b/contrib/openddlparser/code/OpenDDLCommon.cpp index c0a2b0318..13a96f7a8 100644 --- a/contrib/openddlparser/code/OpenDDLCommon.cpp +++ b/contrib/openddlparser/code/OpenDDLCommon.cpp @@ -154,10 +154,17 @@ DataArrayList::~DataArrayList() { size_t DataArrayList::size() { size_t result( 0 ); - DataArrayList *n=m_next; - while( n!=ddl_nullptr ) { + if ( ddl_nullptr == m_next ) { + if ( m_dataList != ddl_nullptr ) { + result = 1; + } + return result; + } + + DataArrayList *n( m_next ); + while( ddl_nullptr != n ) { result++; - n=n->m_next; + n = n->m_next; } return result; } diff --git a/contrib/openddlparser/code/OpenDDLExport.cpp b/contrib/openddlparser/code/OpenDDLExport.cpp index 43e3bcb02..6f1c3449a 100644 --- a/contrib/openddlparser/code/OpenDDLExport.cpp +++ b/contrib/openddlparser/code/OpenDDLExport.cpp @@ -334,7 +334,7 @@ bool OpenDDLExport::writeValue( Value *val, std::string &statement ) { const int i = static_cast< int >( val->getInt64() ); stream << i; statement += stream.str(); - } + } break; case Value::ddl_unsigned_int8: { @@ -378,6 +378,11 @@ bool OpenDDLExport::writeValue( Value *val, std::string &statement ) { } break; case Value::ddl_double: + { + std::stringstream stream; + stream << val->getDouble(); + statement += stream.str(); + } break; case Value::ddl_string: { diff --git a/contrib/openddlparser/code/OpenDDLParser.cpp b/contrib/openddlparser/code/OpenDDLParser.cpp index 921f67aa4..6f471be36 100644 --- a/contrib/openddlparser/code/OpenDDLParser.cpp +++ b/contrib/openddlparser/code/OpenDDLParser.cpp @@ -948,15 +948,23 @@ char *OpenDDLParser::parseDataList( char *in, char *end, Value::ValueType type, return in; } -static DataArrayList *createDataArrayList( Value *currentValue, size_t numValues ) { - DataArrayList *dataList = new DataArrayList; +static DataArrayList *createDataArrayList( Value *currentValue, size_t numValues, + Reference *refs, size_t numRefs ) { + DataArrayList *dataList( new DataArrayList ); dataList->m_dataList = currentValue; dataList->m_numItems = numValues; + dataList->m_refs = refs; + dataList->m_numRefs = numRefs; return dataList; } -char *OpenDDLParser::parseDataArrayList( char *in, char *end,Value::ValueType type, DataArrayList **dataArrayList ) { +char *OpenDDLParser::parseDataArrayList( char *in, char *end,Value::ValueType type, + DataArrayList **dataArrayList ) { + if ( ddl_nullptr == dataArrayList ) { + return in; + } + *dataArrayList = ddl_nullptr; if( ddl_nullptr == in || in == end ) { return in; @@ -975,10 +983,10 @@ char *OpenDDLParser::parseDataArrayList( char *in, char *end,Value::ValueType ty in = parseDataList( in, end, type, ¤tValue, numValues, &refs, numRefs ); if( ddl_nullptr != currentValue || 0 != numRefs ) { if( ddl_nullptr == prev ) { - *dataArrayList = createDataArrayList( currentValue, numValues ); + *dataArrayList = createDataArrayList( currentValue, numValues, refs, numRefs ); prev = *dataArrayList; } else { - currentDataList = createDataArrayList( currentValue, numValues ); + currentDataList = createDataArrayList( currentValue, numValues, refs, numRefs ); if( ddl_nullptr != prev ) { prev->m_next = currentDataList; prev = currentDataList; diff --git a/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h b/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h index ddf36df31..d3e0fb458 100644 --- a/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h +++ b/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h @@ -209,6 +209,8 @@ struct DLL_ODDLPARSER_EXPORT DataArrayList { size_t m_numItems; ///< The number of items in the list. Value *m_dataList; ///< The data list ( a Value ). DataArrayList *m_next; ///< The next data array list ( ddl_nullptr if last ). + Reference *m_refs; + size_t m_numRefs; /// @brief The default constructor for initialization. DataArrayList();