support of openddlparser lib without x++11.
Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>pull/502/head
parent
8e87613bb3
commit
e1c6a16b85
|
@ -13,6 +13,7 @@ else()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions( -DOPENDDLPARSER_BUILD )
|
add_definitions( -DOPENDDLPARSER_BUILD )
|
||||||
|
add_definitions( -DOPENDDL_NO_USE_CPP11 )
|
||||||
add_definitions( -D_VARIADIC_MAX=10 )
|
add_definitions( -D_VARIADIC_MAX=10 )
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
|
|
|
@ -32,11 +32,11 @@ DDLNode::DllNodeList DDLNode::s_allocatedNodes;
|
||||||
template<class T>
|
template<class T>
|
||||||
inline
|
inline
|
||||||
static void releaseDataType( T *ptr ) {
|
static void releaseDataType( T *ptr ) {
|
||||||
if( nullptr == ptr ) {
|
if( ddl_nullptr == ptr ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
T *current( nullptr );
|
T *current( ddl_nullptr );
|
||||||
while( ptr ) {
|
while( ptr ) {
|
||||||
current = ptr;
|
current = ptr;
|
||||||
ptr = ptr->m_next;
|
ptr = ptr->m_next;
|
||||||
|
@ -49,10 +49,10 @@ DDLNode::DDLNode( const std::string &type, const std::string &name, size_t idx,
|
||||||
, m_name( name )
|
, m_name( name )
|
||||||
, m_parent( parent )
|
, m_parent( parent )
|
||||||
, m_children()
|
, m_children()
|
||||||
, m_properties( nullptr )
|
, m_properties( ddl_nullptr )
|
||||||
, m_value( nullptr )
|
, m_value( ddl_nullptr )
|
||||||
, m_idx( idx )
|
, m_idx( idx )
|
||||||
, m_dtArrayList( nullptr ) {
|
, m_dtArrayList( ddl_nullptr ) {
|
||||||
if( m_parent ) {
|
if( m_parent ) {
|
||||||
m_parent->m_children.push_back( this );
|
m_parent->m_children.push_back( this );
|
||||||
}
|
}
|
||||||
|
@ -63,9 +63,9 @@ DDLNode::~DDLNode() {
|
||||||
releaseDataType<Value>( m_value );
|
releaseDataType<Value>( m_value );
|
||||||
|
|
||||||
delete m_dtArrayList;
|
delete m_dtArrayList;
|
||||||
m_dtArrayList = nullptr;
|
m_dtArrayList = ddl_nullptr;
|
||||||
if( s_allocatedNodes[ m_idx ] == this ) {
|
if( s_allocatedNodes[ m_idx ] == this ) {
|
||||||
s_allocatedNodes[ m_idx ] = nullptr;
|
s_allocatedNodes[ m_idx ] = ddl_nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ void DDLNode::attachParent( DDLNode *parent ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
if( nullptr != m_parent ) {
|
if( ddl_nullptr != m_parent ) {
|
||||||
m_parent->m_children.push_back( this );
|
m_parent->m_children.push_back( this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ void DDLNode::detachParent() {
|
||||||
if( m_parent->m_children.end() != it ) {
|
if( m_parent->m_children.end() != it ) {
|
||||||
m_parent->m_children.erase( it );
|
m_parent->m_children.erase( it );
|
||||||
}
|
}
|
||||||
m_parent = nullptr;
|
m_parent = ddl_nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,14 +73,14 @@ static bool isIntegerType( Value::ValueType integerType ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static DDLNode *createDDLNode( Identifier *id, Property *first, OpenDDLParser *parser ) {
|
static DDLNode *createDDLNode( Identifier *id, Property *first, OpenDDLParser *parser ) {
|
||||||
if( nullptr == id || nullptr == parser ) {
|
if( nullptr == id || ddl_nullptr == parser ) {
|
||||||
return nullptr;
|
return ddl_nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string type( id->m_buffer );
|
const std::string type( id->m_buffer );
|
||||||
DDLNode *parent( parser->top() );
|
DDLNode *parent( parser->top() );
|
||||||
DDLNode *node = DDLNode::create( type, "", parent );
|
DDLNode *node = DDLNode::create( type, "", parent );
|
||||||
if( nullptr != first ) {
|
if( ddl_nullptr != first ) {
|
||||||
node->setProperties( first );
|
node->setProperties( first );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,19 +108,19 @@ static void logMessage( LogSeverity severity, const std::string &msg ) {
|
||||||
OpenDDLParser::OpenDDLParser()
|
OpenDDLParser::OpenDDLParser()
|
||||||
: m_logCallback( logMessage )
|
: m_logCallback( logMessage )
|
||||||
, m_ownsBuffer( false )
|
, m_ownsBuffer( false )
|
||||||
,m_buffer( nullptr )
|
, m_buffer( ddl_nullptr )
|
||||||
, m_len( 0 )
|
, m_len( 0 )
|
||||||
, m_stack()
|
, m_stack()
|
||||||
, m_context( nullptr ) {
|
, m_context( ddl_nullptr ) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenDDLParser::OpenDDLParser( char *buffer, size_t len, bool ownsIt )
|
OpenDDLParser::OpenDDLParser( char *buffer, size_t len, bool ownsIt )
|
||||||
: m_logCallback( &logMessage )
|
: m_logCallback( &logMessage )
|
||||||
, m_ownsBuffer( false )
|
, m_ownsBuffer( false )
|
||||||
, m_buffer( nullptr )
|
, m_buffer( ddl_nullptr )
|
||||||
, m_len( 0 )
|
, m_len( 0 )
|
||||||
, m_context( nullptr ) {
|
, m_context( ddl_nullptr ) {
|
||||||
if( 0 != m_len ) {
|
if( 0 != m_len ) {
|
||||||
setBuffer( buffer, len, ownsIt );
|
setBuffer( buffer, len, ownsIt );
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ OpenDDLParser::logCallback OpenDDLParser::getLogCallback() const {
|
||||||
void OpenDDLParser::setBuffer( char *buffer, size_t len, bool ownsIt ) {
|
void OpenDDLParser::setBuffer( char *buffer, size_t len, bool ownsIt ) {
|
||||||
if( m_buffer && m_ownsBuffer ) {
|
if( m_buffer && m_ownsBuffer ) {
|
||||||
delete[] m_buffer;
|
delete[] m_buffer;
|
||||||
m_buffer = nullptr;
|
m_buffer = ddl_nullptr;
|
||||||
m_len = 0;
|
m_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,11 +176,11 @@ void OpenDDLParser::clear() {
|
||||||
if( m_ownsBuffer ) {
|
if( m_ownsBuffer ) {
|
||||||
delete [] m_buffer;
|
delete [] m_buffer;
|
||||||
}
|
}
|
||||||
m_buffer = nullptr;
|
m_buffer = ddl_nullptr;
|
||||||
m_len = 0;
|
m_len = 0;
|
||||||
|
|
||||||
if( m_context ) {
|
if( m_context ) {
|
||||||
m_context->m_root = nullptr;
|
m_context->m_root = ddl_nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
DDLNode::releaseNodes();
|
DDLNode::releaseNodes();
|
||||||
|
@ -194,7 +194,7 @@ bool OpenDDLParser::parse() {
|
||||||
normalizeBuffer( m_buffer, m_len );
|
normalizeBuffer( m_buffer, m_len );
|
||||||
|
|
||||||
m_context = new Context;
|
m_context = new Context;
|
||||||
m_context->m_root = DDLNode::create( "root", "", nullptr );
|
m_context->m_root = DDLNode::create( "root", "", ddl_nullptr );
|
||||||
pushNode( m_context->m_root );
|
pushNode( m_context->m_root );
|
||||||
|
|
||||||
// do the main parsing
|
// do the main parsing
|
||||||
|
@ -218,7 +218,7 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier *id( nullptr );
|
Identifier *id( ddl_nullptr );
|
||||||
in = OpenDDLParser::parseIdentifier( in, end, &id );
|
in = OpenDDLParser::parseIdentifier( in, end, &id );
|
||||||
|
|
||||||
#ifdef DEBUG_HEADER_NAME
|
#ifdef DEBUG_HEADER_NAME
|
||||||
|
@ -228,11 +228,11 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) {
|
||||||
#endif // DEBUG_HEADER_NAME
|
#endif // DEBUG_HEADER_NAME
|
||||||
|
|
||||||
in = getNextToken( in, end );
|
in = getNextToken( in, end );
|
||||||
Property *first( nullptr );
|
Property *first( ddl_nullptr );
|
||||||
if( nullptr != id ) {
|
if( ddl_nullptr != id ) {
|
||||||
if( *in == '(' ) {
|
if( *in == '(' ) {
|
||||||
in++;
|
in++;
|
||||||
Property *prop( nullptr ), *prev( nullptr );
|
Property *prop( ddl_nullptr ), *prev( ddl_nullptr );
|
||||||
while( *in != ')' && in != end ) {
|
while( *in != ')' && in != end ) {
|
||||||
in = parseProperty( in, end, &prop );
|
in = parseProperty( in, end, &prop );
|
||||||
in = getNextToken( in, end );
|
in = getNextToken( in, end );
|
||||||
|
@ -241,11 +241,11 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) {
|
||||||
logInvalidTokenError( in, ")", m_logCallback );
|
logInvalidTokenError( in, ")", m_logCallback );
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
if( nullptr != prop && *in != ',' ) {
|
if( ddl_nullptr != prop && *in != ',' ) {
|
||||||
if( nullptr == first ) {
|
if( ddl_nullptr == first ) {
|
||||||
first = prop;
|
first = prop;
|
||||||
}
|
}
|
||||||
if( nullptr != prev ) {
|
if( ddl_nullptr != prev ) {
|
||||||
prev->m_next = prop;
|
prev->m_next = prop;
|
||||||
}
|
}
|
||||||
prev = prop;
|
prev = prop;
|
||||||
|
@ -262,9 +262,9 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) {
|
||||||
std::cerr << "nullptr returned by creating DDLNode." << std::endl;
|
std::cerr << "nullptr returned by creating DDLNode." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Name *name( nullptr );
|
Name *name( ddl_nullptr );
|
||||||
in = OpenDDLParser::parseName( in, end, &name );
|
in = OpenDDLParser::parseName( in, end, &name );
|
||||||
if( nullptr != name ) {
|
if( ddl_nullptr != name ) {
|
||||||
const std::string nodeName( name->m_id->m_buffer );
|
const std::string nodeName( name->m_id->m_buffer );
|
||||||
node->setName( nodeName );
|
node->setName( nodeName );
|
||||||
}
|
}
|
||||||
|
@ -288,21 +288,21 @@ char *OpenDDLParser::parseStructure( char *in, char *end ) {
|
||||||
if( Value::ddl_none != type ) {
|
if( Value::ddl_none != type ) {
|
||||||
in = getNextToken( in, end );
|
in = getNextToken( in, end );
|
||||||
if( *in == '{' ) {
|
if( *in == '{' ) {
|
||||||
DataArrayList *dtArrayList( nullptr );
|
DataArrayList *dtArrayList( ddl_nullptr );
|
||||||
Value *values( nullptr );
|
Value *values( ddl_nullptr );
|
||||||
if( 1 == arrayLen ) {
|
if( 1 == arrayLen ) {
|
||||||
in = parseDataList( in, end, &values );
|
in = parseDataList( in, end, &values );
|
||||||
if( nullptr != values ){
|
if( ddl_nullptr != values ){
|
||||||
DDLNode *currentNode( top() );
|
DDLNode *currentNode( top() );
|
||||||
if( nullptr != currentNode ) {
|
if( ddl_nullptr != currentNode ) {
|
||||||
currentNode->setValue( values );
|
currentNode->setValue( values );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if( arrayLen > 1 ) {
|
} else if( arrayLen > 1 ) {
|
||||||
in = parseDataArrayList( in, end, &dtArrayList );
|
in = parseDataArrayList( in, end, &dtArrayList );
|
||||||
if( nullptr != dtArrayList ) {
|
if( ddl_nullptr != dtArrayList ) {
|
||||||
DDLNode *currentNode( top() );
|
DDLNode *currentNode( top() );
|
||||||
if( nullptr != currentNode ) {
|
if( ddl_nullptr != currentNode ) {
|
||||||
currentNode->setDataArrayList( dtArrayList );
|
currentNode->setDataArrayList( dtArrayList );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,7 +341,7 @@ void OpenDDLParser::pushNode( DDLNode *node ) {
|
||||||
|
|
||||||
DDLNode *OpenDDLParser::popNode() {
|
DDLNode *OpenDDLParser::popNode() {
|
||||||
if( m_stack.empty() ) {
|
if( m_stack.empty() ) {
|
||||||
return nullptr;
|
return ddl_nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
DDLNode *topNode( top() );
|
DDLNode *topNode( top() );
|
||||||
|
@ -352,7 +352,7 @@ DDLNode *OpenDDLParser::popNode() {
|
||||||
|
|
||||||
DDLNode *OpenDDLParser::top() {
|
DDLNode *OpenDDLParser::top() {
|
||||||
if( m_stack.empty() ) {
|
if( m_stack.empty() ) {
|
||||||
return nullptr;
|
return ddl_nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
DDLNode *top( m_stack.back() );
|
DDLNode *top( m_stack.back() );
|
||||||
|
@ -361,7 +361,7 @@ DDLNode *OpenDDLParser::top() {
|
||||||
|
|
||||||
DDLNode *OpenDDLParser::getRoot() const {
|
DDLNode *OpenDDLParser::getRoot() const {
|
||||||
if( nullptr == m_context ) {
|
if( nullptr == m_context ) {
|
||||||
return nullptr;
|
return ddl_nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_context->m_root;
|
return m_context->m_root;
|
||||||
|
@ -401,8 +401,8 @@ void OpenDDLParser::normalizeBuffer( char *buffer, size_t len ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OpenDDLParser::parseName( char *in, char *end, Name **name ) {
|
char *OpenDDLParser::parseName( char *in, char *end, Name **name ) {
|
||||||
*name = nullptr;
|
*name = ddl_nullptr;
|
||||||
if( nullptr == in || in == end ) {
|
if( ddl_nullptr == in || in == end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,8 +417,8 @@ char *OpenDDLParser::parseName( char *in, char *end, Name **name ) {
|
||||||
ntype = LocalName;
|
ntype = LocalName;
|
||||||
}
|
}
|
||||||
|
|
||||||
Name *currentName( nullptr );
|
Name *currentName( ddl_nullptr );
|
||||||
Identifier *id( nullptr );
|
Identifier *id( ddl_nullptr );
|
||||||
in = parseIdentifier( in, end, &id );
|
in = parseIdentifier( in, end, &id );
|
||||||
if( id ) {
|
if( id ) {
|
||||||
currentName = new Name( ntype, id );
|
currentName = new Name( ntype, id );
|
||||||
|
@ -431,8 +431,8 @@ char *OpenDDLParser::parseName( char *in, char *end, Name **name ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OpenDDLParser::parseIdentifier( char *in, char *end, Identifier **id ) {
|
char *OpenDDLParser::parseIdentifier( char *in, char *end, Identifier **id ) {
|
||||||
*id = nullptr;
|
*id = ddl_nullptr;
|
||||||
if( nullptr == in || in == end ) {
|
if( ddl_nullptr == in || in == end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ char *OpenDDLParser::parseIdentifier( char *in, char *end, Identifier **id ) {
|
||||||
char *OpenDDLParser::parsePrimitiveDataType( char *in, char *end, Value::ValueType &type, size_t &len ) {
|
char *OpenDDLParser::parsePrimitiveDataType( char *in, char *end, Value::ValueType &type, size_t &len ) {
|
||||||
type = Value::ddl_none;
|
type = Value::ddl_none;
|
||||||
len = 0;
|
len = 0;
|
||||||
if( nullptr == in || in == end ) {
|
if( ddl_nullptr == in || in == end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,7 +508,7 @@ char *OpenDDLParser::parsePrimitiveDataType( char *in, char *end, Value::ValueTy
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OpenDDLParser::parseReference( char *in, char *end, std::vector<Name*> &names ) {
|
char *OpenDDLParser::parseReference( char *in, char *end, std::vector<Name*> &names ) {
|
||||||
if( nullptr == in || in == end ) {
|
if( ddl_nullptr == in || in == end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,7 +527,7 @@ char *OpenDDLParser::parseReference( char *in, char *end, std::vector<Name*> &na
|
||||||
}
|
}
|
||||||
|
|
||||||
in = getNextToken( in, end );
|
in = getNextToken( in, end );
|
||||||
Name *nextName( nullptr );
|
Name *nextName( ddl_nullptr );
|
||||||
in = parseName( in, end, &nextName );
|
in = parseName( in, end, &nextName );
|
||||||
if( nextName ) {
|
if( nextName ) {
|
||||||
names.push_back( nextName );
|
names.push_back( nextName );
|
||||||
|
@ -548,8 +548,8 @@ char *OpenDDLParser::parseReference( char *in, char *end, std::vector<Name*> &na
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OpenDDLParser::parseBooleanLiteral( char *in, char *end, Value **boolean ) {
|
char *OpenDDLParser::parseBooleanLiteral( char *in, char *end, Value **boolean ) {
|
||||||
*boolean = nullptr;
|
*boolean = ddl_nullptr;
|
||||||
if( nullptr == in || in == end ) {
|
if( ddl_nullptr == in || in == end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,7 +565,7 @@ char *OpenDDLParser::parseBooleanLiteral( char *in, char *end, Value **boolean )
|
||||||
if( 0 != res ) {
|
if( 0 != res ) {
|
||||||
res = ::strncmp( BoolFalse, start, strlen( BoolFalse ) );
|
res = ::strncmp( BoolFalse, start, strlen( BoolFalse ) );
|
||||||
if( 0 != res ) {
|
if( 0 != res ) {
|
||||||
*boolean = nullptr;
|
*boolean = ddl_nullptr;
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
*boolean = ValueAllocator::allocPrimData( Value::ddl_bool );
|
*boolean = ValueAllocator::allocPrimData( Value::ddl_bool );
|
||||||
|
@ -579,7 +579,7 @@ char *OpenDDLParser::parseBooleanLiteral( char *in, char *end, Value **boolean )
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OpenDDLParser::parseIntegerLiteral( char *in, char *end, Value **integer, Value::ValueType integerType ) {
|
char *OpenDDLParser::parseIntegerLiteral( char *in, char *end, Value **integer, Value::ValueType integerType ) {
|
||||||
*integer = nullptr;
|
*integer = ddl_nullptr;
|
||||||
if( nullptr == in || in == end ) {
|
if( nullptr == in || in == end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
@ -619,8 +619,8 @@ char *OpenDDLParser::parseIntegerLiteral( char *in, char *end, Value **integer,
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OpenDDLParser::parseFloatingLiteral( char *in, char *end, Value **floating ) {
|
char *OpenDDLParser::parseFloatingLiteral( char *in, char *end, Value **floating ) {
|
||||||
*floating = nullptr;
|
*floating = ddl_nullptr;
|
||||||
if( nullptr == in || in == end ) {
|
if( ddl_nullptr == in || in == end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,8 +652,8 @@ char *OpenDDLParser::parseFloatingLiteral( char *in, char *end, Value **floating
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OpenDDLParser::parseStringLiteral( char *in, char *end, Value **stringData ) {
|
char *OpenDDLParser::parseStringLiteral( char *in, char *end, Value **stringData ) {
|
||||||
*stringData = nullptr;
|
*stringData = ddl_nullptr;
|
||||||
if( nullptr == in || in == end ) {
|
if( ddl_nullptr == in || in == end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -685,8 +685,8 @@ static void createPropertyWithData( Identifier *id, Value *primData, Property **
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OpenDDLParser::parseHexaLiteral( char *in, char *end, Value **data ) {
|
char *OpenDDLParser::parseHexaLiteral( char *in, char *end, Value **data ) {
|
||||||
*data = nullptr;
|
*data = ddl_nullptr;
|
||||||
if( nullptr == in || in == end ) {
|
if( ddl_nullptr == in || in == end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,20 +731,20 @@ char *OpenDDLParser::parseHexaLiteral( char *in, char *end, Value **data ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OpenDDLParser::parseProperty( char *in, char *end, Property **prop ) {
|
char *OpenDDLParser::parseProperty( char *in, char *end, Property **prop ) {
|
||||||
*prop = nullptr;
|
*prop = ddl_nullptr;
|
||||||
if( nullptr == in || in == end ) {
|
if( ddl_nullptr == in || in == end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
in = getNextToken( in, end );
|
in = getNextToken( in, end );
|
||||||
Identifier *id( nullptr );
|
Identifier *id( ddl_nullptr );
|
||||||
in = parseIdentifier( in, end, &id );
|
in = parseIdentifier( in, end, &id );
|
||||||
if( nullptr != id ) {
|
if( nullptr != id ) {
|
||||||
in = getNextToken( in, end );
|
in = getNextToken( in, end );
|
||||||
if( *in == '=' ) {
|
if( *in == '=' ) {
|
||||||
in++;
|
in++;
|
||||||
in = getNextToken( in, end );
|
in = getNextToken( in, end );
|
||||||
Value *primData( nullptr );
|
Value *primData( ddl_nullptr );
|
||||||
if( isInteger( in, end ) ) {
|
if( isInteger( in, end ) ) {
|
||||||
in = parseIntegerLiteral( in, end, &primData );
|
in = parseIntegerLiteral( in, end, &primData );
|
||||||
createPropertyWithData( id, primData, prop );
|
createPropertyWithData( id, primData, prop );
|
||||||
|
@ -770,17 +770,17 @@ char *OpenDDLParser::parseProperty( char *in, char *end, Property **prop ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OpenDDLParser::parseDataList( char *in, char *end, Value **data ) {
|
char *OpenDDLParser::parseDataList( char *in, char *end, Value **data ) {
|
||||||
*data = nullptr;
|
*data = ddl_nullptr;
|
||||||
if( nullptr == in || in == end ) {
|
if( ddl_nullptr == in || in == end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
in = getNextToken( in, end );
|
in = getNextToken( in, end );
|
||||||
if( *in == '{' ) {
|
if( *in == '{' ) {
|
||||||
in++;
|
in++;
|
||||||
Value *current( nullptr ), *prev( nullptr );
|
Value *current( ddl_nullptr ), *prev( ddl_nullptr );
|
||||||
while( '}' != *in ) {
|
while( '}' != *in ) {
|
||||||
current = nullptr;
|
current = ddl_nullptr;
|
||||||
in = getNextToken( in, end );
|
in = getNextToken( in, end );
|
||||||
if( isInteger( in, end ) ) {
|
if( isInteger( in, end ) ) {
|
||||||
in = parseIntegerLiteral( in, end, ¤t );
|
in = parseIntegerLiteral( in, end, ¤t );
|
||||||
|
@ -792,8 +792,8 @@ char *OpenDDLParser::parseDataList( char *in, char *end, Value **data ) {
|
||||||
in = parseHexaLiteral( in, end, ¤t );
|
in = parseHexaLiteral( in, end, ¤t );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nullptr != current ) {
|
if( ddl_nullptr != current ) {
|
||||||
if( nullptr == *data ) {
|
if( ddl_nullptr == *data ) {
|
||||||
*data = current;
|
*data = current;
|
||||||
prev = current;
|
prev = current;
|
||||||
} else {
|
} else {
|
||||||
|
@ -814,26 +814,26 @@ char *OpenDDLParser::parseDataList( char *in, char *end, Value **data ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OpenDDLParser::parseDataArrayList( char *in, char *end, DataArrayList **dataList ) {
|
char *OpenDDLParser::parseDataArrayList( char *in, char *end, DataArrayList **dataList ) {
|
||||||
*dataList = nullptr;
|
*dataList = ddl_nullptr;
|
||||||
if( nullptr == in || in == end ) {
|
if( ddl_nullptr == in || in == end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
in = getNextToken( in, end );
|
in = getNextToken( in, end );
|
||||||
if( *in == '{' ) {
|
if( *in == '{' ) {
|
||||||
in++;
|
in++;
|
||||||
Value *current( nullptr );
|
Value *current( ddl_nullptr );
|
||||||
DataArrayList *prev( nullptr ), *currentDataList( nullptr );
|
DataArrayList *prev( ddl_nullptr ), *currentDataList( ddl_nullptr );
|
||||||
do {
|
do {
|
||||||
in = parseDataList( in, end, ¤t );
|
in = parseDataList( in, end, ¤t );
|
||||||
if( nullptr != current ) {
|
if( ddl_nullptr != current ) {
|
||||||
if( nullptr == prev ) {
|
if( ddl_nullptr == prev ) {
|
||||||
*dataList = new DataArrayList;
|
*dataList = new DataArrayList;
|
||||||
(*dataList)->m_dataList = current;
|
(*dataList)->m_dataList = current;
|
||||||
prev = *dataList;
|
prev = *dataList;
|
||||||
} else {
|
} else {
|
||||||
currentDataList = new DataArrayList;
|
currentDataList = new DataArrayList;
|
||||||
if( nullptr != prev ) {
|
if( ddl_nullptr != prev ) {
|
||||||
prev->m_next = currentDataList;
|
prev->m_next = currentDataList;
|
||||||
prev = currentDataList;
|
prev = currentDataList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ BEGIN_ODDLPARSER_NS
|
||||||
Value::Value()
|
Value::Value()
|
||||||
: m_type( ddl_none )
|
: m_type( ddl_none )
|
||||||
, m_size( 0 )
|
, m_size( 0 )
|
||||||
, m_data( nullptr )
|
, m_data( ddl_nullptr )
|
||||||
, m_next( nullptr ) {
|
, m_next( ddl_nullptr ) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ Value *Value::getNext() const {
|
||||||
|
|
||||||
Value *ValueAllocator::allocPrimData( Value::ValueType type, size_t len ) {
|
Value *ValueAllocator::allocPrimData( Value::ValueType type, size_t len ) {
|
||||||
if( type == Value::ddl_none || Value::ddl_types_max == type ) {
|
if( type == Value::ddl_none || Value::ddl_types_max == type ) {
|
||||||
return nullptr;
|
return ddl_nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value *data = new Value;
|
Value *data = new Value;
|
||||||
|
@ -236,8 +236,7 @@ void ValueAllocator::releasePrimData( Value **data ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
delete *data;
|
delete *data;
|
||||||
*data = nullptr;
|
*data = ddl_nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
END_ODDLPARSER_NS
|
END_ODDLPARSER_NS
|
||||||
|
|
|
@ -46,6 +46,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
BEGIN_ODDLPARSER_NS
|
BEGIN_ODDLPARSER_NS
|
||||||
|
|
||||||
|
#ifndef OPENDDL_NO_USE_CPP11
|
||||||
|
# define ddl_nullptr nullptr
|
||||||
|
#else
|
||||||
|
# define ddl_nullptr NULL
|
||||||
|
#endif
|
||||||
|
|
||||||
class DDLNode;
|
class DDLNode;
|
||||||
class Value;
|
class Value;
|
||||||
|
|
||||||
|
@ -106,9 +112,9 @@ struct Property {
|
||||||
|
|
||||||
Property( Identifier *id )
|
Property( Identifier *id )
|
||||||
: m_id( id )
|
: m_id( id )
|
||||||
, m_primData( nullptr )
|
, m_primData( ddl_nullptr )
|
||||||
, m_ref( nullptr )
|
, m_ref( ddl_nullptr )
|
||||||
, m_next( nullptr ) {
|
, m_next( ddl_nullptr ) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -120,8 +126,8 @@ struct DataArrayList {
|
||||||
|
|
||||||
DataArrayList()
|
DataArrayList()
|
||||||
: m_numItems( 0 )
|
: m_numItems( 0 )
|
||||||
, m_dataList( nullptr )
|
, m_dataList( ddl_nullptr )
|
||||||
, m_next( nullptr ) {
|
, m_next( ddl_nullptr ) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -131,8 +137,8 @@ struct Context {
|
||||||
DDLNode *m_root;
|
DDLNode *m_root;
|
||||||
|
|
||||||
Context()
|
Context()
|
||||||
: m_properties( nullptr )
|
: m_properties( ddl_nullptr )
|
||||||
, m_root( nullptr ) {
|
, m_root( ddl_nullptr ) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -106,7 +106,6 @@ private:
|
||||||
bool m_ownsBuffer;
|
bool m_ownsBuffer;
|
||||||
char *m_buffer;
|
char *m_buffer;
|
||||||
size_t m_len;
|
size_t m_len;
|
||||||
//DDLNode *m_root;
|
|
||||||
typedef std::vector<DDLNode*> DDLNodeStack;
|
typedef std::vector<DDLNode*> DDLNodeStack;
|
||||||
DDLNodeStack m_stack;
|
DDLNodeStack m_stack;
|
||||||
Context *m_context;
|
Context *m_context;
|
||||||
|
|
Loading…
Reference in New Issue