- fix invalid value get for index data. - update OpenDDL-librarypull/789/head
parent
7961c22c55
commit
522f4e0882
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2014, assimp team
|
Copyright (c) 2006-2016, assimp team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2014, assimp team
|
Copyright (c) 2006-2016, assimp team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2014, assimp team
|
Copyright (c) 2006-2016, assimp team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
@ -225,6 +225,7 @@ OpenGEXImporter::OpenGEXImporter()
|
||||||
, m_tokenType( Grammar::NoneType )
|
, m_tokenType( Grammar::NoneType )
|
||||||
, m_nodeStack()
|
, m_nodeStack()
|
||||||
, m_unresolvedRefStack() {
|
, m_unresolvedRefStack() {
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
|
@ -423,7 +424,7 @@ static void getRefNames( DDLNode *node, std::vector<std::string> &names ) {
|
||||||
for( size_t i = 0; i < ref->m_numRefs; i++ ) {
|
for( size_t i = 0; i < ref->m_numRefs; i++ ) {
|
||||||
Name *currentName( ref->m_referencedName[ i ] );
|
Name *currentName( ref->m_referencedName[ i ] );
|
||||||
if( NULL != currentName && NULL != currentName->m_id ) {
|
if( NULL != currentName && NULL != currentName->m_id ) {
|
||||||
const std::string name( currentName->m_id->m_text.m_buffer );
|
const std::string name( currentName->m_id->m_buffer );
|
||||||
if( !name.empty() ) {
|
if( !name.empty() ) {
|
||||||
names.push_back( name );
|
names.push_back( name );
|
||||||
}
|
}
|
||||||
|
@ -541,7 +542,7 @@ static void propId2StdString( Property *prop, std::string &name, std::string &ke
|
||||||
}
|
}
|
||||||
|
|
||||||
if( NULL != prop->m_key ) {
|
if( NULL != prop->m_key ) {
|
||||||
name = prop->m_key->m_text.m_buffer;
|
name = prop->m_key->m_buffer;
|
||||||
if( Value::ddl_string == prop->m_value->m_type ) {
|
if( Value::ddl_string == prop->m_value->m_type ) {
|
||||||
key = prop->m_value->getString();
|
key = prop->m_value->getString();
|
||||||
}
|
}
|
||||||
|
@ -714,7 +715,7 @@ void OpenGEXImporter::handleIndexArrayNode( ODDLParser::DDLNode *node, aiScene *
|
||||||
current.mIndices = new unsigned int[ current.mNumIndices ];
|
current.mIndices = new unsigned int[ current.mNumIndices ];
|
||||||
Value *next( vaList->m_dataList );
|
Value *next( vaList->m_dataList );
|
||||||
for( size_t indices = 0; indices < current.mNumIndices; indices++ ) {
|
for( size_t indices = 0; indices < current.mNumIndices; indices++ ) {
|
||||||
const int idx = next->getInt32();
|
const int idx( next->getUnsignedInt32() );
|
||||||
ai_assert( static_cast<size_t>( idx ) <= m_currentVertices.m_numVerts );
|
ai_assert( static_cast<size_t>( idx ) <= m_currentVertices.m_numVerts );
|
||||||
|
|
||||||
aiVector3D &pos = ( m_currentVertices.m_vertices[ idx ] );
|
aiVector3D &pos = ( m_currentVertices.m_vertices[ idx ] );
|
||||||
|
@ -758,12 +759,16 @@ enum ColorType {
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
static ColorType getColorType( Identifier *id ) {
|
static ColorType getColorType( Text *id ) {
|
||||||
if( id->m_text == Grammar::DiffuseColorToken ) {
|
if ( NULL == id ) {
|
||||||
|
return NoneColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( *id == Grammar::DiffuseColorToken ) {
|
||||||
return DiffuseColor;
|
return DiffuseColor;
|
||||||
} else if( id->m_text == Grammar::SpecularColorToken ) {
|
} else if( *id == Grammar::SpecularColorToken ) {
|
||||||
return SpecularColor;
|
return SpecularColor;
|
||||||
} else if( id->m_text == Grammar::EmissionColorToken ) {
|
} else if( *id == Grammar::EmissionColorToken ) {
|
||||||
return EmissionColor;
|
return EmissionColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2014, assimp team
|
Copyright (c) 2006-2016, assimp team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2014, assimp team
|
Copyright (c) 2006-2016, assimp team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use of this software in source and binary forms,
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
|
|
@ -1,29 +1,39 @@
|
||||||
The OpenDDL-Parser
|
The OpenDDL-Parser
|
||||||
==================
|
==================
|
||||||
|
|
||||||
A simple and fast OpenDDL Parser
|
The OpenDDL-Parser is a small and easy to use library for OpenDDL-file-format-parsing. OpenDDL is the shortcut for Open Data Description Language, a data-declaration language introduced by Eric Lengyel. Please check http://openddl.org/ if you want to learn more about it.
|
||||||
Current build status: [![Build Status](https://travis-ci.org/kimkulling/openddl-parser.png)](https://travis-ci.org/kimkulling/openddl-parser)
|
|
||||||
|
Build status
|
||||||
|
============
|
||||||
|
Linux build status: [![Build Status](https://travis-ci.org/kimkulling/openddl-parser.png)](https://travis-ci.org/kimkulling/openddl-parser)
|
||||||
|
Current coverity check status:
|
||||||
|
<a href="https://scan.coverity.com/projects/5606">
|
||||||
|
<img alt="Coverity Scan Build Status"
|
||||||
|
src="https://scan.coverity.com/projects/5606/badge.svg"/>
|
||||||
|
</a>
|
||||||
|
|
||||||
Get the source code
|
Get the source code
|
||||||
===================
|
===================
|
||||||
You can get the code from our git repository, which is located at GitHub. You can clone the repository like:
|
You can get the code from our git repository, which is located at GitHub. You can clone the repository with the following command:
|
||||||
|
|
||||||
> git clone https://github.com/kimkulling/openddl-parser.git
|
> git clone https://github.com/kimkulling/openddl-parser.git
|
||||||
|
|
||||||
Build from repo
|
Building the source from the GitHub-Repo
|
||||||
===============
|
========================================
|
||||||
To build the library you need to install cmake first ( see http://www.cmake.org/ for more information ). Make also sure that a compiler toolchain is installed on your machine.
|
To build the library you need to install cmake first ( see http://www.cmake.org/ for more information ). Make also sure that a compiler tool-chain is installed on your machine.
|
||||||
After installing it you can open a console and type:
|
After installing it you can open a console and enter:
|
||||||
|
|
||||||
> cmake CMakeLists.txt
|
> cmake CMakeLists.txt
|
||||||
|
|
||||||
This command will generate a build environment for your installed build enrironment ( for Visual Studio the project files will be generated, for gcc the makefiles will be generated ).
|
This command will generate a build environment for your installed build enrironment ( for Visual-Studio-users the project files will be generated, for gcc-users the makefiles will be generated ).
|
||||||
When using an IDE open the IDE and run the build. When using GNU-make type in your console:
|
When using an IDE open the IDE and run the build. When using GNU-make type in your console:
|
||||||
|
|
||||||
> make
|
> make
|
||||||
|
|
||||||
and that's all.
|
and that's all.
|
||||||
|
|
||||||
|
When using Visual Studio CMake will generate you a solution for ythe library. Just build it there.
|
||||||
|
|
||||||
Use the library
|
Use the library
|
||||||
===============
|
===============
|
||||||
To use the OpenDDL-parser you need to build the lib first. Now add the
|
To use the OpenDDL-parser you need to build the lib first. Now add the
|
||||||
|
@ -88,24 +98,39 @@ int main( int argc, char *argv[] ) {
|
||||||
|
|
||||||
How to access the imported data
|
How to access the imported data
|
||||||
===============================
|
===============================
|
||||||
The data is organized as a tree. You can get the root tree with the following code:
|
The data is organized as a tree. You can get the root-node of the tree with the following code:
|
||||||
|
|
||||||
```
|
```cpp
|
||||||
OpenDDLParser theParser;
|
OpenDDLParser theParser;
|
||||||
theParser.setBuffer( buffer, size );
|
theParser.setBuffer( buffer, size );
|
||||||
const bool result( theParser.parse() );
|
const bool result( theParser.parse() );
|
||||||
if ( result ) {
|
if ( result ) {
|
||||||
DDLNode *root = theParser.getRoot();
|
DDLNode *root = theParser.getRoot();
|
||||||
|
|
||||||
DDLNode::DllNodeList childs = root->getChildNodeList();
|
DDLNode::DllNodeList childs = root->getChildNodeList();
|
||||||
for ( size_t i=0; i<childs.size(); i++ ) {
|
for ( size_t i=0; i<childs.size(); i++ ) {
|
||||||
DDLNode *child = childs[ i ];
|
DDLNode *child = childs[ i ];
|
||||||
Property *prop = child->getProperty(); // to get properties
|
Property *prop = child->getProperty(); // to get properties
|
||||||
std:.string type = child->getType(); // to get the node type
|
std::string type = child->getType(); // to get the node type
|
||||||
Value *values = child->getValue(); // to get the data;
|
Value *values = child->getValue(); // to get the data;
|
||||||
|
|
||||||
|
// to loop through all values
|
||||||
|
while ( values != ddl_nullptr ) {
|
||||||
|
int current = values->getInt32();
|
||||||
|
values = value->getNext();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The instance called root contains the data.
|
The node instance called root contains the data.
|
||||||
|
|
||||||
|
All data lists are organized as linked lists.
|
||||||
|
|
||||||
|
Reference documentation
|
||||||
|
=======================
|
||||||
|
Please check http://kimkulling.github.io/openddl-parser/doxygen_html/index.html.
|
||||||
|
|
||||||
|
Projects using OpenDDL-Parser
|
||||||
|
=============================
|
||||||
|
- Asset Importer Lib: https://github.com/assimp/assimp .
|
||||||
|
|
|
@ -153,7 +153,7 @@ Property *DDLNode::findPropertyByName( const std::string &name ) {
|
||||||
|
|
||||||
Property *current( m_properties );
|
Property *current( m_properties );
|
||||||
while( ddl_nullptr != current ) {
|
while( ddl_nullptr != current ) {
|
||||||
int res = strncmp( current->m_key->m_text.m_buffer, name.c_str(), name.size() );
|
int res = strncmp( current->m_key->m_buffer, name.c_str(), name.size() );
|
||||||
if( 0 == res ) {
|
if( 0 == res ) {
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,31 +73,14 @@ bool Text::operator == ( const Text &rhs ) const {
|
||||||
return ( 0 == res );
|
return ( 0 == res );
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier::Identifier( const char buffer[], size_t len )
|
Name::Name( NameType type, Text *id )
|
||||||
: m_text( buffer, len ) {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
Identifier::Identifier( const char buffer[] )
|
|
||||||
: m_text( buffer, strlen( buffer ) ) {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
Identifier::~Identifier() {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Identifier::operator == ( const Identifier &rhs ) const {
|
|
||||||
return m_text == rhs.m_text;
|
|
||||||
}
|
|
||||||
|
|
||||||
Name::Name( NameType type, Identifier *id )
|
|
||||||
: m_type( type )
|
: m_type( type )
|
||||||
, m_id( id ) {
|
, m_id( id ) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
Name::~Name() {
|
Name::~Name() {
|
||||||
|
delete m_id;
|
||||||
m_id = ddl_nullptr;
|
m_id = ddl_nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,10 +93,12 @@ Reference::Reference()
|
||||||
Reference::Reference( size_t numrefs, Name **names )
|
Reference::Reference( size_t numrefs, Name **names )
|
||||||
: m_numRefs( numrefs )
|
: m_numRefs( numrefs )
|
||||||
, m_referencedName( ddl_nullptr ) {
|
, m_referencedName( ddl_nullptr ) {
|
||||||
m_referencedName = new Name *[ numrefs ];
|
if ( numrefs > 0 ) {
|
||||||
for( size_t i = 0; i < numrefs; i++ ) {
|
m_referencedName = new Name *[ numrefs ];
|
||||||
Name *name = new Name( names[ i ]->m_type, names[ i ]->m_id );
|
for ( size_t i = 0; i < numrefs; i++ ) {
|
||||||
m_referencedName[ i ] = name;
|
Name *name = new Name( names[ i ]->m_type, names[ i ]->m_id );
|
||||||
|
m_referencedName[ i ] = name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +110,23 @@ Reference::~Reference() {
|
||||||
m_referencedName = ddl_nullptr;
|
m_referencedName = ddl_nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Property::Property( Identifier *id )
|
size_t Reference::sizeInBytes() {
|
||||||
|
if ( 0 == m_numRefs ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t size( 0 );
|
||||||
|
for ( size_t i = 0; i < m_numRefs; i++ ) {
|
||||||
|
Name *name( m_referencedName[ i ] );
|
||||||
|
if ( ddl_nullptr != name ) {
|
||||||
|
size += name->m_id->m_len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
Property::Property( Text *id )
|
||||||
: m_key( id )
|
: m_key( id )
|
||||||
, m_value( ddl_nullptr )
|
, m_value( ddl_nullptr )
|
||||||
, m_ref( ddl_nullptr )
|
, m_ref( ddl_nullptr )
|
||||||
|
@ -152,7 +153,7 @@ DataArrayList::~DataArrayList() {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t DataArrayList::size() {
|
size_t DataArrayList::size() {
|
||||||
size_t result=1;
|
size_t result( 0 );
|
||||||
DataArrayList *n=m_next;
|
DataArrayList *n=m_next;
|
||||||
while( n!=ddl_nullptr ) {
|
while( n!=ddl_nullptr ) {
|
||||||
result++;
|
result++;
|
||||||
|
@ -167,7 +168,7 @@ Context::Context()
|
||||||
}
|
}
|
||||||
|
|
||||||
Context::~Context() {
|
Context::~Context() {
|
||||||
m_root = ddl_nullptr;
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Context::clear() {
|
void Context::clear() {
|
||||||
|
|
|
@ -256,7 +256,7 @@ bool OpenDDLExport::writeProperties( DDLNode *node, std::string &statement ) {
|
||||||
} else {
|
} else {
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
statement += std::string( prop->m_key->m_text.m_buffer );
|
statement += std::string( prop->m_key->m_buffer );
|
||||||
statement += " = ";
|
statement += " = ";
|
||||||
writeValue( prop->m_value, statement );
|
writeValue( prop->m_value, statement );
|
||||||
prop = prop->m_next;
|
prop = prop->m_next;
|
||||||
|
|
|
@ -97,12 +97,12 @@ static bool isUnsignedIntegerType( Value::ValueType integerType ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DDLNode *createDDLNode( Identifier *id, OpenDDLParser *parser ) {
|
static DDLNode *createDDLNode( Text *id, OpenDDLParser *parser ) {
|
||||||
if( ddl_nullptr == id || ddl_nullptr == parser ) {
|
if( ddl_nullptr == id || ddl_nullptr == parser ) {
|
||||||
return ddl_nullptr;
|
return ddl_nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string type( id->m_text.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 );
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ OpenDDLParser::OpenDDLParser()
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
OpenDDLParser::OpenDDLParser( char *buffer, size_t len )
|
OpenDDLParser::OpenDDLParser( const char *buffer, size_t len )
|
||||||
: m_logCallback( &logMessage )
|
: m_logCallback( &logMessage )
|
||||||
, m_buffer()
|
, m_buffer()
|
||||||
, m_context( ddl_nullptr ) {
|
, m_context( ddl_nullptr ) {
|
||||||
|
@ -162,7 +162,7 @@ OpenDDLParser::logCallback OpenDDLParser::getLogCallback() const {
|
||||||
return m_logCallback;
|
return m_logCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenDDLParser::setBuffer( char *buffer, size_t len ) {
|
void OpenDDLParser::setBuffer( const char *buffer, size_t len ) {
|
||||||
clear();
|
clear();
|
||||||
if( 0 == len ) {
|
if( 0 == len ) {
|
||||||
return;
|
return;
|
||||||
|
@ -192,7 +192,7 @@ size_t OpenDDLParser::getBufferSize() const {
|
||||||
|
|
||||||
void OpenDDLParser::clear() {
|
void OpenDDLParser::clear() {
|
||||||
m_buffer.resize( 0 );
|
m_buffer.resize( 0 );
|
||||||
if( m_context ) {
|
if( ddl_nullptr != m_context ) {
|
||||||
m_context->m_root = ddl_nullptr;
|
m_context->m_root = ddl_nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
Identifier *id( ddl_nullptr );
|
Text *id( ddl_nullptr );
|
||||||
in = OpenDDLParser::parseIdentifier( in, end, &id );
|
in = OpenDDLParser::parseIdentifier( in, end, &id );
|
||||||
|
|
||||||
#ifdef DEBUG_HEADER_NAME
|
#ifdef DEBUG_HEADER_NAME
|
||||||
|
@ -263,33 +263,7 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) {
|
||||||
#endif // DEBUG_HEADER_NAME
|
#endif // DEBUG_HEADER_NAME
|
||||||
|
|
||||||
in = lookForNextToken( in, end );
|
in = lookForNextToken( in, end );
|
||||||
Property *first( ddl_nullptr );
|
|
||||||
if( ddl_nullptr != id ) {
|
if( ddl_nullptr != id ) {
|
||||||
if( *in == Grammar::OpenPropertyToken[ 0 ] ) {
|
|
||||||
in++;
|
|
||||||
Property *prop( ddl_nullptr ), *prev( ddl_nullptr );
|
|
||||||
while( *in != Grammar::ClosePropertyToken[ 0 ] && in != end ) {
|
|
||||||
in = OpenDDLParser::parseProperty( in, end, &prop );
|
|
||||||
in = lookForNextToken( in, end );
|
|
||||||
|
|
||||||
if( *in != Grammar::CommaSeparator[ 0 ] && *in != Grammar::ClosePropertyToken[ 0 ] ) {
|
|
||||||
logInvalidTokenError( in, Grammar::ClosePropertyToken, m_logCallback );
|
|
||||||
return ddl_nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ddl_nullptr != prop && *in != Grammar::CommaSeparator[ 0 ] ) {
|
|
||||||
if( ddl_nullptr == first ) {
|
|
||||||
first = prop;
|
|
||||||
}
|
|
||||||
if( ddl_nullptr != prev ) {
|
|
||||||
prev->m_next = prop;
|
|
||||||
}
|
|
||||||
prev = prop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
in++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// store the node
|
// store the node
|
||||||
DDLNode *node( createDDLNode( id, this ) );
|
DDLNode *node( createDDLNode( id, this ) );
|
||||||
if( ddl_nullptr != node ) {
|
if( ddl_nullptr != node ) {
|
||||||
|
@ -298,17 +272,44 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the properties
|
Name *name(ddl_nullptr);
|
||||||
if( ddl_nullptr != first && ddl_nullptr != node ) {
|
in = OpenDDLParser::parseName(in, end, &name);
|
||||||
node->setProperties( first );
|
|
||||||
}
|
|
||||||
|
|
||||||
Name *name( ddl_nullptr );
|
|
||||||
in = OpenDDLParser::parseName( in, end, &name );
|
|
||||||
if( ddl_nullptr != name && ddl_nullptr != node ) {
|
if( ddl_nullptr != name && ddl_nullptr != node ) {
|
||||||
const std::string nodeName( name->m_id->m_text.m_buffer );
|
const std::string nodeName( name->m_id->m_buffer );
|
||||||
node->setName( nodeName );
|
node->setName( nodeName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Property *first(ddl_nullptr);
|
||||||
|
in = lookForNextToken(in, end);
|
||||||
|
if (*in == Grammar::OpenPropertyToken[0]) {
|
||||||
|
in++;
|
||||||
|
Property *prop(ddl_nullptr), *prev(ddl_nullptr);
|
||||||
|
while (*in != Grammar::ClosePropertyToken[0] && in != end) {
|
||||||
|
in = OpenDDLParser::parseProperty(in, end, &prop);
|
||||||
|
in = lookForNextToken(in, end);
|
||||||
|
|
||||||
|
if (*in != Grammar::CommaSeparator[0] && *in != Grammar::ClosePropertyToken[0]) {
|
||||||
|
logInvalidTokenError(in, Grammar::ClosePropertyToken, m_logCallback);
|
||||||
|
return ddl_nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ddl_nullptr != prop && *in != Grammar::CommaSeparator[0]) {
|
||||||
|
if (ddl_nullptr == first) {
|
||||||
|
first = prop;
|
||||||
|
}
|
||||||
|
if (ddl_nullptr != prev) {
|
||||||
|
prev->m_next = prop;
|
||||||
|
}
|
||||||
|
prev = prop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
in++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the properties
|
||||||
|
if (ddl_nullptr != first && ddl_nullptr != node) {
|
||||||
|
node->setProperties(first);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
|
@ -499,7 +500,7 @@ char *OpenDDLParser::parseName( char *in, char *end, Name **name ) {
|
||||||
}
|
}
|
||||||
in++;
|
in++;
|
||||||
Name *currentName( ddl_nullptr );
|
Name *currentName( ddl_nullptr );
|
||||||
Identifier *id( ddl_nullptr );
|
Text *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 );
|
||||||
|
@ -511,7 +512,7 @@ char *OpenDDLParser::parseName( char *in, char *end, Name **name ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OpenDDLParser::parseIdentifier( char *in, char *end, Identifier **id ) {
|
char *OpenDDLParser::parseIdentifier( char *in, char *end, Text **id ) {
|
||||||
*id = ddl_nullptr;
|
*id = ddl_nullptr;
|
||||||
if( ddl_nullptr == in || in == end ) {
|
if( ddl_nullptr == in || in == end ) {
|
||||||
return in;
|
return in;
|
||||||
|
@ -534,7 +535,7 @@ char *OpenDDLParser::parseIdentifier( char *in, char *end, Identifier **id ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t len( idLen );
|
const size_t len( idLen );
|
||||||
Identifier *newId = new Identifier( start, len );
|
Text *newId = new Text( start, len );
|
||||||
*id = newId;
|
*id = newId;
|
||||||
|
|
||||||
return in;
|
return in;
|
||||||
|
@ -715,6 +716,11 @@ char *OpenDDLParser::parseFloatingLiteral( char *in, char *end, Value **floating
|
||||||
|
|
||||||
// parse the float value
|
// parse the float value
|
||||||
bool ok( false );
|
bool ok( false );
|
||||||
|
if ( isHexLiteral( start, end ) ) {
|
||||||
|
parseHexaLiteral( start, end, floating );
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
if( isNumeric( *start ) ) {
|
if( isNumeric( *start ) ) {
|
||||||
ok = true;
|
ok = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -767,7 +773,7 @@ char *OpenDDLParser::parseStringLiteral( char *in, char *end, Value **stringData
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createPropertyWithData( Identifier *id, Value *primData, Property **prop ) {
|
static void createPropertyWithData( Text *id, Value *primData, Property **prop ) {
|
||||||
if( ddl_nullptr != primData ) {
|
if( ddl_nullptr != primData ) {
|
||||||
( *prop ) = new Property( id );
|
( *prop ) = new Property( id );
|
||||||
( *prop )->m_value = primData;
|
( *prop )->m_value = primData;
|
||||||
|
@ -830,7 +836,7 @@ char *OpenDDLParser::parseProperty( char *in, char *end, Property **prop ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
in = lookForNextToken( in, end );
|
in = lookForNextToken( in, end );
|
||||||
Identifier *id( ddl_nullptr );
|
Text *id( ddl_nullptr );
|
||||||
in = parseIdentifier( in, end, &id );
|
in = parseIdentifier( in, end, &id );
|
||||||
if( ddl_nullptr != id ) {
|
if( ddl_nullptr != id ) {
|
||||||
in = lookForNextToken( in, end );
|
in = lookForNextToken( in, end );
|
||||||
|
@ -847,7 +853,7 @@ char *OpenDDLParser::parseProperty( char *in, char *end, Property **prop ) {
|
||||||
} else if( isStringLiteral( *in ) ) { // string data
|
} else if( isStringLiteral( *in ) ) { // string data
|
||||||
in = parseStringLiteral( in, end, &primData );
|
in = parseStringLiteral( in, end, &primData );
|
||||||
createPropertyWithData( id, primData, prop );
|
createPropertyWithData( id, primData, prop );
|
||||||
} else { // reference data
|
} else { // reference data
|
||||||
std::vector<Name*> names;
|
std::vector<Name*> names;
|
||||||
in = parseReference( in, end, names );
|
in = parseReference( in, end, names );
|
||||||
if( !names.empty() ) {
|
if( !names.empty() ) {
|
||||||
|
@ -862,7 +868,8 @@ char *OpenDDLParser::parseProperty( char *in, char *end, Property **prop ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OpenDDLParser::parseDataList( char *in, char *end, Value::ValueType type, Value **data, size_t &numValues, Reference **refs, size_t &numRefs ) {
|
char *OpenDDLParser::parseDataList( char *in, char *end, Value::ValueType type, Value **data,
|
||||||
|
size_t &numValues, Reference **refs, size_t &numRefs ) {
|
||||||
*data = ddl_nullptr;
|
*data = ddl_nullptr;
|
||||||
numValues = numRefs = 0;
|
numValues = numRefs = 0;
|
||||||
if( ddl_nullptr == in || in == end ) {
|
if( ddl_nullptr == in || in == end ) {
|
||||||
|
@ -876,28 +883,24 @@ char *OpenDDLParser::parseDataList( char *in, char *end, Value::ValueType type,
|
||||||
while( '}' != *in ) {
|
while( '}' != *in ) {
|
||||||
current = ddl_nullptr;
|
current = ddl_nullptr;
|
||||||
in = lookForNextToken( in, end );
|
in = lookForNextToken( in, end );
|
||||||
if (Value::ddl_none == type) {
|
if ( Value::ddl_ref == type ) {
|
||||||
|
std::vector<Name*> names;
|
||||||
|
in = parseReference( in, end, names );
|
||||||
|
if ( !names.empty() ) {
|
||||||
|
Reference *ref = new Reference( names.size(), &names[ 0 ] );
|
||||||
|
*refs = ref;
|
||||||
|
numRefs = names.size();
|
||||||
|
}
|
||||||
|
} else if ( Value::ddl_none == type ) {
|
||||||
if (isInteger( in, end )) {
|
if (isInteger( in, end )) {
|
||||||
in = parseIntegerLiteral( in, end, ¤t );
|
in = parseIntegerLiteral( in, end, ¤t );
|
||||||
}
|
} else if (isFloat( in, end )) {
|
||||||
else if (isFloat( in, end )) {
|
|
||||||
in = parseFloatingLiteral( in, end, ¤t );
|
in = parseFloatingLiteral( in, end, ¤t );
|
||||||
}
|
} else if (isStringLiteral( *in )) {
|
||||||
else if (isStringLiteral( *in )) {
|
|
||||||
in = parseStringLiteral( in, end, ¤t );
|
in = parseStringLiteral( in, end, ¤t );
|
||||||
}
|
} else if (isHexLiteral( in, end )) {
|
||||||
else if (isHexLiteral( in, end )) {
|
|
||||||
in = parseHexaLiteral( in, end, ¤t );
|
in = parseHexaLiteral( in, end, ¤t );
|
||||||
}
|
}
|
||||||
else { // reference data
|
|
||||||
std::vector<Name*> names;
|
|
||||||
in = parseReference( in, end, names );
|
|
||||||
if (!names.empty()) {
|
|
||||||
Reference *ref = new Reference( names.size(), &names[ 0 ] );
|
|
||||||
*refs = ref;
|
|
||||||
numRefs = names.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
switch(type){
|
switch(type){
|
||||||
case Value::ddl_int8:
|
case Value::ddl_int8:
|
||||||
|
@ -951,10 +954,10 @@ static DataArrayList *createDataArrayList( Value *currentValue, size_t numValues
|
||||||
dataList->m_numItems = numValues;
|
dataList->m_numItems = numValues;
|
||||||
|
|
||||||
return dataList;
|
return dataList;
|
||||||
|
|
||||||
}
|
}
|
||||||
char *OpenDDLParser::parseDataArrayList( char *in, char *end,Value::ValueType type, DataArrayList **dataList ) {
|
|
||||||
*dataList = ddl_nullptr;
|
char *OpenDDLParser::parseDataArrayList( char *in, char *end,Value::ValueType type, DataArrayList **dataArrayList ) {
|
||||||
|
*dataArrayList = ddl_nullptr;
|
||||||
if( ddl_nullptr == in || in == end ) {
|
if( ddl_nullptr == in || in == end ) {
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
@ -970,10 +973,10 @@ char *OpenDDLParser::parseDataArrayList( char *in, char *end,Value::ValueType ty
|
||||||
currentValue = ddl_nullptr;
|
currentValue = ddl_nullptr;
|
||||||
|
|
||||||
in = parseDataList( in, end, type, ¤tValue, numValues, &refs, numRefs );
|
in = parseDataList( in, end, type, ¤tValue, numValues, &refs, numRefs );
|
||||||
if( ddl_nullptr != currentValue ) {
|
if( ddl_nullptr != currentValue || 0 != numRefs ) {
|
||||||
if( ddl_nullptr == prev ) {
|
if( ddl_nullptr == prev ) {
|
||||||
*dataList = createDataArrayList( currentValue, numValues );
|
*dataArrayList = createDataArrayList( currentValue, numValues );
|
||||||
prev = *dataList;
|
prev = *dataArrayList;
|
||||||
} else {
|
} else {
|
||||||
currentDataList = createDataArrayList( currentValue, numValues );
|
currentDataList = createDataArrayList( currentValue, numValues );
|
||||||
if( ddl_nullptr != prev ) {
|
if( ddl_nullptr != prev ) {
|
||||||
|
|
|
@ -240,10 +240,16 @@ void Value::setDouble( double value ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
double Value::getDouble() const {
|
double Value::getDouble() const {
|
||||||
assert( ddl_double == m_type );
|
if ( m_type == ddl_double ) {
|
||||||
double v;
|
double v;
|
||||||
::memcpy( &v, m_data, m_size );
|
::memcpy( &v, m_data, m_size );
|
||||||
return v;
|
return ( float ) v;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
double tmp;
|
||||||
|
::memcpy( &tmp, m_data, 4 );
|
||||||
|
return ( double ) tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Value::setString( const std::string &str ) {
|
void Value::setString( const std::string &str ) {
|
||||||
|
@ -251,60 +257,88 @@ void Value::setString( const std::string &str ) {
|
||||||
::memcpy( m_data, str.c_str(), str.size() );
|
::memcpy( m_data, str.c_str(), str.size() );
|
||||||
m_data[ str.size() ] = '\0';
|
m_data[ str.size() ] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *Value::getString() const {
|
const char *Value::getString() const {
|
||||||
assert( ddl_string == m_type );
|
assert( ddl_string == m_type );
|
||||||
return (const char*) m_data;
|
return (const char*) m_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Value::setRef( Reference *ref ) {
|
||||||
|
assert( ddl_ref == m_type );
|
||||||
|
|
||||||
|
if ( ddl_nullptr != ref ) {
|
||||||
|
const size_t sizeInBytes( ref->sizeInBytes() );
|
||||||
|
if ( sizeInBytes > 0 ) {
|
||||||
|
if ( ddl_nullptr != m_data ) {
|
||||||
|
delete [] m_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_data = new unsigned char[ sizeof( Reference ) ];
|
||||||
|
Reference *myRef = ( Reference * ) m_data;
|
||||||
|
myRef->m_numRefs = ref->m_numRefs;
|
||||||
|
myRef->m_referencedName = new Name *[ myRef->m_numRefs ];
|
||||||
|
for ( size_t i = 0; i < myRef->m_numRefs; i++ ) {
|
||||||
|
myRef->m_referencedName[ i ] = new Name( ref->m_referencedName[ i ]->m_type, ref->m_referencedName[ i ]->m_id );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference *Value::getRef() const {
|
||||||
|
assert( ddl_ref == m_type );
|
||||||
|
|
||||||
|
return (Reference*) m_data;
|
||||||
|
}
|
||||||
|
|
||||||
void Value::dump() {
|
void Value::dump() {
|
||||||
switch( m_type ) {
|
switch( m_type ) {
|
||||||
case ddl_none:
|
case ddl_none:
|
||||||
std::cout << "None" << std::endl;
|
std::cout << "None" << std::endl;
|
||||||
break;
|
break;
|
||||||
case ddl_bool:
|
case ddl_bool:
|
||||||
std::cout << getBool() << std::endl;
|
std::cout << getBool() << std::endl;
|
||||||
break;
|
break;
|
||||||
case ddl_int8:
|
case ddl_int8:
|
||||||
std::cout << getInt8() << std::endl;
|
std::cout << getInt8() << std::endl;
|
||||||
break;
|
break;
|
||||||
case ddl_int16:
|
case ddl_int16:
|
||||||
std::cout << getInt16() << std::endl;
|
std::cout << getInt16() << std::endl;
|
||||||
break;
|
break;
|
||||||
case ddl_int32:
|
case ddl_int32:
|
||||||
std::cout << getInt32() << std::endl;
|
std::cout << getInt32() << std::endl;
|
||||||
break;
|
break;
|
||||||
case ddl_int64:
|
case ddl_int64:
|
||||||
std::cout << getInt64() << std::endl;
|
std::cout << getInt64() << std::endl;
|
||||||
break;
|
break;
|
||||||
case ddl_unsigned_int8:
|
case ddl_unsigned_int8:
|
||||||
std::cout << "Not supported" << std::endl;
|
std::cout << "Not supported" << std::endl;
|
||||||
break;
|
break;
|
||||||
case ddl_unsigned_int16:
|
case ddl_unsigned_int16:
|
||||||
std::cout << "Not supported" << std::endl;
|
std::cout << "Not supported" << std::endl;
|
||||||
break;
|
break;
|
||||||
case ddl_unsigned_int32:
|
case ddl_unsigned_int32:
|
||||||
std::cout << "Not supported" << std::endl;
|
std::cout << "Not supported" << std::endl;
|
||||||
break;
|
break;
|
||||||
case ddl_unsigned_int64:
|
case ddl_unsigned_int64:
|
||||||
std::cout << "Not supported" << std::endl;
|
std::cout << "Not supported" << std::endl;
|
||||||
break;
|
break;
|
||||||
case ddl_half:
|
case ddl_half:
|
||||||
std::cout << "Not supported" << std::endl;
|
std::cout << "Not supported" << std::endl;
|
||||||
break;
|
break;
|
||||||
case ddl_float:
|
case ddl_float:
|
||||||
std::cout << getFloat() << std::endl;
|
std::cout << getFloat() << std::endl;
|
||||||
break;
|
break;
|
||||||
case ddl_double:
|
case ddl_double:
|
||||||
std::cout << getDouble() << std::endl;
|
std::cout << getDouble() << std::endl;
|
||||||
break;
|
break;
|
||||||
case ddl_string:
|
case ddl_string:
|
||||||
std::cout << "Not supported" << std::endl;
|
std::cout << getString() << std::endl;
|
||||||
break;
|
break;
|
||||||
case ddl_ref:
|
case ddl_ref:
|
||||||
std::cout << "Not supported" << std::endl;
|
std::cout << "Not supported" << std::endl;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,8 +144,8 @@ public:
|
||||||
private:
|
private:
|
||||||
DDLNode( const std::string &type, const std::string &name, size_t idx, DDLNode *parent = ddl_nullptr );
|
DDLNode( const std::string &type, const std::string &name, size_t idx, DDLNode *parent = ddl_nullptr );
|
||||||
DDLNode();
|
DDLNode();
|
||||||
DDLNode( const DDLNode & );
|
DDLNode( const DDLNode & ) ddl_no_copy;
|
||||||
DDLNode &operator = ( const DDLNode & );
|
DDLNode &operator = ( const DDLNode & ) ddl_no_copy;
|
||||||
static void releaseNodes();
|
static void releaseNodes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -32,7 +32,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
# include <inttypes.h>
|
# include <inttypes.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) && !defined( OPENDDL_STATIC_LIBARY )
|
||||||
|
|
||||||
# define TAG_DLL_EXPORT __declspec(dllexport)
|
# define TAG_DLL_EXPORT __declspec(dllexport)
|
||||||
# define TAG_DLL_IMPORT __declspec(dllimport )
|
# define TAG_DLL_IMPORT __declspec(dllimport )
|
||||||
# ifdef OPENDDLPARSER_BUILD
|
# ifdef OPENDDLPARSER_BUILD
|
||||||
|
@ -132,31 +133,6 @@ private:
|
||||||
Text &operator = ( const Text & ) ddl_no_copy;
|
Text &operator = ( const Text & ) ddl_no_copy;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief Stores an OpenDDL-specific identifier type.
|
|
||||||
struct DLL_ODDLPARSER_EXPORT Identifier {
|
|
||||||
Text m_text; ///< The text element.
|
|
||||||
|
|
||||||
/// @brief The constructor with a sized buffer full of characters.
|
|
||||||
/// @param buffer [in] The identifier buffer.
|
|
||||||
/// @param len [in] The length of the buffer
|
|
||||||
Identifier( const char buffer[], size_t len );
|
|
||||||
|
|
||||||
/// @brief The constructor with a buffer full of characters.
|
|
||||||
/// @param buffer [in] The identifier buffer.
|
|
||||||
/// @remark Buffer must be null-terminated.
|
|
||||||
Identifier( const char buffer[] );
|
|
||||||
|
|
||||||
/// @brief The destructor.
|
|
||||||
~Identifier();
|
|
||||||
|
|
||||||
/// @brief The compare operator.
|
|
||||||
bool operator == ( const Identifier &rhs ) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Identifier( const Identifier & ) ddl_no_copy;
|
|
||||||
Identifier &operator = ( const Identifier & ) ddl_no_copy;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @brief Description of the type of a name.
|
/// @brief Description of the type of a name.
|
||||||
enum NameType {
|
enum NameType {
|
||||||
GlobalName, ///< Name is global.
|
GlobalName, ///< Name is global.
|
||||||
|
@ -166,12 +142,12 @@ enum NameType {
|
||||||
/// @brief Stores an OpenDDL-specific name
|
/// @brief Stores an OpenDDL-specific name
|
||||||
struct DLL_ODDLPARSER_EXPORT Name {
|
struct DLL_ODDLPARSER_EXPORT Name {
|
||||||
NameType m_type; ///< The type of the name ( @see NameType ).
|
NameType m_type; ///< The type of the name ( @see NameType ).
|
||||||
Identifier *m_id; ///< The id.
|
Text *m_id; ///< The id.
|
||||||
|
|
||||||
/// @brief The constructor with the type and the id.
|
/// @brief The constructor with the type and the id.
|
||||||
/// @param type [in] The name type.
|
/// @param type [in] The name type.
|
||||||
/// @param id [in] The id.
|
/// @param id [in] The id.
|
||||||
Name( NameType type, Identifier *id );
|
Name( NameType type, Text *id );
|
||||||
|
|
||||||
/// @brief The destructor.
|
/// @brief The destructor.
|
||||||
~Name();
|
~Name();
|
||||||
|
@ -197,6 +173,10 @@ struct DLL_ODDLPARSER_EXPORT Reference {
|
||||||
/// @brief The destructor.
|
/// @brief The destructor.
|
||||||
~Reference();
|
~Reference();
|
||||||
|
|
||||||
|
/// @brief Returns the size in bytes to store one deep reference copy.
|
||||||
|
/// @return The size on bytes.
|
||||||
|
size_t sizeInBytes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Reference( const Reference & ) ddl_no_copy;
|
Reference( const Reference & ) ddl_no_copy;
|
||||||
Reference &operator = ( const Reference & ) ddl_no_copy;
|
Reference &operator = ( const Reference & ) ddl_no_copy;
|
||||||
|
@ -204,7 +184,7 @@ private:
|
||||||
|
|
||||||
/// @brief Stores a property list.
|
/// @brief Stores a property list.
|
||||||
struct DLL_ODDLPARSER_EXPORT Property {
|
struct DLL_ODDLPARSER_EXPORT Property {
|
||||||
Identifier *m_key; ///< The identifier / key of the property.
|
Text *m_key; ///< The identifier / key of the property.
|
||||||
Value *m_value; ///< The value assigned to its key / id ( ddl_nullptr if none ).
|
Value *m_value; ///< The value assigned to its key / id ( ddl_nullptr if none ).
|
||||||
Reference *m_ref; ///< References assigned to its key / id ( ddl_nullptr if none ).
|
Reference *m_ref; ///< References assigned to its key / id ( ddl_nullptr if none ).
|
||||||
Property *m_next; ///< The next property ( ddl_nullptr if none ).
|
Property *m_next; ///< The next property ( ddl_nullptr if none ).
|
||||||
|
@ -214,7 +194,7 @@ struct DLL_ODDLPARSER_EXPORT Property {
|
||||||
|
|
||||||
/// @brief The constructor for initialization.
|
/// @brief The constructor for initialization.
|
||||||
/// @param id [in] The identifier
|
/// @param id [in] The identifier
|
||||||
Property( Identifier *id );
|
Property( Text *id );
|
||||||
|
|
||||||
/// @brief The destructor.
|
/// @brief The destructor.
|
||||||
~Property();
|
~Property();
|
||||||
|
@ -227,7 +207,7 @@ private:
|
||||||
/// @brief Stores a data array list.
|
/// @brief Stores a data array list.
|
||||||
struct DLL_ODDLPARSER_EXPORT DataArrayList {
|
struct DLL_ODDLPARSER_EXPORT DataArrayList {
|
||||||
size_t m_numItems; ///< The number of items in the list.
|
size_t m_numItems; ///< The number of items in the list.
|
||||||
Value *m_dataList; ///< The data list ( ee Value ).
|
Value *m_dataList; ///< The data list ( a Value ).
|
||||||
DataArrayList *m_next; ///< The next data array list ( ddl_nullptr if last ).
|
DataArrayList *m_next; ///< The next data array list ( ddl_nullptr if last ).
|
||||||
|
|
||||||
/// @brief The default constructor for initialization.
|
/// @brief The default constructor for initialization.
|
||||||
|
|
|
@ -93,6 +93,10 @@ protected:
|
||||||
bool writeValue( Value *val, std::string &statement );
|
bool writeValue( Value *val, std::string &statement );
|
||||||
bool writeValueArray( DataArrayList *al, std::string &statement );
|
bool writeValueArray( DataArrayList *al, std::string &statement );
|
||||||
|
|
||||||
|
private:
|
||||||
|
OpenDDLExport( const OpenDDLExport & ) ddl_no_copy;
|
||||||
|
OpenDDLExport &operator = ( const OpenDDLExport & ) ddl_no_copy;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IOStreamBase *m_stream;
|
IOStreamBase *m_stream;
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,9 +63,6 @@ inline
|
||||||
T *getNextToken( T *in, T *end ) {
|
T *getNextToken( T *in, T *end ) {
|
||||||
T *tmp( in );
|
T *tmp( in );
|
||||||
in = lookForNextToken( in, end );
|
in = lookForNextToken( in, end );
|
||||||
/*while( ( isSpace( *in ) || isNewLine( *in ) || ',' == *in ) && ( in != end ) ) {
|
|
||||||
in++;
|
|
||||||
}*/
|
|
||||||
if( tmp == in ) {
|
if( tmp == in ) {
|
||||||
in++;
|
in++;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +100,7 @@ public:
|
||||||
/// @brief The class constructor.
|
/// @brief The class constructor.
|
||||||
/// @param buffer [in] The buffer
|
/// @param buffer [in] The buffer
|
||||||
/// @param len [in] Size of the buffer
|
/// @param len [in] Size of the buffer
|
||||||
OpenDDLParser( char *buffer, size_t len );
|
OpenDDLParser( const char *buffer, size_t len );
|
||||||
|
|
||||||
/// @brief The class destructor.
|
/// @brief The class destructor.
|
||||||
~OpenDDLParser();
|
~OpenDDLParser();
|
||||||
|
@ -119,7 +116,7 @@ public:
|
||||||
/// @brief Assigns a new buffer to parse.
|
/// @brief Assigns a new buffer to parse.
|
||||||
/// @param buffer [in] The buffer
|
/// @param buffer [in] The buffer
|
||||||
/// @param len [in] Size of the buffer
|
/// @param len [in] Size of the buffer
|
||||||
void setBuffer( char *buffer, size_t len );
|
void setBuffer( const char *buffer, size_t len );
|
||||||
|
|
||||||
/// @brief Assigns a new buffer to parse.
|
/// @brief Assigns a new buffer to parse.
|
||||||
/// @param buffer [in] The buffer as a std::vector.
|
/// @param buffer [in] The buffer as a std::vector.
|
||||||
|
@ -161,7 +158,7 @@ public: // parser helpers
|
||||||
DDLNode *top();
|
DDLNode *top();
|
||||||
static void normalizeBuffer( std::vector<char> &buffer );
|
static void normalizeBuffer( std::vector<char> &buffer );
|
||||||
static char *parseName( char *in, char *end, Name **name );
|
static char *parseName( char *in, char *end, Name **name );
|
||||||
static char *parseIdentifier( char *in, char *end, Identifier **id );
|
static char *parseIdentifier( char *in, char *end, Text **id );
|
||||||
static char *parsePrimitiveDataType( char *in, char *end, Value::ValueType &type, size_t &len );
|
static char *parsePrimitiveDataType( char *in, char *end, Value::ValueType &type, size_t &len );
|
||||||
static char *parseReference( char *in, char *end, std::vector<Name*> &names );
|
static char *parseReference( char *in, char *end, std::vector<Name*> &names );
|
||||||
static char *parseBooleanLiteral( char *in, char *end, Value **boolean );
|
static char *parseBooleanLiteral( char *in, char *end, Value **boolean );
|
||||||
|
@ -175,8 +172,8 @@ public: // parser helpers
|
||||||
static const char *getVersion();
|
static const char *getVersion();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OpenDDLParser( const OpenDDLParser & );
|
OpenDDLParser( const OpenDDLParser & ) ddl_no_copy;
|
||||||
OpenDDLParser &operator = ( const OpenDDLParser & );
|
OpenDDLParser &operator = ( const OpenDDLParser & ) ddl_no_copy;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
logCallback m_logCallback;
|
logCallback m_logCallback;
|
||||||
|
|
|
@ -84,12 +84,7 @@ static const unsigned char chartype_table[ 256 ] = {
|
||||||
template<class T>
|
template<class T>
|
||||||
inline
|
inline
|
||||||
bool isNumeric( const T in ) {
|
bool isNumeric( const T in ) {
|
||||||
return ( in >= '0' && in <= '9' );
|
return ( chartype_table[ in ] == 1 );
|
||||||
//return ( chartype_table[in] );
|
|
||||||
/*if (in >= '0' && in <= '9' )
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
@ -243,7 +238,7 @@ bool isComment( T *in, T *end ) {
|
||||||
if ( in+1!=end ) {
|
if ( in+1!=end ) {
|
||||||
if ( *( in+1 )=='/' ) {
|
if ( *( in+1 )=='/' ) {
|
||||||
char *drive( ( in+2 ) );
|
char *drive( ( in+2 ) );
|
||||||
if ( isUpperCase<T>( *drive )||isLowerCase<T>( *drive )&&*( drive+1 )=='/' ) {
|
if ( (isUpperCase<T>( *drive )||isLowerCase<T>( *drive ))&&*( drive+1 )=='/' ) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -220,6 +220,14 @@ public:
|
||||||
/// @return The std::string value.
|
/// @return The std::string value.
|
||||||
const char *getString() const;
|
const char *getString() const;
|
||||||
|
|
||||||
|
/// @brief Set the reference.
|
||||||
|
/// @param ref [in] Pointer showing to the reference.
|
||||||
|
void setRef( Reference *ref );
|
||||||
|
|
||||||
|
/// @brief Returns the pointer showing to the reference.
|
||||||
|
/// @return Pointer showing to the reference.
|
||||||
|
Reference *getRef() const;
|
||||||
|
|
||||||
/// @brief Dumps the value.
|
/// @brief Dumps the value.
|
||||||
void dump();
|
void dump();
|
||||||
|
|
||||||
|
@ -241,8 +249,8 @@ public:
|
||||||
Value *m_next;
|
Value *m_next;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Value &operator =( const Value & );
|
Value &operator =( const Value & ) ddl_no_copy;
|
||||||
Value( const Value & );
|
Value( const Value & ) ddl_no_copy;
|
||||||
};
|
};
|
||||||
|
|
||||||
///------------------------------------------------------------------------------------------------
|
///------------------------------------------------------------------------------------------------
|
||||||
|
@ -253,9 +261,9 @@ struct DLL_ODDLPARSER_EXPORT ValueAllocator {
|
||||||
static void releasePrimData( Value **data );
|
static void releasePrimData( Value **data );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ValueAllocator();
|
ValueAllocator() ddl_no_copy;
|
||||||
ValueAllocator( const ValueAllocator & );
|
ValueAllocator( const ValueAllocator & ) ddl_no_copy;
|
||||||
ValueAllocator &operator = ( const ValueAllocator & );
|
ValueAllocator &operator = ( const ValueAllocator & ) ddl_no_copy;
|
||||||
};
|
};
|
||||||
|
|
||||||
END_ODDLPARSER_NS
|
END_ODDLPARSER_NS
|
||||||
|
|
Loading…
Reference in New Issue