summaryrefslogtreecommitdiff
path: root/libs/assimp/contrib/openddlparser/include/openddlparser
diff options
context:
space:
mode:
Diffstat (limited to 'libs/assimp/contrib/openddlparser/include/openddlparser')
-rw-r--r--libs/assimp/contrib/openddlparser/include/openddlparser/DDLNode.h173
-rw-r--r--libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h245
-rw-r--r--libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLExport.h80
-rw-r--r--libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLParser.h206
-rw-r--r--libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h503
-rw-r--r--libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLStream.h89
-rw-r--r--libs/assimp/contrib/openddlparser/include/openddlparser/TPoolAllocator.h226
-rw-r--r--libs/assimp/contrib/openddlparser/include/openddlparser/Value.h273
8 files changed, 1795 insertions, 0 deletions
diff --git a/libs/assimp/contrib/openddlparser/include/openddlparser/DDLNode.h b/libs/assimp/contrib/openddlparser/include/openddlparser/DDLNode.h
new file mode 100644
index 0000000..593a5f1
--- /dev/null
+++ b/libs/assimp/contrib/openddlparser/include/openddlparser/DDLNode.h
@@ -0,0 +1,173 @@
+/*-----------------------------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2014-2020 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
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+-----------------------------------------------------------------------------------------------*/
+#pragma once
+
+#include <openddlparser/OpenDDLCommon.h>
+
+#include <string>
+#include <vector>
+
+BEGIN_ODDLPARSER_NS
+
+// Forward declarations
+class IOStreamBase;
+class Value;
+class OpenDDLParser;
+
+struct Identifier;
+struct Reference;
+struct Property;
+struct DataArrayList;
+
+///
+/// @ingroup OpenDDLParser
+/// @brief This class represents one single instance in the object tree of the parsed OpenDDL-file.
+///
+/// A DDLNode represents one leaf in the OpenDDL-node tree. It can have one parent node and multiple children.
+/// You can assign special properties to a single DDLNode instance.
+/// A node instance can store values via a linked list. You can get the first value from the DDLNode.
+/// A node can store data-array-lists and references as well.
+///
+class DLL_ODDLPARSER_EXPORT DDLNode {
+public:
+ friend class OpenDDLParser;
+
+ /// @brief The child-node-list type.
+ typedef std::vector<DDLNode *> DllNodeList;
+
+ /// @brief The child-node-list iterator.
+ typedef std::vector<DDLNode *>::iterator DDLNodeIt;
+
+public:
+ /// @brief The class destructor.
+ ~DDLNode();
+
+ /// @brief Will attach a parent node instance, an older one will be released.
+ /// @param parent [in] The parent node instance.
+ void attachParent(DDLNode *parent);
+
+ /// @brief Will try to detach a parent node instance, if there is any.
+ void detachParent();
+
+ /// @brief Returns the assigned parent node instance, will return ddl_nullptr id no parent is assigned.
+ /// @return The parent node instance.
+ DDLNode *getParent() const;
+
+ /// @brief Returns the child node list.
+ /// @return The list of child nodes.
+ const DllNodeList &getChildNodeList() const;
+
+ /// Set the type of the DDLNode instance.
+ /// @param type [in] The type.
+ void setType(const std::string &type);
+
+ /// @brief Returns the type of the DDLNode instance.
+ /// @return The type of the DDLNode instance.
+ const std::string &getType() const;
+
+ /// Set the name of the DDLNode instance.
+ /// @param name [in] The name.
+ void setName(const std::string &name);
+
+ /// @brief Returns the name of the DDLNode instance.
+ /// @return The name of the DDLNode instance.
+ const std::string &getName() const;
+
+ /// @brief Set a new property set.
+ /// @param prop [in] The first element of the property set.
+ void setProperties(Property *prop);
+
+ /// @brief Returns the first element of the assigned property set.
+ /// @return The first property of the assigned property set.
+ Property *getProperties() const;
+
+ /// @brief Looks for a given property.
+ /// @param name [in] The name for the property to look for.
+ /// @return true, if a corresponding property is assigned to the node, false if not.
+ bool hasProperty(const std::string &name);
+
+ /// @brief Will return true, if any properties are assigned to the node instance.
+ /// @return True, if properties are assigned.
+ bool hasProperties() const;
+
+ /// @brief Search for a given property and returns it. Will return ddl_nullptr if no property was found.
+ /// @param name [in] The name for the property to look for.
+ /// @return The property or ddl_nullptr if no property was found.
+ Property *findPropertyByName(const std::string &name);
+
+ /// @brief Set a new value set.
+ /// @param val [in] The first value instance of the value set.
+ void setValue(Value *val);
+
+ /// @brief Returns the first element of the assigned value set.
+ /// @return The first property of the assigned value set.
+ Value *getValue() const;
+
+ /// @brief Set a new DataArrayList.
+ /// @param dtArrayList [in] The DataArrayList instance.
+ void setDataArrayList(DataArrayList *dtArrayList);
+
+ /// @brief Returns the DataArrayList.
+ /// @return The DataArrayList.
+ DataArrayList *getDataArrayList() const;
+
+ /// @brief Set a new Reference set.
+ /// @param refs [in] The first value instance of the Reference set.
+ void setReferences(Reference *refs);
+
+ /// @brief Returns the first element of the assigned Reference set.
+ /// @return The first property of the assigned Reference set.
+ Reference *getReferences() const;
+
+ /// @brief Will dump the node into the stream.
+ /// @param stream [in] The stream to write to.
+ void dump(IOStreamBase &stream);
+
+ /// @brief The creation method.
+ /// @param type [in] The DDLNode type.
+ /// @param name [in] The name for the new DDLNode instance.
+ /// @param parent [in] The parent node instance or ddl_nullptr if no parent node is there.
+ /// @return The new created node instance.
+ static DDLNode *create(const std::string &type, const std::string &name, DDLNode *parent = nullptr);
+
+private:
+ DDLNode(const std::string &type, const std::string &name, size_t idx, DDLNode *parent = nullptr);
+ DDLNode();
+ DDLNode(const DDLNode &) ddl_no_copy;
+ DDLNode &operator=(const DDLNode &) ddl_no_copy;
+ static void releaseNodes();
+
+private:
+ std::string m_type;
+ std::string m_name;
+ DDLNode *m_parent;
+ std::vector<DDLNode *> m_children;
+ Property *m_properties;
+ Value *m_value;
+ DataArrayList *m_dtArrayList;
+ Reference *m_references;
+ size_t m_idx;
+ static DllNodeList s_allocatedNodes;
+};
+
+END_ODDLPARSER_NS
diff --git a/libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h b/libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h
new file mode 100644
index 0000000..6ccc83b
--- /dev/null
+++ b/libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h
@@ -0,0 +1,245 @@
+/*-----------------------------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2014-2020 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
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+-----------------------------------------------------------------------------------------------*/
+#pragma once
+
+#include <cstddef>
+#include <string>
+#include <vector>
+
+#include <stdio.h>
+#include <string.h>
+#ifndef _WIN32
+#include <inttypes.h>
+#endif
+
+#if defined(_MSC_VER) && !defined(OPENDDL_STATIC_LIBARY)
+
+#define TAG_DLL_EXPORT __declspec(dllexport)
+#define TAG_DLL_IMPORT __declspec(dllimport)
+#ifdef OPENDDLPARSER_BUILD
+#define DLL_ODDLPARSER_EXPORT TAG_DLL_EXPORT
+#else
+#define DLL_ODDLPARSER_EXPORT TAG_DLL_IMPORT
+#endif // OPENDDLPARSER_BUILD
+#pragma warning(disable : 4251)
+#else
+#define DLL_ODDLPARSER_EXPORT
+#endif // _WIN32
+
+// Namespace declarations, override this to avoid any conflicts
+#define BEGIN_ODDLPARSER_NS namespace ODDLParser {
+#define END_ODDLPARSER_NS } // namespace ODDLParser
+#define USE_ODDLPARSER_NS using namespace ODDLParser;
+
+BEGIN_ODDLPARSER_NS
+
+// We will use C++11 optional
+#ifndef OPENDDL_NO_USE_CPP11
+// All C++11 constructs
+#define nullptr nullptr
+#define ddl_override override
+#define ddl_final final
+#define ddl_no_copy = delete
+#else
+// Fall-back for older compilers
+#define nullptr NULL
+#define ddl_override
+#define ddl_final
+#define ddl_no_copy
+#endif // OPENDDL_NO_USE_CPP11
+
+// Forward declarations
+class DDLNode;
+class Value;
+
+struct Name;
+struct Identifier;
+struct Reference;
+struct Property;
+struct DataArrayList;
+
+// Platform-specific typedefs
+#ifdef _WIN32
+typedef signed __int64 int64_impl;
+typedef unsigned __int64 uint64_impl;
+#else
+typedef int64_t int64_impl;
+typedef uint64_t uint64_impl;
+#endif
+
+// OpenDDL-specific data typedefs
+using int8 = signed char; ///< Signed integer, 1 byte
+using int16 = signed short; ///< Signed integer, 2 byte
+using int32 = signed int; ///< Signed integer, 4 byte
+using int64 = int64_impl; ///< Signed integer, 8 byte
+using uint8 = unsigned char; ///< Unsigned integer, 1 byte
+using uint16 = unsigned short ; ///< Unsigned integer, 2 byte
+using uint32 = unsigned int; ///< Unsigned integer, 4 byte
+using uint64 = uint64_impl ; ///< Unsigned integer, 8 byte
+
+/// @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 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:
+ Text(const Text &) ddl_no_copy;
+ Text &operator=(const Text &) ddl_no_copy;
+};
+
+/// @brief Description of the type of a name.
+enum NameType {
+ GlobalName, ///< Name is global.
+ LocalName ///< Name is local.
+};
+
+/// @brief Stores an OpenDDL-specific name
+struct DLL_ODDLPARSER_EXPORT Name {
+ NameType m_type; ///< The type of the name ( @see NameType ).
+ 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, Text *id);
+ Name(const Name &name);
+ /// @brief The destructor.
+ ~Name();
+
+private:
+ Name &operator=(const Name &) ddl_no_copy;
+};
+
+/// @brief Stores a bundle of references.
+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(const Reference &ref);
+ /// @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();
+
+ /// @brief Returns the size in bytes to store one deep reference copy.
+ /// @return The size on bytes.
+ size_t sizeInBytes();
+
+private:
+ Reference &operator=(const Reference &) ddl_no_copy;
+};
+
+/// @brief Stores a property list.
+struct DLL_ODDLPARSER_EXPORT 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 ).
+
+ /// @brief The default constructor.
+ Property();
+
+ /// @brief The constructor for initialization.
+ /// @param id [in] The identifier
+ Property(Text *id);
+
+ /// @brief The destructor.
+ ~Property();
+
+private:
+ Property(const Property &) ddl_no_copy;
+ Property &operator=(const Property &) ddl_no_copy;
+};
+
+/// @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 ( a Value ).
+ DataArrayList *m_next; ///< The next data array list ( ddl_nullptr if last ).
+ Reference *m_refs;
+ size_t m_numRefs;
+
+ /// @brief The default constructor for initialization.
+ DataArrayList();
+
+ /// @brief The destructor.
+ ~DataArrayList();
+
+ /// @brief Gets the length of the array
+ size_t size();
+
+private:
+ DataArrayList(const DataArrayList &) ddl_no_copy;
+ DataArrayList &operator=(const DataArrayList &) ddl_no_copy;
+};
+
+/// @brief Stores the context of a parsed OpenDDL declaration.
+struct DLL_ODDLPARSER_EXPORT Context {
+ DDLNode *m_root; ///< The root node of the OpenDDL node tree.
+
+ /// @brief Constructor for initialization.
+ Context();
+
+ /// @brief Destructor.
+ ~Context();
+
+ /// @brief Clears the whole node tree.
+ void clear();
+
+private:
+ Context(const Context &) ddl_no_copy;
+ Context &operator=(const Context &) ddl_no_copy;
+};
+
+END_ODDLPARSER_NS
diff --git a/libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLExport.h b/libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLExport.h
new file mode 100644
index 0000000..9452535
--- /dev/null
+++ b/libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLExport.h
@@ -0,0 +1,80 @@
+/*-----------------------------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2014-2020 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
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+-----------------------------------------------------------------------------------------------*/
+#pragma once
+
+#include <openddlparser/OpenDDLCommon.h>
+#include <openddlparser/OpenDDLStream.h>
+#include <openddlparser/Value.h>
+
+BEGIN_ODDLPARSER_NS
+
+// Forward declarations
+class IOStreamBase;
+
+//-------------------------------------------------------------------------------------------------
+///
+/// @ingroup OpenDDLParser
+/// @brief This class represents the OpenDDLExporter.
+///
+//-------------------------------------------------------------------------------------------------
+class DLL_ODDLPARSER_EXPORT OpenDDLExport {
+public:
+ /// @brief The class constructor
+ OpenDDLExport(IOStreamBase *stream = nullptr);
+
+ /// @brief The class destructor.
+ ~OpenDDLExport();
+
+ /// @brief Export the data of a parser context.
+ /// @param ctx [in] Pointer to the context.
+ /// @param filename [in] The filename for the export.
+ /// @return True in case of success, false in case of an error.
+ bool exportContext(Context *ctx, const std::string &filename);
+
+ /// @brief Handles a node export.
+ /// @param node [in] The node to handle with.
+ /// @return True in case of success, false in case of an error.
+ bool handleNode(DDLNode *node);
+
+ /// @brief Writes the statement to the stream.
+ /// @param statement [in] The content to write.
+ /// @return True in case of success, false in case of an error.
+ bool writeToStream(const std::string &statement);
+
+protected:
+ bool writeNode(DDLNode *node, std::string &statement);
+ bool writeNodeHeader(DDLNode *node, std::string &statement);
+ bool writeProperties(DDLNode *node, std::string &statement);
+ bool writeValueType(Value::ValueType type, size_t numItems, std::string &statement);
+ 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;
+};
+
+END_ODDLPARSER_NS
diff --git a/libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLParser.h b/libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLParser.h
new file mode 100644
index 0000000..3fbb4b6
--- /dev/null
+++ b/libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLParser.h
@@ -0,0 +1,206 @@
+/*-----------------------------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2014-2020 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
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+-----------------------------------------------------------------------------------------------*/
+#pragma once
+
+#include <openddlparser/DDLNode.h>
+#include <openddlparser/OpenDDLCommon.h>
+#include <openddlparser/OpenDDLParserUtils.h>
+#include <openddlparser/Value.h>
+
+#include <string>
+#include <vector>
+#include <functional>
+
+BEGIN_ODDLPARSER_NS
+
+class DDLNode;
+class Value;
+
+struct Identifier;
+struct Reference;
+struct Property;
+
+template <class T>
+inline bool isEmbeddedCommentOpenTag(T *in, T *end) {
+ if (in == '/' && in + 1 == '*') {
+ return true;
+ }
+
+ return false;
+}
+
+/// @brief Utility function to search for the next token or the end of the buffer.
+/// @param in [in] The start position in the buffer.
+/// @param end [in] The end position in the buffer.
+/// @return Pointer showing to the next token or the end of the buffer.
+/// @detail Will not increase buffer when already a valid buffer was found.
+template <class T>
+inline T *lookForNextToken(T *in, T *end) {
+ while ((in != end) && (isSpace(*in) || isNewLine(*in) || ',' == *in)) {
+ ++in;
+ }
+ return in;
+}
+
+/// @brief Utility function to go for the next token or the end of the buffer.
+/// @param in [in] The start position in the buffer.
+/// @param end [in] The end position in the buffer.
+/// @return Pointer showing to the next token or the end of the buffer.
+/// @detail Will increase buffer by a minimum of one.
+template <class T>
+inline T *getNextToken(T *in, T *end) {
+ T *tmp(in);
+ in = lookForNextToken(in, end);
+ if (tmp == in) {
+ ++in;
+ }
+ return in;
+}
+
+/// @brief Defines the log severity.
+enum LogSeverity {
+ ddl_debug_msg = 0, ///< Debug message, for debugging
+ ddl_info_msg, ///< Info messages, normal mode
+ ddl_warn_msg, ///< Parser warnings
+ ddl_error_msg ///< Parser errors
+};
+
+DLL_ODDLPARSER_EXPORT const char *getTypeToken(Value::ValueType type);
+
+//-------------------------------------------------------------------------------------------------
+/// @class OpenDDLParser
+/// @ingroup OpenDDLParser
+
+///
+/// @brief This is the main API for the OpenDDL-parser.
+///
+/// Use instances of this class to manage the parsing and handling of your parser contexts.
+//-------------------------------------------------------------------------------------------------
+class DLL_ODDLPARSER_EXPORT OpenDDLParser {
+public:
+ /// @brief The log callback function.
+ typedef std::function<void (LogSeverity severity, const std::string &msg)> logCallback;
+
+public:
+ /// @brief The default class constructor.
+ OpenDDLParser();
+
+ /// @brief The class constructor.
+ /// @param buffer [in] The buffer
+ /// @param len [in] Size of the buffer
+ OpenDDLParser(const char *buffer, size_t len);
+
+ /// @brief The class destructor.
+ ~OpenDDLParser();
+
+ /// @brief Setter for an own log callback function.
+ /// @param callback [in] The own callback.
+ void setLogCallback(logCallback callback);
+
+ /// @brief Getter for the log callback.
+ /// @return The current log callback.
+ logCallback getLogCallback() const;
+
+ /// @brief A default log callback that writes to a FILE.
+ /// @param destination [in] Output stream. NULL will use stderr.
+ /// @return A callback that you can pass to setLogCallback.
+ static logCallback StdLogCallback(FILE *destination = nullptr);
+
+ /// @brief Assigns a new buffer to parse.
+ /// @param buffer [in] The buffer
+ /// @param len [in] Size of the buffer
+ void setBuffer(const char *buffer, size_t len);
+
+ /// @brief Assigns a new buffer to parse.
+ /// @param buffer [in] The buffer as a std::vector.
+ void setBuffer(const std::vector<char> &buffer);
+
+ /// @brief Returns the buffer pointer.
+ /// @return The buffer pointer.
+ const char *getBuffer() const;
+
+ /// @brief Returns the size of the buffer.
+ /// @return The buffer size.
+ size_t getBufferSize() const;
+
+ /// @brief Clears all parser data, including buffer and active context.
+ void clear();
+
+ bool validate();
+
+ /// @brief Starts the parsing of the OpenDDL-file.
+ /// @return True in case of success, false in case of an error.
+ /// @remark In case of errors check log.
+ bool parse();
+
+
+ bool exportContext(Context *ctx, const std::string &filename);
+
+ /// @brief Returns the root node.
+ /// @return The root node.
+ DDLNode *getRoot() const;
+
+ /// @brief Returns the parser context, only available in case of a succeeded parsing.
+ /// @return Pointer to the active context or ddl_nullptr.
+ Context *getContext() const;
+
+public: // parser helpers
+ char *parseNextNode(char *current, char *end);
+ char *parseHeader(char *in, char *end);
+ char *parseStructure(char *in, char *end);
+ char *parseStructureBody(char *in, char *end, bool &error);
+ void pushNode(DDLNode *node);
+ DDLNode *popNode();
+ 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, 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);
+ static char *parseIntegerLiteral(char *in, char *end, Value **integer, Value::ValueType integerType = Value::ValueType::ddl_int32);
+ static char *parseFloatingLiteral(char *in, char *end, Value **floating, Value::ValueType floatType = Value::ValueType::ddl_float);
+ static char *parseStringLiteral(char *in, char *end, Value **stringData);
+ static char *parseHexaLiteral(char *in, char *end, Value **data);
+ static char *parseProperty(char *in, char *end, Property **prop);
+ static char *parseDataList(char *in, char *end, Value::ValueType type, Value **data, size_t &numValues, Reference **refs, size_t &numRefs);
+ static char *parseDataArrayList(char *in, char *end, Value::ValueType type, DataArrayList **dataList);
+ static const char *getVersion();
+
+private:
+ OpenDDLParser(const OpenDDLParser &) ddl_no_copy;
+ OpenDDLParser &operator=(const OpenDDLParser &) ddl_no_copy;
+
+private:
+ logCallback m_logCallback;
+ std::vector<char> m_buffer;
+
+ typedef std::vector<DDLNode *> DDLNodeStack;
+ DDLNodeStack m_stack;
+ Context *m_context;
+
+ /// @brief Callback for StdLogCallback(). Not meant to be called directly.
+ static void logToStream (FILE *, LogSeverity, const std::string &);
+};
+
+END_ODDLPARSER_NS
diff --git a/libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h b/libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h
new file mode 100644
index 0000000..42ad675
--- /dev/null
+++ b/libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h
@@ -0,0 +1,503 @@
+/*-----------------------------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2014-2020 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
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+-----------------------------------------------------------------------------------------------*/
+#pragma once
+
+#include <openddlparser/OpenDDLCommon.h>
+
+BEGIN_ODDLPARSER_NS
+
+template <class T>
+inline bool isUpperCase(T in) {
+ return (in >= 'A' && in <= 'Z');
+}
+
+template <class T>
+inline bool isLowerCase(T in) {
+ return (in >= 'a' && in <= 'z');
+}
+
+template <class T>
+inline bool isSpace(const T in) {
+ return (' ' == in || '\t' == in);
+}
+
+template <class T>
+inline bool isNewLine(const T in) {
+ return ('\n' == in || ('\r' == in));
+}
+
+template <class T>
+inline bool isSeparator(T in) {
+ if (isSpace(in) || ',' == in || '{' == in || '}' == in || '[' == in || '(' == in || ')' == in) {
+ return true;
+ }
+ return false;
+}
+
+static const unsigned char chartype_table[256] = {
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, // 0-15
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, // 16-31
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, // 32-47
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, // 48-63
+
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, // 64-79
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, // 80-95
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, // 96-111
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, // 112-127
+
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0, // > 127
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+template <class T>
+inline bool isNumeric(const T in) {
+ size_t idx = static_cast<size_t>(in);
+ return idx < sizeof(chartype_table) && (chartype_table[idx] == 1);
+}
+
+template <class T>
+inline bool isNotEndOfToken(T *in, T *end) {
+ return ('}' != *in && ',' != *in && !isSpace(*in) && ')' != *in && in != end);
+}
+
+template <class T>
+inline bool isInteger(T *in, T *end) {
+ if (in != end) {
+ if (*in == '-') {
+ ++in;
+ }
+ }
+
+ bool result(false);
+ while (isNotEndOfToken(in, end)) {
+ result = isNumeric(*in);
+ if (!result) {
+ break;
+ }
+ ++in;
+ }
+
+ return result;
+}
+
+template <class T>
+inline bool isFloat(T *in, T *end) {
+ if (in != end) {
+ if (*in == '-') {
+ ++in;
+ }
+ }
+
+ // check for <1>.0f
+ bool result(false);
+ while (isNotEndOfToken(in, end)) {
+ if (*in == '.') {
+ result = true;
+ break;
+ }
+ result = isNumeric(*in);
+ if (!result) {
+ return false;
+ }
+ ++in;
+ }
+
+ // check for 1<.>0f
+ if (*in == '.') {
+ ++in;
+ } else {
+ return false;
+ }
+
+ // check for 1.<0>f
+ while (isNotEndOfToken(in, end)) {
+ result = isNumeric(*in);
+ if (!result) {
+ return false;
+ }
+ ++in;
+ }
+
+ return result;
+}
+
+template <class T>
+inline bool isCharacter(const T in) {
+ return ((in >= 'a' && in <= 'z') || (in >= 'A' && in <= 'Z'));
+}
+
+template <class T>
+inline bool isStringLiteral(const T in) {
+ return (in == '\"');
+}
+
+template <class T>
+inline bool isHexLiteral(T *in, T *end) {
+ if (*in == '0') {
+ if (in + 1 != end) {
+ if (*(in + 1) == 'x' || *(in + 1) == 'X') {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+template <class T>
+inline bool isReference(T *in, T *end) {
+ if (*in == 'r') {
+ if (*(in + 1) == 'e') {
+ if (*(in + 2) == 'f') {
+ if ((in + 2) != end) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+template <class T>
+inline bool isEndofLine(const T in) {
+ return ('\n' == in);
+}
+
+template <class T>
+inline static T *getNextSeparator(T *in, T *end) {
+ while (!isSeparator(*in) || in == end) {
+ ++in;
+ }
+ return in;
+}
+
+static const int ErrorHex2Decimal = 9999999;
+
+inline int hex2Decimal(char in) {
+ if (isNumeric(in)) {
+ return (in - 48);
+ }
+
+ char hexCodeLower('a'), hexCodeUpper('A');
+ for (int i = 0; i < 16; i++) {
+ if (in == hexCodeLower + i || in == hexCodeUpper + i) {
+ return (i + 10);
+ }
+ }
+
+ return ErrorHex2Decimal;
+}
+
+template <class T>
+inline bool isComment(T *in, T *end) {
+ if (*in == '/') {
+ if (in + 1 != end) {
+ if (*(in + 1) == '/') {
+ char *drive((in + 2));
+ if ((isUpperCase<T>(*drive) || isLowerCase<T>(*drive)) && *(drive + 1) == '/') {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+template <class T>
+inline bool isCommentOpenTag(T *in, T *end) {
+ if (*in == '/') {
+ if (in + 1 != end) {
+ if (*(in + 1) == '*') {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+template <class T>
+inline bool isCommentCloseTag(T *in, T *end) {
+ if (*in == '*') {
+ if (in + 1 != end) {
+ if (*(in + 1) == '/') {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+END_ODDLPARSER_NS
diff --git a/libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLStream.h b/libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLStream.h
new file mode 100644
index 0000000..93bde5f
--- /dev/null
+++ b/libs/assimp/contrib/openddlparser/include/openddlparser/OpenDDLStream.h
@@ -0,0 +1,89 @@
+/*-----------------------------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2014-2020 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
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+-----------------------------------------------------------------------------------------------*/
+#pragma once
+
+#include <openddlparser/OpenDDLCommon.h>
+
+BEGIN_ODDLPARSER_NS
+
+//-------------------------------------------------------------------------------------------------
+/// @ingroup IOStreamBase
+/// @brief This class represents the stream to write out.
+//-------------------------------------------------------------------------------------------------
+class DLL_ODDLPARSER_EXPORT StreamFormatterBase {
+public:
+ /// @brief The class constructor.
+ StreamFormatterBase();
+
+ /// @brief The class destructor, virtual.
+ virtual ~StreamFormatterBase();
+
+ /// @brief Will format the string and return the new formatted result.
+ /// @param statement [in] The string to reformat.
+ /// @return The reformatted result.
+ virtual std::string format(const std::string &statement);
+};
+
+//-------------------------------------------------------------------------------------------------
+/// @ingroup IOStreamBase
+/// @brief This class represents the stream to write out.
+//-------------------------------------------------------------------------------------------------
+class DLL_ODDLPARSER_EXPORT IOStreamBase {
+public:
+ /// @brief The class constructor with the formatter.
+ /// @param formatter [in] The formatter to use.
+ explicit IOStreamBase(StreamFormatterBase *formatter = nullptr);
+
+ /// @brief The class destructor, virtual.
+ virtual ~IOStreamBase();
+
+ /// @brief Will open the stream.
+ /// @param name [in] The name for the stream.
+ /// @return true, if the stream was opened successfully, false if not.
+ virtual bool open(const std::string &name);
+
+ /// @brief Will close the stream.
+ /// @return true, if the stream was closed successfully, false if not.
+ virtual bool close();
+
+ /// @brief Returns true, if the stream is open.
+ /// @return true, if the stream is open, false if not.
+ virtual bool isOpen() const;
+
+ /// @brief Will read a string from the stream.
+ /// @param sizeToRead [in] The size to read in bytes.
+ /// @param statement [out] The read statements.
+ /// @return The bytes read from the stream.
+ virtual size_t read(size_t sizeToRead, std::string &statement);
+
+ /// @brief Will write a string into the stream.
+ /// @param statement [in] The string to write.
+ /// @return The bytes written into the stream.
+ virtual size_t write(const std::string &statement);
+
+private:
+ StreamFormatterBase *m_formatter;
+ FILE *m_file;
+};
+
+END_ODDLPARSER_NS
diff --git a/libs/assimp/contrib/openddlparser/include/openddlparser/TPoolAllocator.h b/libs/assimp/contrib/openddlparser/include/openddlparser/TPoolAllocator.h
new file mode 100644
index 0000000..6076c73
--- /dev/null
+++ b/libs/assimp/contrib/openddlparser/include/openddlparser/TPoolAllocator.h
@@ -0,0 +1,226 @@
+/*-----------------------------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2014-2019 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
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+-----------------------------------------------------------------------------------------------*/
+#pragma once
+
+#include <openddlparser/OpenDDLCommon.h>
+#include <string>
+
+BEGIN_ODDLPARSER_NS
+
+//-------------------------------------------------------------------------------------------------
+/// @class TPoolAllocator
+/// @ingroup CPPCore
+///
+/// @brief This class implements a simple pool-based allocation scheme.
+/// Initially you have to define its size. Each allocation will be done from this initially created
+/// pool. You have to release all pooled instances after the usage.
+/// This allocation scheme is fast and does no call any new-calls during the lifetime of the
+/// allocator.
+//-------------------------------------------------------------------------------------------------
+template <class T>
+class TPoolAllocator {
+public:
+ TPoolAllocator();
+ TPoolAllocator(size_t numItems);
+ ~TPoolAllocator();
+ T *alloc();
+ void release();
+ void reserve(size_t size);
+ void clear();
+ size_t capacity() const;
+ size_t reservedMem() const;
+ size_t freeMem() const;
+ void dumpAllocations(std::string &allocs);
+ void resize(size_t growSize);
+
+ CPPCORE_NONE_COPYING(TPoolAllocator)
+
+private:
+ struct Pool {
+ size_t m_poolsize;
+ T *m_pool;
+ size_t m_currentIdx;
+ Pool *m_next;
+
+ Pool() :
+ m_poolsize(0u), m_pool(nullptr), m_currentIdx(0u), m_next(nullptr) {
+ // empty
+ }
+
+ Pool(size_t numItems, Pool *prev) :
+ m_poolsize(numItems), m_pool(nullptr), m_currentIdx(0u), m_next(prev) {
+ m_pool = new T[m_poolsize];
+ }
+
+ ~Pool() {
+ delete[] m_pool;
+ m_pool = nullptr;
+ }
+
+ CPPCORE_NONE_COPYING(Pool)
+ };
+
+ Pool *getFreePool() {
+ Pool *current(m_freeList);
+ if (nullptr != m_freeList) {
+ m_freeList = m_freeList->m_next;
+ }
+ return current;
+ }
+
+ Pool *m_first;
+ Pool *m_current;
+ Pool *m_freeList;
+ size_t m_capacity;
+};
+
+template <class T>
+inline TPoolAllocator<T>::TPoolAllocator() :
+ m_first(nullptr), m_current(nullptr), m_freeList(nullptr), m_capacity(0L) {
+ // empty
+}
+
+template <class T>
+inline TPoolAllocator<T>::TPoolAllocator(size_t numItems) :
+ m_first(nullptr), m_current(nullptr), m_freeList(nullptr), m_capacity(0L) {
+ m_first = new Pool(numItems);
+ m_capacity += numItems;
+ m_current = m_first;
+}
+
+template <class T>
+inline TPoolAllocator<T>::~TPoolAllocator() {
+ clear();
+}
+
+template <class T>
+inline T *TPoolAllocator<T>::alloc() {
+ if (nullptr == m_current) {
+ return nullptr;
+ }
+
+ if (m_current->m_currentIdx == m_current->m_poolsize) {
+ resize(m_current->m_poolsize);
+ }
+
+ T *ptr(&m_current->m_pool[m_current->m_currentIdx]);
+ m_current->m_currentIdx++;
+
+ return ptr;
+}
+
+template <class T>
+inline void TPoolAllocator<T>::release() {
+ if (nullptr == m_current) {
+ return;
+ }
+
+ Pool *current(m_first);
+ while (nullptr != current) {
+ current->m_currentIdx = 0;
+ current = current->m_next;
+ }
+ m_freeList = m_first->m_next;
+ m_current = m_first;
+}
+
+template <class T>
+inline void TPoolAllocator<T>::reserve(size_t size) {
+ clear();
+
+ m_first = new Pool(size, nullptr);
+ m_current = m_first;
+
+ m_current->m_pool = new T[size];
+ m_current->m_poolsize = size;
+
+ m_capacity = size;
+}
+
+template <class T>
+inline void TPoolAllocator<T>::clear() {
+ if (nullptr == m_current) {
+ return;
+ }
+
+ Pool *next(m_first);
+ while (nullptr != next) {
+ Pool *current = next;
+ next = current->m_next;
+ delete current;
+ }
+ m_current = nullptr;
+ m_freeList = nullptr;
+}
+
+template <class T>
+inline size_t TPoolAllocator<T>::capacity() const {
+ return m_capacity;
+}
+
+template <class T>
+inline size_t TPoolAllocator<T>::reservedMem() const {
+ return m_capacity * sizeof(T);
+}
+
+template <class T>
+inline size_t TPoolAllocator<T>::freeMem() const {
+ if (nullptr == m_current) {
+ return 0L;
+ }
+
+ return (m_current->m_poolsize - m_current->m_currentIdx);
+}
+
+template <class T>
+inline void TPoolAllocator<T>::dumpAllocations(std::string &allocs) {
+ allocs.clear();
+ allocs += "Number allocations = ";
+ allocs += std::to_string(m_current->m_currentIdx);
+ allocs += "\n";
+}
+
+template <class T>
+inline void TPoolAllocator<T>::resize(size_t growSize) {
+ if (nullptr != m_current) {
+ if (growSize < m_current->m_poolsize) {
+ return;
+ }
+ }
+
+ if (nullptr == m_first) {
+ m_first = new Pool(growSize, nullptr);
+ m_current = m_first;
+ m_capacity += m_current->m_poolsize;
+ } else {
+ Pool *pool = getFreePool();
+ if (nullptr == pool) {
+ pool = new Pool(growSize, nullptr);
+ m_capacity += growSize;
+ }
+ m_current->m_next = pool;
+ m_current = m_current->m_next;
+ }
+}
+
+END_ODDLPARSER_NS \ No newline at end of file
diff --git a/libs/assimp/contrib/openddlparser/include/openddlparser/Value.h b/libs/assimp/contrib/openddlparser/include/openddlparser/Value.h
new file mode 100644
index 0000000..75af781
--- /dev/null
+++ b/libs/assimp/contrib/openddlparser/include/openddlparser/Value.h
@@ -0,0 +1,273 @@
+/*-----------------------------------------------------------------------------------------------
+The MIT License (MIT)
+
+Copyright (c) 2014-2020 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
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+-----------------------------------------------------------------------------------------------*/
+#pragma once
+
+#include <openddlparser/OpenDDLCommon.h>
+
+#include <string>
+
+BEGIN_ODDLPARSER_NS
+
+// Forward declarations
+struct ValueAllocator;
+
+class IOStreamBase;
+
+///------------------------------------------------------------------------------------------------
+/// @brief This class implements a value.
+///
+/// Values are used to store data types like boolean, integer, floats, double and many mode. To get
+/// an overview please check the enum VylueType ( @see Value::ValueType ).
+/// Values can be single items or lists of items. They are implemented as linked lists.
+///------------------------------------------------------------------------------------------------
+class DLL_ODDLPARSER_EXPORT Value {
+ friend struct ValueAllocator;
+
+public:
+ /// @brief This class implements an iterator through a Value list.
+ ///
+ /// When getting a new value you need to know how to iterate through it. The Value::Iterator
+ /// will help you here:
+ /// @code
+ /// Value *val = node->getValue();
+ /// Value::Iterator it( val );
+ /// while( it.hasNext() ) {
+ /// Value v( it.getNext );
+ /// }
+ /// @endcode
+ class DLL_ODDLPARSER_EXPORT Iterator {
+ public:
+ /// @brief The default class constructor.
+ Iterator();
+
+ /// @brief The class constructor with the start value.
+ /// @param start [in] The first value for iteration,
+ Iterator( Value *start );
+
+ Iterator( const Iterator &rhs );
+
+ /// @brief The class destructor.
+ ~Iterator();
+
+ /// @brief Will return true, if another value is in the list.
+ /// @return true if another value is there.
+ bool hasNext() const;
+
+ /// @brief Returns the next item and moves the iterator to it.
+ /// @return The next value, is ddl_nullptr in case of being the last item.
+ Value *getNext();
+
+ /// @brief The post-increment operator.
+ const Iterator operator++( int );
+
+ /// @brief The pre-increment operator.
+ Iterator &operator++( );
+
+ /// @brief The compare operator.
+ /// @param rhs [in] The instance to compare.
+ /// @return true if equal.
+ bool operator == ( const Iterator &rhs ) const;
+
+ /// @brief The * operator.
+ /// @return The instance or ddl_nullptr if end of list is reached.
+ Value *operator->( ) const;
+
+ private:
+ Value *m_start;
+ Value *m_current;
+
+ private:
+ Iterator &operator = ( const Iterator & );
+ };
+
+ /// @brief This enum describes the data type stored in the value.
+ enum class ValueType {
+ ddl_none = -1, ///< Nothing specified
+ ddl_bool = 0, ///< A boolean type
+ ddl_int8, ///< Integer type, 8 bytes
+ ddl_int16, ///< Integer type, 16 bytes
+ ddl_int32, ///< Integer type, 32 bytes
+ ddl_int64, ///< Integer type, 64 bytes
+ ddl_unsigned_int8, ///< Unsigned integer type, 8 bytes
+ ddl_unsigned_int16, ///< Unsigned integer type, 16 bytes
+ ddl_unsigned_int32, ///< Unsigned integer type, 32 bytes
+ ddl_unsigned_int64, ///< Unsigned integer type, 64 bytes
+ ddl_half, ///< Half data type.
+ ddl_float, ///< float data type
+ ddl_double, ///< Double data type.
+ ddl_string, ///< String data type.
+ ddl_ref, ///< Reference, used to define references to other data definitions.
+ ddl_types_max ///< Upper limit.
+ };
+
+ /// @brief The class constructor.
+ /// @param type [in] The value type.
+ Value( ValueType type );
+
+ /// @brief The class destructor.
+ ~Value();
+
+ /// @brief Assigns a boolean to the value.
+ /// @param value [in9 The value.
+ void setBool( bool value );
+
+ /// @brief Returns the boolean value.
+ /// @return The boolean value.
+ bool getBool();
+
+ /// @brief Assigns a int8 to the value.
+ /// @param value [in] The value.
+ void setInt8( int8 value );
+
+ /// @brief Returns the int8 value.
+ /// @return The int8 value.
+ int8 getInt8();
+
+ /// @brief Assigns a int16 to the value.
+ /// @param value [in] The value.
+ void setInt16( int16 value );
+
+ /// @brief Returns the int16 value.
+ /// @return The int16 value.
+ int16 getInt16();
+
+ /// @brief Assigns a int32 to the value.
+ /// @param value [in] The value.
+ void setInt32( int32 value );
+
+ /// @brief Returns the int16 value.
+ /// @return The int32 value.
+ int32 getInt32();
+
+ /// @brief Assigns a int64 to the value.
+ /// @param value [in] The value.
+ void setInt64( int64 value );
+
+ /// @brief Returns the int16 value.
+ /// @return The int64 value.
+ int64 getInt64();
+
+ /// @brief Assigns a unsigned int8 to the value.
+ /// @param value [in] The value.
+ void setUnsignedInt8( uint8 value );
+
+ /// @brief Returns the unsigned int8 value.
+ /// @return The unsigned int8 value.
+ uint8 getUnsignedInt8() const;
+
+ /// @brief Assigns a unsigned int16 to the value.
+ /// @param value [in] The value.
+ void setUnsignedInt16( uint16 value );
+
+ /// @brief Returns the unsigned int16 value.
+ /// @return The unsigned int16 value.
+ uint16 getUnsignedInt16() const;
+
+ /// @brief Assigns a unsigned int32 to the value.
+ /// @param value [in] The value.
+ void setUnsignedInt32( uint32 value );
+
+ /// @brief Returns the unsigned int8 value.
+ /// @return The unsigned int32 value.
+ uint32 getUnsignedInt32() const;
+
+ /// @brief Assigns a unsigned int64 to the value.
+ /// @param value [in] The value.
+ void setUnsignedInt64( uint64 value );
+
+ /// @brief Returns the unsigned int64 value.
+ /// @return The unsigned int64 value.
+ uint64 getUnsignedInt64() const;
+
+ /// @brief Assigns a float to the value.
+ /// @param value [in] The value.
+ void setFloat( float value );
+
+ /// @brief Returns the float value.
+ /// @return The float value.
+ float getFloat() const;
+
+ /// @brief Assigns a double to the value.
+ /// @param value [in] The value.
+ void setDouble( double value );
+
+ /// @brief Returns the double value.
+ /// @return The double value.
+ double getDouble() const;
+
+ /// @brief Assigns a std::string to the value.
+ /// @param str [in] The value.
+ void setString( const std::string &str );
+
+ /// @brief Returns the std::string value.
+ /// @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.
+ /// @param stream [in] The stream to write in.
+ void dump( IOStreamBase &stream );
+
+ /// @brief Assigns the next value.
+ /// @param next [n] The next value.
+ void setNext( Value *next );
+
+ /// @brief Returns the next value.
+ /// @return The next value.s
+ Value *getNext() const;
+
+ /// @brief Gets the length of the array.
+ /// @return The number of items in the array.
+ size_t size() const;
+
+ ValueType m_type;
+ size_t m_size;
+ unsigned char *m_data;
+ Value *m_next;
+
+private:
+ Value &operator =( const Value & ) ddl_no_copy;
+ Value( const Value & ) ddl_no_copy;
+};
+
+///------------------------------------------------------------------------------------------------
+/// @brief This class implements the value allocator.
+///------------------------------------------------------------------------------------------------
+struct DLL_ODDLPARSER_EXPORT ValueAllocator {
+ static Value *allocPrimData( Value::ValueType type, size_t len = 1 );
+ static void releasePrimData( Value **data );
+
+private:
+ ValueAllocator() ddl_no_copy;
+ ValueAllocator( const ValueAllocator & ) ddl_no_copy;
+ ValueAllocator &operator = ( const ValueAllocator & ) ddl_no_copy;
+};
+
+END_ODDLPARSER_NS