|
@@ -56,10 +56,11 @@ BEGIN_ODDLPARSER_NS
|
|
// All C++11 constructs
|
|
// All C++11 constructs
|
|
# define ddl_nullptr nullptr
|
|
# define ddl_nullptr nullptr
|
|
#else
|
|
#else
|
|
- // Fallback for older compilers
|
|
|
|
|
|
+ // Fall-back for older compilers
|
|
# define ddl_nullptr NULL
|
|
# define ddl_nullptr NULL
|
|
#endif // OPENDDL_NO_USE_CPP11
|
|
#endif // OPENDDL_NO_USE_CPP11
|
|
|
|
|
|
|
|
+// Forward declarations
|
|
class DDLNode;
|
|
class DDLNode;
|
|
class Value;
|
|
class Value;
|
|
|
|
|
|
@@ -69,6 +70,7 @@ struct Reference;
|
|
struct Property;
|
|
struct Property;
|
|
struct DataArrayList;
|
|
struct DataArrayList;
|
|
|
|
|
|
|
|
+// Platform-specific typedefs
|
|
#ifdef _WIN32
|
|
#ifdef _WIN32
|
|
typedef signed __int64 int64_impl;
|
|
typedef signed __int64 int64_impl;
|
|
typedef unsigned __int64 uint64_impl;
|
|
typedef unsigned __int64 uint64_impl;
|
|
@@ -87,65 +89,36 @@ typedef unsigned short uint16; ///< Unsigned integer, 2 byte
|
|
typedef unsigned int uint32; ///< Unsigned integer, 4 byte
|
|
typedef unsigned int uint32; ///< Unsigned integer, 4 byte
|
|
typedef uint64_impl uint64; ///< Unsigned integer, 8 byte
|
|
typedef uint64_impl uint64; ///< Unsigned integer, 8 byte
|
|
|
|
|
|
-/// @brief Description of the type of a name.
|
|
|
|
-enum NameType {
|
|
|
|
- GlobalName, ///< Name is global.
|
|
|
|
- LocalName ///< Name is local.
|
|
|
|
-};
|
|
|
|
|
|
+/// @brief Stores a text.
|
|
|
|
+///
|
|
|
|
+/// A text is stored in a simple character buffer. Texts buffer can be
|
|
|
|
+/// greater than the number of stored characters in them.
|
|
|
|
+struct DLL_ODDLPARSER_EXPORT Text {
|
|
|
|
+ size_t m_capacity; ///< The capacity of the text.
|
|
|
|
+ size_t m_len; ///< The length of the text.
|
|
|
|
+ char *m_buffer; ///< The buffer with the text.
|
|
|
|
+
|
|
|
|
+ /// @brief The constructor with a given text buffer.
|
|
|
|
+ /// @param buffer [in] The buffer.
|
|
|
|
+ /// @param numChars [in] The number of characters in the buffer.
|
|
|
|
+ Text( const char *buffer, size_t numChars );
|
|
|
|
+
|
|
|
|
+ /// @brief The destructor.
|
|
|
|
+ ~Text();
|
|
|
|
|
|
-/// @brief Stores a text
|
|
|
|
-struct Text {
|
|
|
|
- size_t m_capacity;
|
|
|
|
- size_t m_len;
|
|
|
|
- char *m_buffer;
|
|
|
|
-
|
|
|
|
- Text( const char *buffer, size_t numChars )
|
|
|
|
- : m_capacity( 0 )
|
|
|
|
- , m_len( 0 )
|
|
|
|
- , m_buffer( ddl_nullptr ) {
|
|
|
|
- set( buffer, numChars );
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ~Text() {
|
|
|
|
- clear();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- void clear() {
|
|
|
|
- delete[] m_buffer;
|
|
|
|
- m_buffer = ddl_nullptr;
|
|
|
|
- m_capacity = 0;
|
|
|
|
- m_len = 0;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- void set( const char *buffer, size_t numChars ) {
|
|
|
|
- clear();
|
|
|
|
- if( numChars > 0 ) {
|
|
|
|
- m_len = numChars;
|
|
|
|
- m_capacity = m_len + 1;
|
|
|
|
- m_buffer = new char[ m_capacity ];
|
|
|
|
- strncpy( m_buffer, buffer, numChars );
|
|
|
|
- m_buffer[ numChars ] = '\0';
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- bool operator == ( const std::string &name ) const {
|
|
|
|
- if( m_len != name.size() ) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- const int res( strncmp( m_buffer, name.c_str(), name.size() ) );
|
|
|
|
-
|
|
|
|
- return ( 0 == res );
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- bool operator == ( const Text &rhs ) const {
|
|
|
|
- if( m_len != rhs.m_len ) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- const int res( strncmp( m_buffer, rhs.m_buffer, m_len ) );
|
|
|
|
-
|
|
|
|
- return ( 0 == res );
|
|
|
|
- }
|
|
|
|
|
|
+ /// @brief Clears the text.
|
|
|
|
+ void clear();
|
|
|
|
+
|
|
|
|
+ /// @brief Set a new text.
|
|
|
|
+ /// @param buffer [in] The buffer.
|
|
|
|
+ /// @param numChars [in] The number of characters in the buffer.
|
|
|
|
+ void set( const char *buffer, size_t numChars );
|
|
|
|
+
|
|
|
|
+ /// @brief The compare operator for std::strings.
|
|
|
|
+ bool operator == ( const std::string &name ) const;
|
|
|
|
+
|
|
|
|
+ /// @brief The compare operator for Texts.
|
|
|
|
+ bool operator == ( const Text &rhs ) const;
|
|
|
|
|
|
private:
|
|
private:
|
|
Text( const Text & );
|
|
Text( const Text & );
|
|
@@ -153,38 +126,48 @@ private:
|
|
};
|
|
};
|
|
|
|
|
|
/// @brief Stores an OpenDDL-specific identifier type.
|
|
/// @brief Stores an OpenDDL-specific identifier type.
|
|
-struct Identifier {
|
|
|
|
- Text m_text;
|
|
|
|
|
|
+struct DLL_ODDLPARSER_EXPORT Identifier {
|
|
|
|
+ Text m_text; ///< The text element.
|
|
|
|
|
|
- Identifier( char buffer[], size_t len )
|
|
|
|
- : m_text( buffer, len ) {
|
|
|
|
- // empty
|
|
|
|
- }
|
|
|
|
|
|
+ /// @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 );
|
|
|
|
|
|
- Identifier( char buffer[] )
|
|
|
|
- : m_text( buffer, strlen( buffer ) ) {
|
|
|
|
- // empty
|
|
|
|
- }
|
|
|
|
|
|
+ /// @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[] );
|
|
|
|
|
|
- bool operator == ( const Identifier &rhs ) const {
|
|
|
|
- return m_text == rhs.m_text;
|
|
|
|
- }
|
|
|
|
|
|
+ /// @brief The destructor.
|
|
|
|
+ ~Identifier();
|
|
|
|
+
|
|
|
|
+ /// @brief The compare operator.
|
|
|
|
+ bool operator == ( const Identifier &rhs ) const;
|
|
|
|
|
|
private:
|
|
private:
|
|
Identifier( const Identifier & );
|
|
Identifier( const Identifier & );
|
|
Identifier &operator = ( const Identifier & );
|
|
Identifier &operator = ( const Identifier & );
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+/// @brief Description of the type of a name.
|
|
|
|
+enum NameType {
|
|
|
|
+ GlobalName, ///< Name is global.
|
|
|
|
+ LocalName ///< Name is local.
|
|
|
|
+};
|
|
|
|
+
|
|
/// @brief Stores an OpenDDL-specific name
|
|
/// @brief Stores an OpenDDL-specific name
|
|
-struct Name {
|
|
|
|
- NameType m_type;
|
|
|
|
- Identifier *m_id;
|
|
|
|
|
|
+struct DLL_ODDLPARSER_EXPORT Name {
|
|
|
|
+ NameType m_type; ///< The type of the name ( @see NameType ).
|
|
|
|
+ Identifier *m_id; ///< The id.
|
|
|
|
|
|
- Name( NameType type, Identifier *id )
|
|
|
|
- : m_type( type )
|
|
|
|
- , m_id( id ) {
|
|
|
|
- // empty
|
|
|
|
- }
|
|
|
|
|
|
+ /// @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 );
|
|
|
|
+
|
|
|
|
+ /// @brief The destructor.
|
|
|
|
+ ~Name();
|
|
|
|
|
|
private:
|
|
private:
|
|
Name( const Name & );
|
|
Name( const Name & );
|
|
@@ -192,33 +175,20 @@ private:
|
|
};
|
|
};
|
|
|
|
|
|
/// @brief Stores a bundle of references.
|
|
/// @brief Stores a bundle of references.
|
|
-struct Reference {
|
|
|
|
- size_t m_numRefs;
|
|
|
|
- Name **m_referencedName;
|
|
|
|
-
|
|
|
|
- Reference()
|
|
|
|
- : m_numRefs( 0 )
|
|
|
|
- , m_referencedName( ddl_nullptr ) {
|
|
|
|
- // empty
|
|
|
|
- }
|
|
|
|
|
|
+struct DLL_ODDLPARSER_EXPORT Reference {
|
|
|
|
+ size_t m_numRefs; ///< The number of stored references.
|
|
|
|
+ Name **m_referencedName; ///< The reference names.
|
|
|
|
+
|
|
|
|
+ /// @brief The default constructor.
|
|
|
|
+ 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;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ~Reference() {
|
|
|
|
- for( size_t i = 0; i < m_numRefs; i++ ) {
|
|
|
|
- delete m_referencedName[ i ];
|
|
|
|
- }
|
|
|
|
- m_numRefs = 0;
|
|
|
|
- m_referencedName = ddl_nullptr;
|
|
|
|
- }
|
|
|
|
|
|
+ /// @brief The constructor with an array of ref names.
|
|
|
|
+ /// @param numrefs [in] The number of ref names.
|
|
|
|
+ /// @param names [in] The ref names.
|
|
|
|
+ Reference( size_t numrefs, Name **names );
|
|
|
|
+
|
|
|
|
+ /// @brief The destructor.
|
|
|
|
+ ~Reference();
|
|
|
|
|
|
private:
|
|
private:
|
|
Reference( const Reference & );
|
|
Reference( const Reference & );
|
|
@@ -226,26 +196,21 @@ private:
|
|
};
|
|
};
|
|
|
|
|
|
/// @brief Stores a property list.
|
|
/// @brief Stores a property list.
|
|
-struct Property {
|
|
|
|
- Identifier *m_key;
|
|
|
|
- Value *m_value;
|
|
|
|
- Reference *m_ref;
|
|
|
|
- Property *m_next;
|
|
|
|
-
|
|
|
|
- Property( Identifier *id )
|
|
|
|
- : m_key( id )
|
|
|
|
- , m_value( ddl_nullptr )
|
|
|
|
- , m_ref( ddl_nullptr )
|
|
|
|
- , m_next( ddl_nullptr ) {
|
|
|
|
- // empty
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ~Property() {
|
|
|
|
- m_key = ddl_nullptr;
|
|
|
|
- m_value = ddl_nullptr;
|
|
|
|
- m_ref = ddl_nullptr;;
|
|
|
|
- m_next = ddl_nullptr;;
|
|
|
|
- }
|
|
|
|
|
|
+struct DLL_ODDLPARSER_EXPORT Property {
|
|
|
|
+ Identifier *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 ).
|
|
|
|
+
|
|
|
|
+ /// @brief The default constructor.
|
|
|
|
+ Property();
|
|
|
|
+
|
|
|
|
+ /// @brief The constructor for initialization.
|
|
|
|
+ /// @param id [in] The identifier
|
|
|
|
+ Property( Identifier *id );
|
|
|
|
+
|
|
|
|
+ /// @brief The destructor.
|
|
|
|
+ ~Property();
|
|
|
|
|
|
private:
|
|
private:
|
|
Property( const Property & );
|
|
Property( const Property & );
|
|
@@ -253,17 +218,16 @@ private:
|
|
};
|
|
};
|
|
|
|
|
|
/// @brief Stores a data array list.
|
|
/// @brief Stores a data array list.
|
|
-struct DataArrayList {
|
|
|
|
- size_t m_numItems;
|
|
|
|
- Value *m_dataList;
|
|
|
|
- DataArrayList *m_next;
|
|
|
|
-
|
|
|
|
- DataArrayList()
|
|
|
|
- : m_numItems( 0 )
|
|
|
|
- , m_dataList( ddl_nullptr )
|
|
|
|
- , m_next( ddl_nullptr ) {
|
|
|
|
- // empty
|
|
|
|
- }
|
|
|
|
|
|
+struct DLL_ODDLPARSER_EXPORT DataArrayList {
|
|
|
|
+ size_t m_numItems; ///< The number of items in the list.
|
|
|
|
+ Value *m_dataList; ///< The data list ( ee Value ).
|
|
|
|
+ DataArrayList *m_next; ///< The next data array list ( ddl_nullptr if last ).
|
|
|
|
+
|
|
|
|
+ /// @brief The default constructor for initialization.
|
|
|
|
+ DataArrayList();
|
|
|
|
+
|
|
|
|
+ /// @brief The destructor.
|
|
|
|
+ ~DataArrayList();
|
|
|
|
|
|
private:
|
|
private:
|
|
DataArrayList( const DataArrayList & );
|
|
DataArrayList( const DataArrayList & );
|
|
@@ -271,17 +235,17 @@ private:
|
|
};
|
|
};
|
|
|
|
|
|
/// @brief Stores the context of a parsed OpenDDL declaration.
|
|
/// @brief Stores the context of a parsed OpenDDL declaration.
|
|
-struct Context {
|
|
|
|
- DDLNode *m_root;
|
|
|
|
|
|
+struct DLL_ODDLPARSER_EXPORT Context {
|
|
|
|
+ DDLNode *m_root; ///< The root node of the OpenDDL node tree.
|
|
|
|
+
|
|
|
|
+ /// @brief Constructor for initialization.
|
|
|
|
+ Context();
|
|
|
|
|
|
- Context()
|
|
|
|
- : m_root( ddl_nullptr ) {
|
|
|
|
- // empty
|
|
|
|
- }
|
|
|
|
|
|
+ /// @brief Destructor.
|
|
|
|
+ ~Context();
|
|
|
|
|
|
- ~Context() {
|
|
|
|
- m_root = ddl_nullptr;
|
|
|
|
- }
|
|
|
|
|
|
+ /// @brief Clears the whole node tree.
|
|
|
|
+ void clear();
|
|
|
|
|
|
private:
|
|
private:
|
|
Context( const Context & );
|
|
Context( const Context & );
|