- fix invalid value get for index data.
- update OpenDDL-library
pull/789/head
Kim Kulling 2016-02-07 17:58:28 +01:00
parent 7961c22c55
commit 522f4e0882
17 changed files with 280 additions and 228 deletions

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2014, assimp team
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2014, assimp team
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2014, assimp team
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@ -225,6 +225,7 @@ OpenGEXImporter::OpenGEXImporter()
, m_tokenType( Grammar::NoneType )
, m_nodeStack()
, 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++ ) {
Name *currentName( ref->m_referencedName[ i ] );
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() ) {
names.push_back( name );
}
@ -541,7 +542,7 @@ static void propId2StdString( Property *prop, std::string &name, std::string &ke
}
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 ) {
key = prop->m_value->getString();
}
@ -714,7 +715,7 @@ void OpenGEXImporter::handleIndexArrayNode( ODDLParser::DDLNode *node, aiScene *
current.mIndices = new unsigned int[ current.mNumIndices ];
Value *next( vaList->m_dataList );
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 );
aiVector3D &pos = ( m_currentVertices.m_vertices[ idx ] );
@ -758,12 +759,16 @@ enum ColorType {
};
//------------------------------------------------------------------------------------------------
static ColorType getColorType( Identifier *id ) {
if( id->m_text == Grammar::DiffuseColorToken ) {
static ColorType getColorType( Text *id ) {
if ( NULL == id ) {
return NoneColor;
}
if( *id == Grammar::DiffuseColorToken ) {
return DiffuseColor;
} else if( id->m_text == Grammar::SpecularColorToken ) {
} else if( *id == Grammar::SpecularColorToken ) {
return SpecularColor;
} else if( id->m_text == Grammar::EmissionColorToken ) {
} else if( *id == Grammar::EmissionColorToken ) {
return EmissionColor;
}

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2014, assimp team
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,

View File

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2014, assimp team
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,

View File

@ -1,29 +1,39 @@
The OpenDDL-Parser
==================
A simple and fast OpenDDL Parser
Current build status: [![Build Status](https://travis-ci.org/kimkulling/openddl-parser.png)](https://travis-ci.org/kimkulling/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.
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
===================
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
Build from 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.
After installing it you can open a console and type:
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 tool-chain is installed on your machine.
After installing it you can open a console and enter:
> 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:
> make
and that's all.
When using Visual Studio CMake will generate you a solution for ythe library. Just build it there.
Use the library
===============
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
===============================
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;
theParser.setBuffer( buffer, size );
const bool result( theParser.parse() );
if ( result ) {
DDLNode *root = theParser.getRoot();
DDLNode::DllNodeList childs = root->getChildNodeList();
for ( size_t i=0; i<childs.size(); i++ ) {
DDLNode *child = childs[ i ];
Property *prop = child->getProperty(); // to get properties
std:.string type = child->getType(); // to get the node type
Value *values = child->getValue(); // to get the data;
Property *prop = child->getProperty(); // to get properties
std::string type = child->getType(); // to get the node type
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 .

View File

@ -153,7 +153,7 @@ Property *DDLNode::findPropertyByName( const std::string &name ) {
Property *current( m_properties );
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 ) {
return current;
}

View File

@ -73,31 +73,14 @@ bool Text::operator == ( const Text &rhs ) const {
return ( 0 == res );
}
Identifier::Identifier( const char buffer[], size_t len )
: 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 )
Name::Name( NameType type, Text *id )
: m_type( type )
, m_id( id ) {
// empty
}
Name::~Name() {
delete m_id;
m_id = ddl_nullptr;
}
@ -110,10 +93,12 @@ Reference::Reference()
Reference::Reference( size_t numrefs, Name **names )
: m_numRefs( numrefs )
, m_referencedName( ddl_nullptr ) {
m_referencedName = new Name *[ numrefs ];
for( size_t i = 0; i < numrefs; i++ ) {
Name *name = new Name( names[ i ]->m_type, names[ i ]->m_id );
m_referencedName[ i ] = name;
if ( numrefs > 0 ) {
m_referencedName = new Name *[ numrefs ];
for ( size_t i = 0; i < numrefs; i++ ) {
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;
}
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_value( ddl_nullptr )
, m_ref( ddl_nullptr )
@ -152,7 +153,7 @@ DataArrayList::~DataArrayList() {
}
size_t DataArrayList::size() {
size_t result=1;
size_t result( 0 );
DataArrayList *n=m_next;
while( n!=ddl_nullptr ) {
result++;
@ -167,7 +168,7 @@ Context::Context()
}
Context::~Context() {
m_root = ddl_nullptr;
clear();
}
void Context::clear() {

View File

@ -256,7 +256,7 @@ bool OpenDDLExport::writeProperties( DDLNode *node, std::string &statement ) {
} else {
first = false;
}
statement += std::string( prop->m_key->m_text.m_buffer );
statement += std::string( prop->m_key->m_buffer );
statement += " = ";
writeValue( prop->m_value, statement );
prop = prop->m_next;

View File

@ -97,12 +97,12 @@ static bool isUnsignedIntegerType( Value::ValueType integerType ) {
return true;
}
static DDLNode *createDDLNode( Identifier *id, OpenDDLParser *parser ) {
static DDLNode *createDDLNode( Text *id, OpenDDLParser *parser ) {
if( ddl_nullptr == id || ddl_nullptr == parser ) {
return ddl_nullptr;
}
const std::string type( id->m_text.m_buffer );
const std::string type( id->m_buffer );
DDLNode *parent( parser->top() );
DDLNode *node = DDLNode::create( type, "", parent );
@ -135,7 +135,7 @@ OpenDDLParser::OpenDDLParser()
// empty
}
OpenDDLParser::OpenDDLParser( char *buffer, size_t len )
OpenDDLParser::OpenDDLParser( const char *buffer, size_t len )
: m_logCallback( &logMessage )
, m_buffer()
, m_context( ddl_nullptr ) {
@ -162,7 +162,7 @@ OpenDDLParser::logCallback OpenDDLParser::getLogCallback() const {
return m_logCallback;
}
void OpenDDLParser::setBuffer( char *buffer, size_t len ) {
void OpenDDLParser::setBuffer( const char *buffer, size_t len ) {
clear();
if( 0 == len ) {
return;
@ -192,7 +192,7 @@ size_t OpenDDLParser::getBufferSize() const {
void OpenDDLParser::clear() {
m_buffer.resize( 0 );
if( m_context ) {
if( ddl_nullptr != m_context ) {
m_context->m_root = ddl_nullptr;
}
@ -255,7 +255,7 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) {
return in;
}
Identifier *id( ddl_nullptr );
Text *id( ddl_nullptr );
in = OpenDDLParser::parseIdentifier( in, end, &id );
#ifdef DEBUG_HEADER_NAME
@ -263,33 +263,7 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) {
#endif // DEBUG_HEADER_NAME
in = lookForNextToken( in, end );
Property *first( ddl_nullptr );
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
DDLNode *node( createDDLNode( id, this ) );
if( ddl_nullptr != node ) {
@ -298,17 +272,44 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) {
std::cerr << "nullptr returned by creating DDLNode." << std::endl;
}
// set the properties
if( ddl_nullptr != first && ddl_nullptr != node ) {
node->setProperties( first );
}
Name *name( ddl_nullptr );
in = OpenDDLParser::parseName( in, end, &name );
Name *name(ddl_nullptr);
in = OpenDDLParser::parseName(in, end, &name);
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 );
}
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;
@ -499,7 +500,7 @@ char *OpenDDLParser::parseName( char *in, char *end, Name **name ) {
}
in++;
Name *currentName( ddl_nullptr );
Identifier *id( ddl_nullptr );
Text *id( ddl_nullptr );
in = parseIdentifier( in, end, &id );
if( id ) {
currentName = new Name( ntype, id );
@ -511,7 +512,7 @@ char *OpenDDLParser::parseName( char *in, char *end, Name **name ) {
return in;
}
char *OpenDDLParser::parseIdentifier( char *in, char *end, Identifier **id ) {
char *OpenDDLParser::parseIdentifier( char *in, char *end, Text **id ) {
*id = ddl_nullptr;
if( ddl_nullptr == in || in == end ) {
return in;
@ -534,7 +535,7 @@ char *OpenDDLParser::parseIdentifier( char *in, char *end, Identifier **id ) {
}
const size_t len( idLen );
Identifier *newId = new Identifier( start, len );
Text *newId = new Text( start, len );
*id = newId;
return in;
@ -715,6 +716,11 @@ char *OpenDDLParser::parseFloatingLiteral( char *in, char *end, Value **floating
// parse the float value
bool ok( false );
if ( isHexLiteral( start, end ) ) {
parseHexaLiteral( start, end, floating );
return in;
}
if( isNumeric( *start ) ) {
ok = true;
} else {
@ -767,7 +773,7 @@ char *OpenDDLParser::parseStringLiteral( char *in, char *end, Value **stringData
return in;
}
static void createPropertyWithData( Identifier *id, Value *primData, Property **prop ) {
static void createPropertyWithData( Text *id, Value *primData, Property **prop ) {
if( ddl_nullptr != primData ) {
( *prop ) = new Property( id );
( *prop )->m_value = primData;
@ -830,7 +836,7 @@ char *OpenDDLParser::parseProperty( char *in, char *end, Property **prop ) {
}
in = lookForNextToken( in, end );
Identifier *id( ddl_nullptr );
Text *id( ddl_nullptr );
in = parseIdentifier( in, end, &id );
if( ddl_nullptr != id ) {
in = lookForNextToken( in, end );
@ -847,7 +853,7 @@ char *OpenDDLParser::parseProperty( char *in, char *end, Property **prop ) {
} else if( isStringLiteral( *in ) ) { // string data
in = parseStringLiteral( in, end, &primData );
createPropertyWithData( id, primData, prop );
} else { // reference data
} else { // reference data
std::vector<Name*> names;
in = parseReference( in, end, names );
if( !names.empty() ) {
@ -862,7 +868,8 @@ char *OpenDDLParser::parseProperty( char *in, char *end, Property **prop ) {
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;
numValues = numRefs = 0;
if( ddl_nullptr == in || in == end ) {
@ -876,28 +883,24 @@ char *OpenDDLParser::parseDataList( char *in, char *end, Value::ValueType type,
while( '}' != *in ) {
current = ddl_nullptr;
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 )) {
in = parseIntegerLiteral( in, end, &current );
}
else if (isFloat( in, end )) {
} else if (isFloat( in, end )) {
in = parseFloatingLiteral( in, end, &current );
}
else if (isStringLiteral( *in )) {
} else if (isStringLiteral( *in )) {
in = parseStringLiteral( in, end, &current );
}
else if (isHexLiteral( in, end )) {
} else if (isHexLiteral( in, end )) {
in = parseHexaLiteral( in, end, &current );
}
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 {
switch(type){
case Value::ddl_int8:
@ -951,10 +954,10 @@ static DataArrayList *createDataArrayList( Value *currentValue, size_t numValues
dataList->m_numItems = numValues;
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 ) {
return in;
}
@ -970,10 +973,10 @@ char *OpenDDLParser::parseDataArrayList( char *in, char *end,Value::ValueType ty
currentValue = ddl_nullptr;
in = parseDataList( in, end, type, &currentValue, numValues, &refs, numRefs );
if( ddl_nullptr != currentValue ) {
if( ddl_nullptr != currentValue || 0 != numRefs ) {
if( ddl_nullptr == prev ) {
*dataList = createDataArrayList( currentValue, numValues );
prev = *dataList;
*dataArrayList = createDataArrayList( currentValue, numValues );
prev = *dataArrayList;
} else {
currentDataList = createDataArrayList( currentValue, numValues );
if( ddl_nullptr != prev ) {

View File

@ -240,10 +240,16 @@ void Value::setDouble( double value ) {
}
double Value::getDouble() const {
assert( ddl_double == m_type );
double v;
::memcpy( &v, m_data, m_size );
return v;
if ( m_type == ddl_double ) {
double v;
::memcpy( &v, m_data, m_size );
return ( float ) v;
}
else {
double tmp;
::memcpy( &tmp, m_data, 4 );
return ( double ) tmp;
}
}
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() );
m_data[ str.size() ] = '\0';
}
const char *Value::getString() const {
assert( ddl_string == m_type );
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() {
switch( m_type ) {
case ddl_none:
std::cout << "None" << std::endl;
break;
case ddl_bool:
std::cout << getBool() << std::endl;
break;
case ddl_int8:
std::cout << getInt8() << std::endl;
break;
case ddl_int16:
std::cout << getInt16() << std::endl;
break;
case ddl_int32:
std::cout << getInt32() << std::endl;
break;
case ddl_int64:
std::cout << getInt64() << std::endl;
break;
case ddl_unsigned_int8:
std::cout << "Not supported" << std::endl;
break;
case ddl_unsigned_int16:
std::cout << "Not supported" << std::endl;
break;
case ddl_unsigned_int32:
std::cout << "Not supported" << std::endl;
break;
case ddl_unsigned_int64:
std::cout << "Not supported" << std::endl;
break;
case ddl_half:
std::cout << "Not supported" << std::endl;
break;
case ddl_float:
std::cout << getFloat() << std::endl;
break;
case ddl_double:
std::cout << getDouble() << std::endl;
break;
case ddl_string:
std::cout << "Not supported" << std::endl;
break;
case ddl_ref:
std::cout << "Not supported" << std::endl;
break;
default:
break;
case ddl_none:
std::cout << "None" << std::endl;
break;
case ddl_bool:
std::cout << getBool() << std::endl;
break;
case ddl_int8:
std::cout << getInt8() << std::endl;
break;
case ddl_int16:
std::cout << getInt16() << std::endl;
break;
case ddl_int32:
std::cout << getInt32() << std::endl;
break;
case ddl_int64:
std::cout << getInt64() << std::endl;
break;
case ddl_unsigned_int8:
std::cout << "Not supported" << std::endl;
break;
case ddl_unsigned_int16:
std::cout << "Not supported" << std::endl;
break;
case ddl_unsigned_int32:
std::cout << "Not supported" << std::endl;
break;
case ddl_unsigned_int64:
std::cout << "Not supported" << std::endl;
break;
case ddl_half:
std::cout << "Not supported" << std::endl;
break;
case ddl_float:
std::cout << getFloat() << std::endl;
break;
case ddl_double:
std::cout << getDouble() << std::endl;
break;
case ddl_string:
std::cout << getString() << std::endl;
break;
case ddl_ref:
std::cout << "Not supported" << std::endl;
break;
default:
break;
}
}

View File

@ -144,8 +144,8 @@ public:
private:
DDLNode( const std::string &type, const std::string &name, size_t idx, DDLNode *parent = ddl_nullptr );
DDLNode();
DDLNode( const DDLNode & );
DDLNode &operator = ( const DDLNode & );
DDLNode( const DDLNode & ) ddl_no_copy;
DDLNode &operator = ( const DDLNode & ) ddl_no_copy;
static void releaseNodes();
private:

View File

@ -32,7 +32,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# include <inttypes.h>
#endif
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined( OPENDDL_STATIC_LIBARY )
# define TAG_DLL_EXPORT __declspec(dllexport)
# define TAG_DLL_IMPORT __declspec(dllimport )
# ifdef OPENDDLPARSER_BUILD
@ -132,31 +133,6 @@ private:
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.
enum NameType {
GlobalName, ///< Name is global.
@ -166,12 +142,12 @@ enum NameType {
/// @brief Stores an OpenDDL-specific name
struct DLL_ODDLPARSER_EXPORT Name {
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.
/// @param type [in] The name type.
/// @param id [in] The id.
Name( NameType type, Identifier *id );
Name( NameType type, Text *id );
/// @brief The destructor.
~Name();
@ -197,6 +173,10 @@ struct DLL_ODDLPARSER_EXPORT Reference {
/// @brief The destructor.
~Reference();
/// @brief Returns the size in bytes to store one deep reference copy.
/// @return The size on bytes.
size_t sizeInBytes();
private:
Reference( const Reference & ) ddl_no_copy;
Reference &operator = ( const Reference & ) ddl_no_copy;
@ -204,7 +184,7 @@ private:
/// @brief Stores a property list.
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 ).
Reference *m_ref; ///< References assigned to its key / id ( 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.
/// @param id [in] The identifier
Property( Identifier *id );
Property( Text *id );
/// @brief The destructor.
~Property();
@ -227,7 +207,7 @@ private:
/// @brief Stores a data array list.
struct DLL_ODDLPARSER_EXPORT DataArrayList {
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 ).
/// @brief The default constructor for initialization.

View File

@ -93,6 +93,10 @@ protected:
bool writeValue( Value *val, 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:
IOStreamBase *m_stream;
};

View File

@ -63,9 +63,6 @@ inline
T *getNextToken( T *in, T *end ) {
T *tmp( in );
in = lookForNextToken( in, end );
/*while( ( isSpace( *in ) || isNewLine( *in ) || ',' == *in ) && ( in != end ) ) {
in++;
}*/
if( tmp == in ) {
in++;
}
@ -103,7 +100,7 @@ public:
/// @brief The class constructor.
/// @param buffer [in] 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.
~OpenDDLParser();
@ -119,7 +116,7 @@ public:
/// @brief Assigns a new buffer to parse.
/// @param buffer [in] 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.
/// @param buffer [in] The buffer as a std::vector.
@ -161,7 +158,7 @@ public: // parser helpers
DDLNode *top();
static void normalizeBuffer( std::vector<char> &buffer );
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 *parseReference( char *in, char *end, std::vector<Name*> &names );
static char *parseBooleanLiteral( char *in, char *end, Value **boolean );
@ -175,8 +172,8 @@ public: // parser helpers
static const char *getVersion();
private:
OpenDDLParser( const OpenDDLParser & );
OpenDDLParser &operator = ( const OpenDDLParser & );
OpenDDLParser( const OpenDDLParser & ) ddl_no_copy;
OpenDDLParser &operator = ( const OpenDDLParser & ) ddl_no_copy;
private:
logCallback m_logCallback;

View File

@ -84,12 +84,7 @@ static const unsigned char chartype_table[ 256 ] = {
template<class T>
inline
bool isNumeric( const T in ) {
return ( in >= '0' && in <= '9' );
//return ( chartype_table[in] );
/*if (in >= '0' && in <= '9' )
return true;
return false;*/
return ( chartype_table[ in ] == 1 );
}
template<class T>
@ -243,7 +238,7 @@ bool isComment( T *in, T *end ) {
if ( in+1!=end ) {
if ( *( in+1 )=='/' ) {
char *drive( ( in+2 ) );
if ( isUpperCase<T>( *drive )||isLowerCase<T>( *drive )&&*( drive+1 )=='/' ) {
if ( (isUpperCase<T>( *drive )||isLowerCase<T>( *drive ))&&*( drive+1 )=='/' ) {
return false;
} else {
return true;

View File

@ -220,6 +220,14 @@ public:
/// @return The std::string value.
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.
void dump();
@ -241,8 +249,8 @@ public:
Value *m_next;
private:
Value &operator =( const Value & );
Value( const Value & );
Value &operator =( const Value & ) ddl_no_copy;
Value( const Value & ) ddl_no_copy;
};
///------------------------------------------------------------------------------------------------
@ -253,9 +261,9 @@ struct DLL_ODDLPARSER_EXPORT ValueAllocator {
static void releasePrimData( Value **data );
private:
ValueAllocator();
ValueAllocator( const ValueAllocator & );
ValueAllocator &operator = ( const ValueAllocator & );
ValueAllocator() ddl_no_copy;
ValueAllocator( const ValueAllocator & ) ddl_no_copy;
ValueAllocator &operator = ( const ValueAllocator & ) ddl_no_copy;
};
END_ODDLPARSER_NS