From 223a5385af9f81eaa4e1c1a39d42f28fc20525d3 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 16 Apr 2015 11:09:54 +0200 Subject: [PATCH] openddl-parser latest greatest Signed-off-by: Kim Kulling --- contrib/openddlparser/code/DDLNode.cpp | 27 ++++++++++- contrib/openddlparser/code/OpenDDLParser.cpp | 2 +- contrib/openddlparser/code/Value.cpp | 2 +- .../include/openddlparser/DDLNode.h | 4 +- .../include/openddlparser/OpenDDLCommon.h | 47 ++++++++++++------- .../include/openddlparser/OpenDDLParser.h | 2 +- .../openddlparser/OpenDDLParserUtils.h | 2 +- .../include/openddlparser/Value.h | 2 +- 8 files changed, 65 insertions(+), 23 deletions(-) diff --git a/contrib/openddlparser/code/DDLNode.cpp b/contrib/openddlparser/code/DDLNode.cpp index 24f0da9d1..e57119587 100644 --- a/contrib/openddlparser/code/DDLNode.cpp +++ b/contrib/openddlparser/code/DDLNode.cpp @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------------------------------- The MIT License (MIT) -Copyright (c) 2014 Kim Kulling +Copyright (c) 2014-2015 Kim Kulling Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -138,6 +138,31 @@ Property *DDLNode::getProperties() const { return m_properties; } +bool DDLNode::hasProperty( const std::string &name ) { + const Property *prop( findPropertyByName( name ) ); + return ( ddl_nullptr != prop ); +} + +Property *DDLNode::findPropertyByName( const std::string &name ) { + if( name.empty() ) { + return ddl_nullptr; + } + + if( ddl_nullptr == m_properties ) { + return ddl_nullptr; + } + Property *current( m_properties ); + while( ddl_nullptr != current ) { + int res = strncmp( current->m_id->m_buffer, name.c_str(), name.size() ); + if( 0 == res ) { + return current; + } + current = current->m_next; + } + + return ddl_nullptr; +} + void DDLNode::setValue( Value *val ) { m_value = val; } diff --git a/contrib/openddlparser/code/OpenDDLParser.cpp b/contrib/openddlparser/code/OpenDDLParser.cpp index c1b36620c..3587dcb6f 100644 --- a/contrib/openddlparser/code/OpenDDLParser.cpp +++ b/contrib/openddlparser/code/OpenDDLParser.cpp @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------------------------------- The MIT License (MIT) -Copyright (c) 2014 Kim Kulling +Copyright (c) 2014-2015 Kim Kulling Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/contrib/openddlparser/code/Value.cpp b/contrib/openddlparser/code/Value.cpp index c815d52a2..39f4c32b7 100644 --- a/contrib/openddlparser/code/Value.cpp +++ b/contrib/openddlparser/code/Value.cpp @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------------------------------- The MIT License (MIT) -Copyright (c) 2014 Kim Kulling +Copyright (c) 2014-2015 Kim Kulling Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/contrib/openddlparser/include/openddlparser/DDLNode.h b/contrib/openddlparser/include/openddlparser/DDLNode.h index 93b447bb2..5ecf41e9a 100644 --- a/contrib/openddlparser/include/openddlparser/DDLNode.h +++ b/contrib/openddlparser/include/openddlparser/DDLNode.h @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------------------------------- The MIT License (MIT) -Copyright (c) 2014 Kim Kulling +Copyright (c) 2014-2015 Kim Kulling Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -57,6 +57,8 @@ public: const std::string &getName() const; void setProperties( Property *prop ); Property *getProperties() const; + bool hasProperty( const std::string &name ); + Property *findPropertyByName( const std::string &name ); void setValue( Value *val ); Value *getValue() const; void setDataArrayList( DataArrayList *dtArrayList ); diff --git a/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h b/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h index a42fbcf59..ab6d003b3 100644 --- a/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h +++ b/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------------------------------- The MIT License (MIT) -Copyright (c) 2014 Kim Kulling +Copyright (c) 2014-2015 Kim Kulling Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in @@ -43,7 +43,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif // _WIN32 #define BEGIN_ODDLPARSER_NS namespace ODDLParser { -#define END_ODDLPARSER_NS } +#define END_ODDLPARSER_NS } // namespace ODDLParser #define USE_ODDLPARSER_NS using namespace ODDLParser; BEGIN_ODDLPARSER_NS @@ -63,10 +63,10 @@ struct Reference; struct Property; struct DataArrayList; -typedef char int8; -typedef short int16; -typedef int int32; -typedef long int64; +typedef char int8; +typedef short int16; +typedef int int32; +typedef long int64; typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; @@ -113,6 +113,7 @@ private: const char *m_token; size_t m_size; }; + struct Name { NameType m_type; Identifier *m_id; @@ -122,6 +123,10 @@ struct Name { , m_id( id ) { // empty } + +private: + Name( const Name & ); + Name &operator = ( const Name& ); }; struct Reference { @@ -143,6 +148,10 @@ struct Reference { m_referencedName[ i ] = name; } } + +private: + Reference( const Reference & ); + Reference &operator = ( const Reference & ); }; struct Identifier { @@ -154,6 +163,10 @@ struct Identifier { , m_buffer( buffer ) { // empty } + +private: + Identifier( const Identifier & ); + Identifier &operator = ( const Identifier & ); }; struct Property { @@ -169,6 +182,10 @@ struct Property { , m_next( ddl_nullptr ) { // empty } + +private: + Property( const Property & ); + Property &operator = ( const Property & ); }; struct DataArrayList { @@ -182,6 +199,11 @@ struct DataArrayList { , m_next( ddl_nullptr ) { // empty } + +private: + DataArrayList( const DataArrayList & ); + DataArrayList &operator = ( const DataArrayList & ); + }; struct Context { @@ -191,17 +213,10 @@ struct Context { : m_root( ddl_nullptr ) { // empty } -}; -struct BufferIt { - std::vector m_buffer; - size_t m_idx; - - BufferIt( const std::vector &buffer ) - : m_buffer( buffer ) - , m_idx( 0 ) { - // empty - } +private: + Context( const Context & ); + Context &operator = ( const Context & ); }; END_ODDLPARSER_NS diff --git a/contrib/openddlparser/include/openddlparser/OpenDDLParser.h b/contrib/openddlparser/include/openddlparser/OpenDDLParser.h index 068c028b7..3ba68370f 100644 --- a/contrib/openddlparser/include/openddlparser/OpenDDLParser.h +++ b/contrib/openddlparser/include/openddlparser/OpenDDLParser.h @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------------------------------- The MIT License (MIT) -Copyright (c) 2014 Kim Kulling +Copyright (c) 2014-2015 Kim Kulling Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h b/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h index a4c0f2180..ef8d1dceb 100644 --- a/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h +++ b/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------------------------------- The MIT License (MIT) -Copyright (c) 2014 Kim Kulling +Copyright (c) 2014-2015 Kim Kulling Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/contrib/openddlparser/include/openddlparser/Value.h b/contrib/openddlparser/include/openddlparser/Value.h index a11b823a3..bb974fb74 100644 --- a/contrib/openddlparser/include/openddlparser/Value.h +++ b/contrib/openddlparser/include/openddlparser/Value.h @@ -1,7 +1,7 @@ /*----------------------------------------------------------------------------------------------- The MIT License (MIT) -Copyright (c) 2014 Kim Kulling +Copyright (c) 2014-2015 Kim Kulling Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in