openddl-parser latest greatest

Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>
pull/538/head
Kim Kulling 2015-04-16 11:09:54 +02:00
parent 56e8dc5a43
commit 223a5385af
8 changed files with 65 additions and 23 deletions

View File

@ -1,7 +1,7 @@
/*----------------------------------------------------------------------------------------------- /*-----------------------------------------------------------------------------------------------
The MIT License (MIT) 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 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 this software and associated documentation files (the "Software"), to deal in
@ -138,6 +138,31 @@ Property *DDLNode::getProperties() const {
return m_properties; 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 ) { void DDLNode::setValue( Value *val ) {
m_value = val; m_value = val;
} }

View File

@ -1,7 +1,7 @@
/*----------------------------------------------------------------------------------------------- /*-----------------------------------------------------------------------------------------------
The MIT License (MIT) 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 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 this software and associated documentation files (the "Software"), to deal in

View File

@ -1,7 +1,7 @@
/*----------------------------------------------------------------------------------------------- /*-----------------------------------------------------------------------------------------------
The MIT License (MIT) 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 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 this software and associated documentation files (the "Software"), to deal in

View File

@ -1,7 +1,7 @@
/*----------------------------------------------------------------------------------------------- /*-----------------------------------------------------------------------------------------------
The MIT License (MIT) 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 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 this software and associated documentation files (the "Software"), to deal in
@ -57,6 +57,8 @@ public:
const std::string &getName() const; const std::string &getName() const;
void setProperties( Property *prop ); void setProperties( Property *prop );
Property *getProperties() const; Property *getProperties() const;
bool hasProperty( const std::string &name );
Property *findPropertyByName( const std::string &name );
void setValue( Value *val ); void setValue( Value *val );
Value *getValue() const; Value *getValue() const;
void setDataArrayList( DataArrayList *dtArrayList ); void setDataArrayList( DataArrayList *dtArrayList );

View File

@ -1,7 +1,7 @@
/*----------------------------------------------------------------------------------------------- /*-----------------------------------------------------------------------------------------------
The MIT License (MIT) 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 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 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 #endif // _WIN32
#define BEGIN_ODDLPARSER_NS namespace ODDLParser { #define BEGIN_ODDLPARSER_NS namespace ODDLParser {
#define END_ODDLPARSER_NS } #define END_ODDLPARSER_NS } // namespace ODDLParser
#define USE_ODDLPARSER_NS using namespace ODDLParser; #define USE_ODDLPARSER_NS using namespace ODDLParser;
BEGIN_ODDLPARSER_NS BEGIN_ODDLPARSER_NS
@ -113,6 +113,7 @@ private:
const char *m_token; const char *m_token;
size_t m_size; size_t m_size;
}; };
struct Name { struct Name {
NameType m_type; NameType m_type;
Identifier *m_id; Identifier *m_id;
@ -122,6 +123,10 @@ struct Name {
, m_id( id ) { , m_id( id ) {
// empty // empty
} }
private:
Name( const Name & );
Name &operator = ( const Name& );
}; };
struct Reference { struct Reference {
@ -143,6 +148,10 @@ struct Reference {
m_referencedName[ i ] = name; m_referencedName[ i ] = name;
} }
} }
private:
Reference( const Reference & );
Reference &operator = ( const Reference & );
}; };
struct Identifier { struct Identifier {
@ -154,6 +163,10 @@ struct Identifier {
, m_buffer( buffer ) { , m_buffer( buffer ) {
// empty // empty
} }
private:
Identifier( const Identifier & );
Identifier &operator = ( const Identifier & );
}; };
struct Property { struct Property {
@ -169,6 +182,10 @@ struct Property {
, m_next( ddl_nullptr ) { , m_next( ddl_nullptr ) {
// empty // empty
} }
private:
Property( const Property & );
Property &operator = ( const Property & );
}; };
struct DataArrayList { struct DataArrayList {
@ -182,6 +199,11 @@ struct DataArrayList {
, m_next( ddl_nullptr ) { , m_next( ddl_nullptr ) {
// empty // empty
} }
private:
DataArrayList( const DataArrayList & );
DataArrayList &operator = ( const DataArrayList & );
}; };
struct Context { struct Context {
@ -191,17 +213,10 @@ struct Context {
: m_root( ddl_nullptr ) { : m_root( ddl_nullptr ) {
// empty // empty
} }
};
struct BufferIt { private:
std::vector<char> m_buffer; Context( const Context & );
size_t m_idx; Context &operator = ( const Context & );
BufferIt( const std::vector<char> &buffer )
: m_buffer( buffer )
, m_idx( 0 ) {
// empty
}
}; };
END_ODDLPARSER_NS END_ODDLPARSER_NS

View File

@ -1,7 +1,7 @@
/*----------------------------------------------------------------------------------------------- /*-----------------------------------------------------------------------------------------------
The MIT License (MIT) 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 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 this software and associated documentation files (the "Software"), to deal in

View File

@ -1,7 +1,7 @@
/*----------------------------------------------------------------------------------------------- /*-----------------------------------------------------------------------------------------------
The MIT License (MIT) 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 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 this software and associated documentation files (the "Software"), to deal in

View File

@ -1,7 +1,7 @@
/*----------------------------------------------------------------------------------------------- /*-----------------------------------------------------------------------------------------------
The MIT License (MIT) 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 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 this software and associated documentation files (the "Software"), to deal in