diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index a3333ba7557..8ba35ce8ec3 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -7,7 +7,7 @@ include(../source_files/cmake_engine.txt) # Define engine library add_library(engine ${source_files}) -target_include_directories(engine PUBLIC . ./util) +target_include_directories(engine PUBLIC . ./include ./lib) # Make cmake selections visible to C++ code if(SC_NO_THREADING) diff --git a/engine/Makefile b/engine/Makefile index 011b10c674e..5d5027cc6ad 100644 --- a/engine/Makefile +++ b/engine/Makefile @@ -55,7 +55,7 @@ endif MKDIR = mkdir CXX = c++ -CPP_FLAGS = -Wall -Wextra -W -I. -I./util -DSC_SHARED_DATA=\"$(SHARED_DATA)\" --std=c++14 -O3 -MMD -MP \ +CPP_FLAGS = -Wall -Wextra -W -I. -I./include -I./lib -DSC_SHARED_DATA=\"$(SHARED_DATA)\" --std=c++14 -O3 -MMD -MP \ -Wpedantic \ -Wcast-qual \ -Wconversion-null diff --git a/engine/action/sc_action.hpp b/engine/action/sc_action.hpp index 06bd32fa008..8d4dd1570a7 100644 --- a/engine/action/sc_action.hpp +++ b/engine/action/sc_action.hpp @@ -6,7 +6,7 @@ #pragma once #include "config.hpp" -#include "generic.hpp" +#include "util/generic.hpp" #include "sc_enums.hpp" #include "sc_timespan.hpp" #include "player/target_specific.hpp" diff --git a/engine/action/sc_action_state.hpp b/engine/action/sc_action_state.hpp index 09bab3f01f9..9b9081d86c7 100644 --- a/engine/action/sc_action_state.hpp +++ b/engine/action/sc_action_state.hpp @@ -9,7 +9,7 @@ #include #include #include "config.hpp" -#include "generic.hpp" +#include "util/generic.hpp" #include "sc_enums.hpp" #include "dbc/data_enums.hh" diff --git a/engine/buff/sc_buff.cpp b/engine/buff/sc_buff.cpp index c920042962e..04f147eabe5 100644 --- a/engine/buff/sc_buff.cpp +++ b/engine/buff/sc_buff.cpp @@ -10,7 +10,7 @@ #include "sim/event.hpp" #include "sim/sc_sim.hpp" #include "sim/real_ppm.hpp" -#include "rng.hpp" +#include "util/rng.hpp" #include "sim/sc_cooldown.hpp" #include "sim/sc_expressions.hpp" #include "dbc/item_database.hpp" diff --git a/engine/dbc/item_armor.hpp b/engine/dbc/item_armor.hpp index 07b58eb4cce..04cfe260dfb 100644 --- a/engine/dbc/item_armor.hpp +++ b/engine/dbc/item_armor.hpp @@ -5,7 +5,7 @@ #ifndef ITEM_ARMOR_HPP #define ITEM_ARMOR_HPP -#include "generic.hpp" +#include "util/generic.hpp" #include "util/array_view.hpp" #include "client_data.hpp" diff --git a/engine/dbc/item_weapon.hpp b/engine/dbc/item_weapon.hpp index 801b2012370..bc109fafda4 100644 --- a/engine/dbc/item_weapon.hpp +++ b/engine/dbc/item_weapon.hpp @@ -5,7 +5,7 @@ #ifndef ITEM_WEAPON_HPP #define ITEM_WEAPON_HPP -#include "generic.hpp" +#include "util/generic.hpp" #include "util/array_view.hpp" #include "client_data.hpp" diff --git a/engine/interfaces/sc_bcp_api.cpp b/engine/interfaces/sc_bcp_api.cpp index ffe524bf253..a0ad6a0d044 100644 --- a/engine/interfaces/sc_bcp_api.cpp +++ b/engine/interfaces/sc_bcp_api.cpp @@ -5,11 +5,11 @@ #include "simulationcraft.hpp" -#include "util/rapidjson/document.h" -#include "util/rapidjson/stringbuffer.h" -#include "util/rapidjson/prettywriter.h" +#include "rapidjson/document.h" +#include "rapidjson/stringbuffer.h" +#include "rapidjson/prettywriter.h" -#include "../util/utf8-h/utf8.h" +#include "utf8-h/utf8.h" // ========================================================================== // Blizzard Community Platform API diff --git a/engine/interfaces/sc_js.hpp b/engine/interfaces/sc_js.hpp index 76d43f42b87..b6b449f8753 100644 --- a/engine/interfaces/sc_js.hpp +++ b/engine/interfaces/sc_js.hpp @@ -9,9 +9,9 @@ #define RAPIDJSON_HAS_STDSTRING 1 #endif -#include "util/rapidjson/document.h" -#include "util/rapidjson/stringbuffer.h" -#include "util/rapidjson/prettywriter.h" +#include "rapidjson/document.h" +#include "rapidjson/stringbuffer.h" +#include "rapidjson/prettywriter.h" #include #include #include diff --git a/engine/interfaces/wowhead.cpp b/engine/interfaces/wowhead.cpp index 9e3126cb2c0..1f04afe9724 100644 --- a/engine/interfaces/wowhead.cpp +++ b/engine/interfaces/wowhead.cpp @@ -6,9 +6,10 @@ #include "wowhead.hpp" #include "simulationcraft.hpp" -#include "util/rapidjson/document.h" -#include "util/rapidjson/stringbuffer.h" -#include "util/rapidjson/prettywriter.h" +#include "rapidjson/document.h" +#include "rapidjson/stringbuffer.h" +#include "rapidjson/prettywriter.h" +#include "rapidjson/prettywriter.h" namespace { // source_str =============================================================== diff --git a/engine/item/item.hpp b/engine/item/item.hpp index a22e59514eb..127ae6d8b17 100644 --- a/engine/item/item.hpp +++ b/engine/item/item.hpp @@ -6,7 +6,7 @@ #pragma once #include "config.hpp" -#include "generic.hpp" +#include "util/generic.hpp" #include "sc_enums.hpp" #include "player/gear_stats.hpp" #include "sc_timespan.hpp" diff --git a/engine/util/fmt/README.md b/engine/lib/fmt/README.md similarity index 100% rename from engine/util/fmt/README.md rename to engine/lib/fmt/README.md diff --git a/engine/util/fmt/chrono.h b/engine/lib/fmt/chrono.h similarity index 100% rename from engine/util/fmt/chrono.h rename to engine/lib/fmt/chrono.h diff --git a/engine/util/fmt/color.h b/engine/lib/fmt/color.h similarity index 100% rename from engine/util/fmt/color.h rename to engine/lib/fmt/color.h diff --git a/engine/util/fmt/compile.h b/engine/lib/fmt/compile.h similarity index 100% rename from engine/util/fmt/compile.h rename to engine/lib/fmt/compile.h diff --git a/engine/util/fmt/core.h b/engine/lib/fmt/core.h similarity index 100% rename from engine/util/fmt/core.h rename to engine/lib/fmt/core.h diff --git a/engine/util/fmt/format-inl.h b/engine/lib/fmt/format-inl.h similarity index 100% rename from engine/util/fmt/format-inl.h rename to engine/lib/fmt/format-inl.h diff --git a/engine/util/fmt/format.cpp b/engine/lib/fmt/format.cpp similarity index 100% rename from engine/util/fmt/format.cpp rename to engine/lib/fmt/format.cpp diff --git a/engine/util/fmt/format.h b/engine/lib/fmt/format.h similarity index 100% rename from engine/util/fmt/format.h rename to engine/lib/fmt/format.h diff --git a/engine/util/fmt/locale.h b/engine/lib/fmt/locale.h similarity index 100% rename from engine/util/fmt/locale.h rename to engine/lib/fmt/locale.h diff --git a/engine/util/fmt/os.cpp b/engine/lib/fmt/os.cpp similarity index 100% rename from engine/util/fmt/os.cpp rename to engine/lib/fmt/os.cpp diff --git a/engine/util/fmt/os.h b/engine/lib/fmt/os.h similarity index 100% rename from engine/util/fmt/os.h rename to engine/lib/fmt/os.h diff --git a/engine/util/fmt/ostream.h b/engine/lib/fmt/ostream.h similarity index 100% rename from engine/util/fmt/ostream.h rename to engine/lib/fmt/ostream.h diff --git a/engine/util/fmt/posix.h b/engine/lib/fmt/posix.h similarity index 100% rename from engine/util/fmt/posix.h rename to engine/lib/fmt/posix.h diff --git a/engine/util/fmt/printf.h b/engine/lib/fmt/printf.h similarity index 100% rename from engine/util/fmt/printf.h rename to engine/lib/fmt/printf.h diff --git a/engine/util/fmt/ranges.h b/engine/lib/fmt/ranges.h similarity index 100% rename from engine/util/fmt/ranges.h rename to engine/lib/fmt/ranges.h diff --git a/engine/util/gsl-lite/README.md b/engine/lib/gsl-lite/README.md similarity index 100% rename from engine/util/gsl-lite/README.md rename to engine/lib/gsl-lite/README.md diff --git a/engine/util/gsl-lite/gsl-lite.hpp b/engine/lib/gsl-lite/gsl-lite.hpp similarity index 100% rename from engine/util/gsl-lite/gsl-lite.hpp rename to engine/lib/gsl-lite/gsl-lite.hpp diff --git a/engine/util/rapidjson/allocators.h b/engine/lib/rapidjson/allocators.h similarity index 100% rename from engine/util/rapidjson/allocators.h rename to engine/lib/rapidjson/allocators.h diff --git a/engine/util/rapidjson/document.h b/engine/lib/rapidjson/document.h similarity index 100% rename from engine/util/rapidjson/document.h rename to engine/lib/rapidjson/document.h diff --git a/engine/util/rapidjson/encodedstream.h b/engine/lib/rapidjson/encodedstream.h similarity index 100% rename from engine/util/rapidjson/encodedstream.h rename to engine/lib/rapidjson/encodedstream.h diff --git a/engine/util/rapidjson/encodings.h b/engine/lib/rapidjson/encodings.h similarity index 100% rename from engine/util/rapidjson/encodings.h rename to engine/lib/rapidjson/encodings.h diff --git a/engine/util/rapidjson/error/en.h b/engine/lib/rapidjson/error/en.h similarity index 100% rename from engine/util/rapidjson/error/en.h rename to engine/lib/rapidjson/error/en.h diff --git a/engine/util/rapidjson/error/error.h b/engine/lib/rapidjson/error/error.h similarity index 100% rename from engine/util/rapidjson/error/error.h rename to engine/lib/rapidjson/error/error.h diff --git a/engine/util/rapidjson/filereadstream.h b/engine/lib/rapidjson/filereadstream.h similarity index 100% rename from engine/util/rapidjson/filereadstream.h rename to engine/lib/rapidjson/filereadstream.h diff --git a/engine/util/rapidjson/filestream.h b/engine/lib/rapidjson/filestream.h similarity index 100% rename from engine/util/rapidjson/filestream.h rename to engine/lib/rapidjson/filestream.h diff --git a/engine/util/rapidjson/filewritestream.h b/engine/lib/rapidjson/filewritestream.h similarity index 100% rename from engine/util/rapidjson/filewritestream.h rename to engine/lib/rapidjson/filewritestream.h diff --git a/engine/util/rapidjson/fwd.h b/engine/lib/rapidjson/fwd.h similarity index 100% rename from engine/util/rapidjson/fwd.h rename to engine/lib/rapidjson/fwd.h diff --git a/engine/util/rapidjson/internal/biginteger.h b/engine/lib/rapidjson/internal/biginteger.h old mode 100755 new mode 100644 similarity index 100% rename from engine/util/rapidjson/internal/biginteger.h rename to engine/lib/rapidjson/internal/biginteger.h diff --git a/engine/util/rapidjson/internal/diyfp.h b/engine/lib/rapidjson/internal/diyfp.h similarity index 100% rename from engine/util/rapidjson/internal/diyfp.h rename to engine/lib/rapidjson/internal/diyfp.h diff --git a/engine/util/rapidjson/internal/dtoa.h b/engine/lib/rapidjson/internal/dtoa.h similarity index 100% rename from engine/util/rapidjson/internal/dtoa.h rename to engine/lib/rapidjson/internal/dtoa.h diff --git a/engine/util/rapidjson/internal/ieee754.h b/engine/lib/rapidjson/internal/ieee754.h similarity index 100% rename from engine/util/rapidjson/internal/ieee754.h rename to engine/lib/rapidjson/internal/ieee754.h diff --git a/engine/util/rapidjson/internal/itoa.h b/engine/lib/rapidjson/internal/itoa.h similarity index 100% rename from engine/util/rapidjson/internal/itoa.h rename to engine/lib/rapidjson/internal/itoa.h diff --git a/engine/util/rapidjson/internal/meta.h b/engine/lib/rapidjson/internal/meta.h similarity index 100% rename from engine/util/rapidjson/internal/meta.h rename to engine/lib/rapidjson/internal/meta.h diff --git a/engine/util/rapidjson/internal/pow10.h b/engine/lib/rapidjson/internal/pow10.h similarity index 100% rename from engine/util/rapidjson/internal/pow10.h rename to engine/lib/rapidjson/internal/pow10.h diff --git a/engine/util/rapidjson/internal/regex.h b/engine/lib/rapidjson/internal/regex.h similarity index 100% rename from engine/util/rapidjson/internal/regex.h rename to engine/lib/rapidjson/internal/regex.h diff --git a/engine/util/rapidjson/internal/stack.h b/engine/lib/rapidjson/internal/stack.h similarity index 100% rename from engine/util/rapidjson/internal/stack.h rename to engine/lib/rapidjson/internal/stack.h diff --git a/engine/util/rapidjson/internal/strfunc.h b/engine/lib/rapidjson/internal/strfunc.h similarity index 100% rename from engine/util/rapidjson/internal/strfunc.h rename to engine/lib/rapidjson/internal/strfunc.h diff --git a/engine/util/rapidjson/internal/strtod.h b/engine/lib/rapidjson/internal/strtod.h similarity index 100% rename from engine/util/rapidjson/internal/strtod.h rename to engine/lib/rapidjson/internal/strtod.h diff --git a/engine/util/rapidjson/internal/swap.h b/engine/lib/rapidjson/internal/swap.h similarity index 100% rename from engine/util/rapidjson/internal/swap.h rename to engine/lib/rapidjson/internal/swap.h diff --git a/engine/util/rapidjson/istreamwrapper.h b/engine/lib/rapidjson/istreamwrapper.h similarity index 100% rename from engine/util/rapidjson/istreamwrapper.h rename to engine/lib/rapidjson/istreamwrapper.h diff --git a/engine/util/rapidjson/memorybuffer.h b/engine/lib/rapidjson/memorybuffer.h similarity index 100% rename from engine/util/rapidjson/memorybuffer.h rename to engine/lib/rapidjson/memorybuffer.h diff --git a/engine/util/rapidjson/memorystream.h b/engine/lib/rapidjson/memorystream.h similarity index 100% rename from engine/util/rapidjson/memorystream.h rename to engine/lib/rapidjson/memorystream.h diff --git a/engine/util/rapidjson/ostreamwrapper.h b/engine/lib/rapidjson/ostreamwrapper.h similarity index 100% rename from engine/util/rapidjson/ostreamwrapper.h rename to engine/lib/rapidjson/ostreamwrapper.h diff --git a/engine/util/rapidjson/pointer.h b/engine/lib/rapidjson/pointer.h similarity index 100% rename from engine/util/rapidjson/pointer.h rename to engine/lib/rapidjson/pointer.h diff --git a/engine/util/rapidjson/prettywriter.h b/engine/lib/rapidjson/prettywriter.h similarity index 100% rename from engine/util/rapidjson/prettywriter.h rename to engine/lib/rapidjson/prettywriter.h diff --git a/engine/util/rapidjson/rapidjson.h b/engine/lib/rapidjson/rapidjson.h similarity index 100% rename from engine/util/rapidjson/rapidjson.h rename to engine/lib/rapidjson/rapidjson.h diff --git a/engine/util/rapidjson/reader.h b/engine/lib/rapidjson/reader.h similarity index 100% rename from engine/util/rapidjson/reader.h rename to engine/lib/rapidjson/reader.h diff --git a/engine/util/rapidjson/schema.h b/engine/lib/rapidjson/schema.h similarity index 100% rename from engine/util/rapidjson/schema.h rename to engine/lib/rapidjson/schema.h diff --git a/engine/util/rapidjson/stream.h b/engine/lib/rapidjson/stream.h similarity index 100% rename from engine/util/rapidjson/stream.h rename to engine/lib/rapidjson/stream.h diff --git a/engine/util/rapidjson/stringbuffer.h b/engine/lib/rapidjson/stringbuffer.h similarity index 100% rename from engine/util/rapidjson/stringbuffer.h rename to engine/lib/rapidjson/stringbuffer.h diff --git a/engine/util/rapidjson/writer.h b/engine/lib/rapidjson/writer.h similarity index 100% rename from engine/util/rapidjson/writer.h rename to engine/lib/rapidjson/writer.h diff --git a/engine/util/rapidxml/rapidxml.hpp b/engine/lib/rapidxml/rapidxml.hpp similarity index 97% rename from engine/util/rapidxml/rapidxml.hpp rename to engine/lib/rapidxml/rapidxml.hpp index 55777a983dd..6d8db12de3c 100644 --- a/engine/util/rapidxml/rapidxml.hpp +++ b/engine/lib/rapidxml/rapidxml.hpp @@ -1,2596 +1,2596 @@ -#ifndef RAPIDXML_HPP_INCLUDED -#define RAPIDXML_HPP_INCLUDED - -// Copyright (C) 2006, 2009 Marcin Kalicinski -// Version 1.13 -// Revision $DateTime: 2009/05/13 01:46:17 $ -//! \file rapidxml.hpp This file contains rapidxml parser and DOM implementation - -// If standard library is disabled, user must provide implementations of required functions and typedefs -#if !defined(RAPIDXML_NO_STDLIB) - #include // For std::size_t - #include // For assert - #include // For placement new -#endif - -// On MSVC, disable "conditional expression is constant" warning (level 4). -// This warning is almost impossible to avoid with certain types of templated code -#ifdef _MSC_VER - #pragma warning(push) - #pragma warning(disable:4127) // Conditional expression is constant -#endif - -/////////////////////////////////////////////////////////////////////////// -// RAPIDXML_PARSE_ERROR - -#if defined(RAPIDXML_NO_EXCEPTIONS) - -#define RAPIDXML_PARSE_ERROR(what, where) { parse_error_handler(what, where); assert(0); } - -namespace rapidxml -{ - //! When exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, - //! this function is called to notify user about the error. - //! It must be defined by the user. - //!

- //! This function cannot return. If it does, the results are undefined. - //!

- //! A very simple definition might look like that: - //!
-    //! void %rapidxml::%parse_error_handler(const char *what, void *where)
-    //! {
-    //!     std::cout << "Parse error: " << what << "\n";
-    //!     std::abort();
-    //! }
-    //! 
- //! \param what Human readable description of the error. - //! \param where Pointer to character data where error was detected. - void parse_error_handler(const char *what, void *where); -} - -#else - -#include // For std::exception - -#define RAPIDXML_PARSE_ERROR(what, where) throw parse_error(what, where) - -namespace rapidxml -{ - - //! Parse error exception. - //! This exception is thrown by the parser when an error occurs. - //! Use what() function to get human-readable error message. - //! Use where() function to get a pointer to position within source text where error was detected. - //!

- //! If throwing exceptions by the parser is undesirable, - //! it can be disabled by defining RAPIDXML_NO_EXCEPTIONS macro before rapidxml.hpp is included. - //! This will cause the parser to call rapidxml::parse_error_handler() function instead of throwing an exception. - //! This function must be defined by the user. - //!

- //! This class derives from std::exception class. - class parse_error: public std::exception - { - - public: - - //! Constructs parse error - parse_error(const char *what, void *where) - : m_what(what) - , m_where(where) - { - } - - //! Gets human readable description of error. - //! \return Pointer to null terminated description of the error. - virtual const char *what() const throw() override - { - return m_what; - } - - //! Gets pointer to character data where error happened. - //! Ch should be the same as char type of xml_document that produced the error. - //! \return Pointer to location within the parsed string where error occured. - template - Ch *where() const - { - return reinterpret_cast(m_where); - } - - private: - - const char *m_what; - void *m_where; - - }; -} - -#endif - -/////////////////////////////////////////////////////////////////////////// -// Pool sizes - -#ifndef RAPIDXML_STATIC_POOL_SIZE - // Size of static memory block of memory_pool. - // Define RAPIDXML_STATIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value. - // No dynamic memory allocations are performed by memory_pool until static memory is exhausted. - #define RAPIDXML_STATIC_POOL_SIZE (64 * 1024) -#endif - -#ifndef RAPIDXML_DYNAMIC_POOL_SIZE - // Size of dynamic memory block of memory_pool. - // Define RAPIDXML_DYNAMIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value. - // After the static block is exhausted, dynamic blocks with approximately this size are allocated by memory_pool. - #define RAPIDXML_DYNAMIC_POOL_SIZE (64 * 1024) -#endif - -#ifndef RAPIDXML_ALIGNMENT - // Memory allocation alignment. - // Define RAPIDXML_ALIGNMENT before including rapidxml.hpp if you want to override the default value, which is the size of pointer. - // All memory allocations for nodes, attributes and strings will be aligned to this value. - // This must be a power of 2 and at least 1, otherwise memory_pool will not work. - #define RAPIDXML_ALIGNMENT sizeof(void *) -#endif - -namespace rapidxml -{ - // Forward declarations - template class xml_node; - template class xml_attribute; - template class xml_document; - - //! Enumeration listing all node types produced by the parser. - //! Use xml_node::type() function to query node type. - enum node_type - { - node_document, //!< A document node. Name and value are empty. - node_element, //!< An element node. Name contains element name. Value contains text of first data node. - node_data, //!< A data node. Name is empty. Value contains data text. - node_cdata, //!< A CDATA node. Name is empty. Value contains data text. - node_comment, //!< A comment node. Name is empty. Value contains comment text. - node_declaration, //!< A declaration node. Name and value are empty. Declaration parameters (version, encoding and standalone) are in node attributes. - node_doctype, //!< A DOCTYPE node. Name is empty. Value contains DOCTYPE text. - node_pi //!< A PI node. Name contains target. Value contains instructions. - }; - - /////////////////////////////////////////////////////////////////////// - // Parsing flags - - //! Parse flag instructing the parser to not create data nodes. - //! Text of first data node will still be placed in value of parent element, unless rapidxml::parse_no_element_values flag is also specified. - //! Can be combined with other flags by use of | operator. - //!

- //! See xml_document::parse() function. - const int parse_no_data_nodes = 0x1; - - //! Parse flag instructing the parser to not use text of first data node as a value of parent element. - //! Can be combined with other flags by use of | operator. - //! Note that child data nodes of element node take precendence over its value when printing. - //! That is, if element has one or more child data nodes and a value, the value will be ignored. - //! Use rapidxml::parse_no_data_nodes flag to prevent creation of data nodes if you want to manipulate data using values of elements. - //!

- //! See xml_document::parse() function. - const int parse_no_element_values = 0x2; - - //! Parse flag instructing the parser to not place zero terminators after strings in the source text. - //! By default zero terminators are placed, modifying source text. - //! Can be combined with other flags by use of | operator. - //!

- //! See xml_document::parse() function. - const int parse_no_string_terminators = 0x4; - - //! Parse flag instructing the parser to not translate entities in the source text. - //! By default entities are translated, modifying source text. - //! Can be combined with other flags by use of | operator. - //!

- //! See xml_document::parse() function. - const int parse_no_entity_translation = 0x8; - - //! Parse flag instructing the parser to disable UTF-8 handling and assume plain 8 bit characters. - //! By default, UTF-8 handling is enabled. - //! Can be combined with other flags by use of | operator. - //!

- //! See xml_document::parse() function. - const int parse_no_utf8 = 0x10; - - //! Parse flag instructing the parser to create XML declaration node. - //! By default, declaration node is not created. - //! Can be combined with other flags by use of | operator. - //!

- //! See xml_document::parse() function. - const int parse_declaration_node = 0x20; - - //! Parse flag instructing the parser to create comments nodes. - //! By default, comment nodes are not created. - //! Can be combined with other flags by use of | operator. - //!

- //! See xml_document::parse() function. - const int parse_comment_nodes = 0x40; - - //! Parse flag instructing the parser to create DOCTYPE node. - //! By default, doctype node is not created. - //! Although W3C specification allows at most one DOCTYPE node, RapidXml will silently accept documents with more than one. - //! Can be combined with other flags by use of | operator. - //!

- //! See xml_document::parse() function. - const int parse_doctype_node = 0x80; - - //! Parse flag instructing the parser to create PI nodes. - //! By default, PI nodes are not created. - //! Can be combined with other flags by use of | operator. - //!

- //! See xml_document::parse() function. - const int parse_pi_nodes = 0x100; - - //! Parse flag instructing the parser to validate closing tag names. - //! If not set, name inside closing tag is irrelevant to the parser. - //! By default, closing tags are not validated. - //! Can be combined with other flags by use of | operator. - //!

- //! See xml_document::parse() function. - const int parse_validate_closing_tags = 0x200; - - //! Parse flag instructing the parser to trim all leading and trailing whitespace of data nodes. - //! By default, whitespace is not trimmed. - //! This flag does not cause the parser to modify source text. - //! Can be combined with other flags by use of | operator. - //!

- //! See xml_document::parse() function. - const int parse_trim_whitespace = 0x400; - - //! Parse flag instructing the parser to condense all whitespace runs of data nodes to a single space character. - //! Trimming of leading and trailing whitespace of data is controlled by rapidxml::parse_trim_whitespace flag. - //! By default, whitespace is not normalized. - //! If this flag is specified, source text will be modified. - //! Can be combined with other flags by use of | operator. - //!

- //! See xml_document::parse() function. - const int parse_normalize_whitespace = 0x800; - - // Compound flags - - //! Parse flags which represent default behaviour of the parser. - //! This is always equal to 0, so that all other flags can be simply ored together. - //! Normally there is no need to inconveniently disable flags by anding with their negated (~) values. - //! This also means that meaning of each flag is a negation of the default setting. - //! For example, if flag name is rapidxml::parse_no_utf8, it means that utf-8 is enabled by default, - //! and using the flag will disable it. - //!

- //! See xml_document::parse() function. - const int parse_default = 0; - - //! A combination of parse flags that forbids any modifications of the source text. - //! This also results in faster parsing. However, note that the following will occur: - //!
    - //!
  • names and values of nodes will not be zero terminated, you have to use xml_base::name_size() and xml_base::value_size() functions to determine where name and value ends
  • - //!
  • entities will not be translated
  • - //!
  • whitespace will not be normalized
  • - //!
- //! See xml_document::parse() function. - const int parse_non_destructive = parse_no_string_terminators | parse_no_entity_translation; - - //! A combination of parse flags resulting in fastest possible parsing, without sacrificing important data. - //!

- //! See xml_document::parse() function. - const int parse_fastest = parse_non_destructive | parse_no_data_nodes; - - //! A combination of parse flags resulting in largest amount of data being extracted. - //! This usually results in slowest parsing. - //!

- //! See xml_document::parse() function. - const int parse_full = parse_declaration_node | parse_comment_nodes | parse_doctype_node | parse_pi_nodes | parse_validate_closing_tags; - - /////////////////////////////////////////////////////////////////////// - // Internals - - //! \cond internal - namespace internal - { - - // Struct that contains lookup tables for the parser - // It must be a template to allow correct linking (because it has static data members, which are defined in a header file). - template - struct lookup_tables - { - static const unsigned char lookup_whitespace[256]; // Whitespace table - static const unsigned char lookup_node_name[256]; // Node name table - static const unsigned char lookup_text[256]; // Text table - static const unsigned char lookup_text_pure_no_ws[256]; // Text table - static const unsigned char lookup_text_pure_with_ws[256]; // Text table - static const unsigned char lookup_attribute_name[256]; // Attribute name table - static const unsigned char lookup_attribute_data_1[256]; // Attribute data table with single quote - static const unsigned char lookup_attribute_data_1_pure[256]; // Attribute data table with single quote - static const unsigned char lookup_attribute_data_2[256]; // Attribute data table with double quotes - static const unsigned char lookup_attribute_data_2_pure[256]; // Attribute data table with double quotes - static const unsigned char lookup_digits[256]; // Digits - static const unsigned char lookup_upcase[256]; // To uppercase conversion table for ASCII characters - }; - - // Find length of the string - template - inline std::size_t measure(const Ch *p) - { - const Ch *tmp = p; - while (*tmp) - ++tmp; - return tmp - p; - } - - // Compare strings for equality - template - inline bool compare(const Ch *p1, std::size_t size1, const Ch *p2, std::size_t size2, bool case_sensitive) - { - if (size1 != size2) - return false; - if (case_sensitive) - { - for (const Ch *end = p1 + size1; p1 < end; ++p1, ++p2) - if (*p1 != *p2) - return false; - } - else - { - for (const Ch *end = p1 + size1; p1 < end; ++p1, ++p2) - if (lookup_tables<0>::lookup_upcase[static_cast(*p1)] != lookup_tables<0>::lookup_upcase[static_cast(*p2)]) - return false; - } - return true; - } - } - //! \endcond - - /////////////////////////////////////////////////////////////////////// - // Memory pool - - //! This class is used by the parser to create new nodes and attributes, without overheads of dynamic memory allocation. - //! In most cases, you will not need to use this class directly. - //! However, if you need to create nodes manually or modify names/values of nodes, - //! you are encouraged to use memory_pool of relevant xml_document to allocate the memory. - //! Not only is this faster than allocating them by using new operator, - //! but also their lifetime will be tied to the lifetime of document, - //! possibly simplyfing memory management. - //!

- //! Call allocate_node() or allocate_attribute() functions to obtain new nodes or attributes from the pool. - //! You can also call allocate_string() function to allocate strings. - //! Such strings can then be used as names or values of nodes without worrying about their lifetime. - //! Note that there is no free() function -- all allocations are freed at once when clear() function is called, - //! or when the pool is destroyed. - //!

- //! It is also possible to create a standalone memory_pool, and use it - //! to allocate nodes, whose lifetime will not be tied to any document. - //!

- //! Pool maintains RAPIDXML_STATIC_POOL_SIZE bytes of statically allocated memory. - //! Until static memory is exhausted, no dynamic memory allocations are done. - //! When static memory is exhausted, pool allocates additional blocks of memory of size RAPIDXML_DYNAMIC_POOL_SIZE each, - //! by using global new[] and delete[] operators. - //! This behaviour can be changed by setting custom allocation routines. - //! Use set_allocator() function to set them. - //!

- //! Allocations for nodes, attributes and strings are aligned at RAPIDXML_ALIGNMENT bytes. - //! This value defaults to the size of pointer on target architecture. - //!

- //! To obtain absolutely top performance from the parser, - //! it is important that all nodes are allocated from a single, contiguous block of memory. - //! Otherwise, cache misses when jumping between two (or more) disjoint blocks of memory can slow down parsing quite considerably. - //! If required, you can tweak RAPIDXML_STATIC_POOL_SIZE, RAPIDXML_DYNAMIC_POOL_SIZE and RAPIDXML_ALIGNMENT - //! to obtain best wasted memory to performance compromise. - //! To do it, define their values before rapidxml.hpp file is included. - //! \param Ch Character type of created nodes. - template - class memory_pool - { - - public: - - //! \cond internal - typedef void *(alloc_func)(std::size_t); // Type of user-defined function used to allocate memory - typedef void (free_func)(void *); // Type of user-defined function used to free memory - //! \endcond - - //! Constructs empty pool with default allocator functions. - memory_pool() - : m_alloc_func(nullptr) - , m_free_func(nullptr) - { - init(); - } - - //! Destroys pool and frees all the memory. - //! This causes memory occupied by nodes allocated by the pool to be freed. - //! Nodes allocated from the pool are no longer valid. - ~memory_pool() - { - clear(); - } - - //! Allocates a new node from the pool, and optionally assigns name and value to it. - //! If the allocation request cannot be accomodated, this function will throw std::bad_alloc. - //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function - //! will call rapidxml::parse_error_handler() function. - //! \param type Type of node to create. - //! \param name Name to assign to the node, or 0 to assign no name. - //! \param value Value to assign to the node, or 0 to assign no value. - //! \param name_size Size of name to assign, or 0 to automatically calculate size from name string. - //! \param value_size Size of value to assign, or 0 to automatically calculate size from value string. - //! \return Pointer to allocated node. This pointer will never be NULL. - xml_node *allocate_node(node_type type, - const Ch *name = 0, const Ch *value = 0, - std::size_t name_size = 0, std::size_t value_size = 0) - { - void *memory = allocate_aligned(sizeof(xml_node)); - auto node = new(memory) xml_node(type); - if (name) - { - if (name_size > 0) - node->name(name, name_size); - else - node->name(name); - } - if (value) - { - if (value_size > 0) - node->value(value, value_size); - else - node->value(value); - } - return node; - } - - //! Allocates a new attribute from the pool, and optionally assigns name and value to it. - //! If the allocation request cannot be accomodated, this function will throw std::bad_alloc. - //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function - //! will call rapidxml::parse_error_handler() function. - //! \param name Name to assign to the attribute, or 0 to assign no name. - //! \param value Value to assign to the attribute, or 0 to assign no value. - //! \param name_size Size of name to assign, or 0 to automatically calculate size from name string. - //! \param value_size Size of value to assign, or 0 to automatically calculate size from value string. - //! \return Pointer to allocated attribute. This pointer will never be NULL. - xml_attribute *allocate_attribute(const Ch *name = 0, const Ch *value = 0, - std::size_t name_size = 0, std::size_t value_size = 0) - { - void *memory = allocate_aligned(sizeof(xml_attribute)); - auto attribute = new(memory) xml_attribute; - if (name) - { - if (name_size > 0) - attribute->name(name, name_size); - else - attribute->name(name); - } - if (value) - { - if (value_size > 0) - attribute->value(value, value_size); - else - attribute->value(value); - } - return attribute; - } - - //! Allocates a char array of given size from the pool, and optionally copies a given string to it. - //! If the allocation request cannot be accomodated, this function will throw std::bad_alloc. - //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function - //! will call rapidxml::parse_error_handler() function. - //! \param source String to initialize the allocated memory with, or 0 to not initialize it. - //! \param size Number of characters to allocate, or zero to calculate it automatically from source string length; if size is 0, source string must be specified and null terminated. - //! \return Pointer to allocated char array. This pointer will never be NULL. - Ch *allocate_string(const Ch *source = 0, std::size_t size = 0) - { - assert(source || size); // Either source or size (or both) must be specified - if (size == 0) - size = internal::measure(source) + 1; - Ch *result = static_cast(allocate_aligned(size * sizeof(Ch))); - if (source) - for (std::size_t i = 0; i < size; ++i) - result[i] = source[i]; - return result; - } - - //! Clones an xml_node and its hierarchy of child nodes and attributes. - //! Nodes and attributes are allocated from this memory pool. - //! Names and values are not cloned, they are shared between the clone and the source. - //! Result node can be optionally specified as a second parameter, - //! in which case its contents will be replaced with cloned source node. - //! This is useful when you want to clone entire document. - //! \param source Node to clone. - //! \param result Node to put results in, or 0 to automatically allocate result node - //! \return Pointer to cloned node. This pointer will never be NULL. - xml_node *clone_node(const xml_node *source, xml_node *result = 0) - { - // Prepare result node - if (result) - { - result->remove_all_attributes(); - result->remove_all_nodes(); - result->type(source->type()); - } - else - result = allocate_node(source->type()); - - // Clone name and value - result->name(source->name(), source->name_size()); - result->value(source->value(), source->value_size()); - - // Clone child nodes and attributes - for (xml_node *child = source->first_node(); child; child = child->next_sibling()) - result->append_node(clone_node(child)); - for (xml_attribute *attr = source->first_attribute(); attr; attr = attr->next_attribute()) - result->append_attribute(allocate_attribute(attr->name(), attr->value(), attr->name_size(), attr->value_size())); - - return result; - } - - //! Clears the pool. - //! This causes memory occupied by nodes allocated by the pool to be freed. - //! Any nodes or strings allocated from the pool will no longer be valid. - void clear() - { - while (m_begin != m_static_memory) - { - char *previous_begin = reinterpret_cast
(align(m_begin))->previous_begin; - if (m_free_func) - m_free_func(m_begin); - else - delete[] m_begin; - m_begin = previous_begin; - } - init(); - } - - //! Sets or resets the user-defined memory allocation functions for the pool. - //! This can only be called when no memory is allocated from the pool yet, otherwise results are undefined. - //! Allocation function must not return invalid pointer on failure. It should either throw, - //! stop the program, or use longjmp() function to pass control to other place of program. - //! If it returns invalid pointer, results are undefined. - //!

- //! User defined allocation functions must have the following forms: - //!
- //!
void *allocate(std::size_t size); - //!
void free(void *pointer); - //!

- //! \param af Allocation function, or 0 to restore default function - //! \param ff Free function, or 0 to restore default function - void set_allocator(alloc_func *af, free_func *ff) - { - assert(m_begin == m_static_memory && m_ptr == align(m_begin)); // Verify that no memory is allocated yet - m_alloc_func = af; - m_free_func = ff; - } - - private: - - struct header - { - char *previous_begin; - }; - - void init() - { - m_begin = m_static_memory; - m_ptr = align(m_begin); - m_end = m_static_memory + sizeof(m_static_memory); - } - - char *align(char *ptr) - { - std::size_t alignment = ((RAPIDXML_ALIGNMENT - (std::size_t(ptr) & (RAPIDXML_ALIGNMENT - 1))) & (RAPIDXML_ALIGNMENT - 1)); - return ptr + alignment; - } - - char *allocate_raw(std::size_t size) - { - // Allocate - void *memory; - if (m_alloc_func) // Allocate memory using either user-specified allocation function or global operator new[] - { - memory = m_alloc_func(size); - assert(memory); // Allocator is not allowed to return 0, on failure it must either throw, stop the program or use longjmp - } - else - { - memory = new char[size]; -#ifdef RAPIDXML_NO_EXCEPTIONS - if (!memory) // If exceptions are disabled, verify memory allocation, because new will not be able to throw bad_alloc - RAPIDXML_PARSE_ERROR("out of memory", 0); -#endif - } - return static_cast(memory); - } - - void *allocate_aligned(std::size_t size) - { - // Calculate aligned pointer - char *result = align(m_ptr); - - // If not enough memory left in current pool, allocate a new pool - if (result + size > m_end) - { - // Calculate required pool size (may be bigger than RAPIDXML_DYNAMIC_POOL_SIZE) - std::size_t pool_size = RAPIDXML_DYNAMIC_POOL_SIZE; - if (pool_size < size) - pool_size = size; - - // Allocate - std::size_t alloc_size = sizeof(header) + (2 * RAPIDXML_ALIGNMENT - 2) + pool_size; // 2 alignments required in worst case: one for header, one for actual allocation - char *raw_memory = allocate_raw(alloc_size); - - // Setup new pool in allocated memory - char *pool = align(raw_memory); - header *new_header = reinterpret_cast
(pool); - new_header->previous_begin = m_begin; - m_begin = raw_memory; - m_ptr = pool + sizeof(header); - m_end = raw_memory + alloc_size; - - // Calculate aligned pointer again using new pool - result = align(m_ptr); - } - - // Update pool and return aligned pointer - m_ptr = result + size; - return result; - } - - char *m_begin; // Start of raw memory making up current pool - char *m_ptr; // First free byte in current pool - char *m_end; // One past last available byte in current pool - char m_static_memory[RAPIDXML_STATIC_POOL_SIZE]; // Static raw memory - alloc_func *m_alloc_func; // Allocator function, or 0 if default is to be used - free_func *m_free_func; // Free function, or 0 if default is to be used - }; - - /////////////////////////////////////////////////////////////////////////// - // XML base - - //! Base class for xml_node and xml_attribute implementing common functions: - //! name(), name_size(), value(), value_size() and parent(). - //! \param Ch Character type to use - template - class xml_base - { - - public: - - /////////////////////////////////////////////////////////////////////////// - // Construction & destruction - - // Construct a base with empty name, value and parent - xml_base() - : m_name(0) - , m_value(0) - , m_parent(0) - { - } - - /////////////////////////////////////////////////////////////////////////// - // Node data access - - //! Gets name of the node. - //! Interpretation of name depends on type of node. - //! Note that name will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse. - //!

- //! Use name_size() function to determine length of the name. - //! \return Name of node, or empty string if node has no name. - Ch *name() const - { - return m_name ? m_name : nullstr(); - } - - //! Gets size of node name, not including terminator character. - //! This function works correctly irrespective of whether name is or is not zero terminated. - //! \return Size of node name, in characters. - std::size_t name_size() const - { - return m_name ? m_name_size : 0; - } - - //! Gets value of node. - //! Interpretation of value depends on type of node. - //! Note that value will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse. - //!

- //! Use value_size() function to determine length of the value. - //! \return Value of node, or empty string if node has no value. - Ch *value() const - { - return m_value ? m_value : nullstr(); - } - - //! Gets size of node value, not including terminator character. - //! This function works correctly irrespective of whether value is or is not zero terminated. - //! \return Size of node value, in characters. - std::size_t value_size() const - { - return m_value ? m_value_size : 0; - } - - /////////////////////////////////////////////////////////////////////////// - // Node modification - - //! Sets name of node to a non zero-terminated string. - //! See \ref ownership_of_strings. - //!

- //! Note that node does not own its name or value, it only stores a pointer to it. - //! It will not delete or otherwise free the pointer on destruction. - //! It is reponsibility of the user to properly manage lifetime of the string. - //! The easiest way to achieve it is to use memory_pool of the document to allocate the string - - //! on destruction of the document the string will be automatically freed. - //!

- //! Size of name must be specified separately, because name does not have to be zero terminated. - //! Use name(const Ch *) function to have the length automatically calculated (string must be zero terminated). - //! \param name Name of node to set. Does not have to be zero terminated. - //! \param size Size of name, in characters. This does not include zero terminator, if one is present. - void name(const Ch *name, std::size_t size) - { - m_name = const_cast(name); - m_name_size = size; - } - - //! Sets name of node to a zero-terminated string. - //! See also \ref ownership_of_strings and xml_node::name(const Ch *, std::size_t). - //! \param name Name of node to set. Must be zero terminated. - void name(const Ch *name) - { - this->name(name, internal::measure(name)); - } - - //! Sets value of node to a non zero-terminated string. - //! See \ref ownership_of_strings. - //!

- //! Note that node does not own its name or value, it only stores a pointer to it. - //! It will not delete or otherwise free the pointer on destruction. - //! It is reponsibility of the user to properly manage lifetime of the string. - //! The easiest way to achieve it is to use memory_pool of the document to allocate the string - - //! on destruction of the document the string will be automatically freed. - //!

- //! Size of value must be specified separately, because it does not have to be zero terminated. - //! Use value(const Ch *) function to have the length automatically calculated (string must be zero terminated). - //!

- //! If an element has a child node of type node_data, it will take precedence over element value when printing. - //! If you want to manipulate data of elements using values, use parser flag rapidxml::parse_no_data_nodes to prevent creation of data nodes by the parser. - //! \param value value of node to set. Does not have to be zero terminated. - //! \param size Size of value, in characters. This does not include zero terminator, if one is present. - void value(const Ch *value, std::size_t size) - { - m_value = const_cast(value); - m_value_size = size; - } - - //! Sets value of node to a zero-terminated string. - //! See also \ref ownership_of_strings and xml_node::value(const Ch *, std::size_t). - //! \param value Vame of node to set. Must be zero terminated. - void value(const Ch *value) - { - this->value(value, internal::measure(value)); - } - - /////////////////////////////////////////////////////////////////////////// - // Related nodes access - - //! Gets node parent. - //! \return Pointer to parent node, or 0 if there is no parent. - xml_node *parent() const - { - return m_parent; - } - - protected: - - // Return empty string - static Ch *nullstr() - { - static Ch zero = Ch('\0'); - return &zero; - } - - Ch *m_name; // Name of node, or 0 if no name - Ch *m_value; // Value of node, or 0 if no value - std::size_t m_name_size; // Length of node name, or undefined of no name - std::size_t m_value_size; // Length of node value, or undefined if no value - xml_node *m_parent; // Pointer to parent node, or 0 if none - - }; - - //! Class representing attribute node of XML document. - //! Each attribute has name and value strings, which are available through name() and value() functions (inherited from xml_base). - //! Note that after parse, both name and value of attribute will point to interior of source text used for parsing. - //! Thus, this text must persist in memory for the lifetime of attribute. - //! \param Ch Character type to use. - template - class xml_attribute: public xml_base - { - - friend class xml_node; - - public: - - /////////////////////////////////////////////////////////////////////////// - // Construction & destruction - - //! Constructs an empty attribute with the specified type. - //! Consider using memory_pool of appropriate xml_document if allocating attributes manually. - xml_attribute() - { - } - - /////////////////////////////////////////////////////////////////////////// - // Related nodes access - - //! Gets document of which attribute is a child. - //! \return Pointer to document that contains this attribute, or 0 if there is no parent document. - xml_document *document() const - { - if (xml_node *node = this->parent()) - { - while (node->parent()) - node = node->parent(); - return node->type() == node_document ? static_cast *>(node) : 0; - } - else - return 0; - } - - //! Gets previous attribute, optionally matching attribute name. - //! \param name Name of attribute to find, or 0 to return previous attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero - //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string - //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters - //! \return Pointer to found attribute, or 0 if not found. - xml_attribute *previous_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const - { - if (name) - { - if (name_size == 0) - name_size = internal::measure(name); - for (xml_attribute *attribute = m_prev_attribute; attribute; attribute = attribute->m_prev_attribute) - if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive)) - return attribute; - return 0; - } - else - return this->m_parent ? m_prev_attribute : 0; - } - - //! Gets next attribute, optionally matching attribute name. - //! \param name Name of attribute to find, or 0 to return next attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero - //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string - //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters - //! \return Pointer to found attribute, or 0 if not found. - xml_attribute *next_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const - { - if (name) - { - if (name_size == 0) - name_size = internal::measure(name); - for (xml_attribute *attribute = m_next_attribute; attribute; attribute = attribute->m_next_attribute) - if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive)) - return attribute; - return 0; - } - else - return this->m_parent ? m_next_attribute : 0; - } - - private: - - xml_attribute *m_prev_attribute; // Pointer to previous sibling of attribute, or 0 if none; only valid if parent is non-zero - xml_attribute *m_next_attribute; // Pointer to next sibling of attribute, or 0 if none; only valid if parent is non-zero - - }; - - /////////////////////////////////////////////////////////////////////////// - // XML node - - //! Class representing a node of XML document. - //! Each node may have associated name and value strings, which are available through name() and value() functions. - //! Interpretation of name and value depends on type of the node. - //! Type of node can be determined by using type() function. - //!

- //! Note that after parse, both name and value of node, if any, will point interior of source text used for parsing. - //! Thus, this text must persist in the memory for the lifetime of node. - //! \param Ch Character type to use. - template - class xml_node: public xml_base - { - - public: - - /////////////////////////////////////////////////////////////////////////// - // Construction & destruction - - //! Constructs an empty node with the specified type. - //! Consider using memory_pool of appropriate document to allocate nodes manually. - //! \param type Type of node to construct. - xml_node(node_type type) - : m_type(type) - , m_first_node(0) - , m_first_attribute(0) - { - } - - /////////////////////////////////////////////////////////////////////////// - // Node data access - - //! Gets type of node. - //! \return Type of node. - node_type type() const - { - return m_type; - } - - /////////////////////////////////////////////////////////////////////////// - // Related nodes access - - //! Gets document of which node is a child. - //! \return Pointer to document that contains this node, or 0 if there is no parent document. - xml_document *document() const - { - xml_node *node = const_cast *>(this); - while (node->parent()) - node = node->parent(); - return node->type() == node_document ? static_cast *>(node) : 0; - } - - //! Gets first child node, optionally matching node name. - //! \param name Name of child to find, or 0 to return first child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero - //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string - //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters - //! \return Pointer to found child, or 0 if not found. - xml_node *first_node(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const - { - if (name) - { - if (name_size == 0) - name_size = internal::measure(name); - for (xml_node *child = m_first_node; child; child = child->next_sibling()) - if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive)) - return child; - return 0; - } - else - return m_first_node; - } - - //! Gets last child node, optionally matching node name. - //! Behaviour is undefined if node has no children. - //! Use first_node() to test if node has children. - //! \param name Name of child to find, or 0 to return last child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero - //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string - //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters - //! \return Pointer to found child, or 0 if not found. - xml_node *last_node(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const - { - assert(m_first_node); // Cannot query for last child if node has no children - if (name) - { - if (name_size == 0) - name_size = internal::measure(name); - for (xml_node *child = m_last_node; child; child = child->previous_sibling()) - if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive)) - return child; - return 0; - } - else - return m_last_node; - } - - //! Gets previous sibling node, optionally matching node name. - //! Behaviour is undefined if node has no parent. - //! Use parent() to test if node has a parent. - //! \param name Name of sibling to find, or 0 to return previous sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero - //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string - //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters - //! \return Pointer to found sibling, or 0 if not found. - xml_node *previous_sibling(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const - { - assert(this->m_parent); // Cannot query for siblings if node has no parent - if (name) - { - if (name_size == 0) - name_size = internal::measure(name); - for (xml_node *sibling = m_prev_sibling; sibling; sibling = sibling->m_prev_sibling) - if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive)) - return sibling; - return 0; - } - else - return m_prev_sibling; - } - - //! Gets next sibling node, optionally matching node name. - //! Behaviour is undefined if node has no parent. - //! Use parent() to test if node has a parent. - //! \param name Name of sibling to find, or 0 to return next sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero - //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string - //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters - //! \return Pointer to found sibling, or 0 if not found. - xml_node *next_sibling(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const - { - assert(this->m_parent); // Cannot query for siblings if node has no parent - if (name) - { - if (name_size == 0) - name_size = internal::measure(name); - for (xml_node *sibling = m_next_sibling; sibling; sibling = sibling->m_next_sibling) - if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive)) - return sibling; - return 0; - } - else - return m_next_sibling; - } - - //! Gets first attribute of node, optionally matching attribute name. - //! \param name Name of attribute to find, or 0 to return first attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero - //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string - //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters - //! \return Pointer to found attribute, or 0 if not found. - xml_attribute *first_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const - { - if (name) - { - if (name_size == 0) - name_size = internal::measure(name); - for (xml_attribute *attribute = m_first_attribute; attribute; attribute = attribute->m_next_attribute) - if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive)) - return attribute; - return 0; - } - else - return m_first_attribute; - } - - //! Gets last attribute of node, optionally matching attribute name. - //! \param name Name of attribute to find, or 0 to return last attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero - //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string - //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters - //! \return Pointer to found attribute, or 0 if not found. - xml_attribute *last_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const - { - if (name) - { - if (name_size == 0) - name_size = internal::measure(name); - for (xml_attribute *attribute = m_last_attribute; attribute; attribute = attribute->m_prev_attribute) - if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive)) - return attribute; - return 0; - } - else - return m_first_attribute ? m_last_attribute : 0; - } - - /////////////////////////////////////////////////////////////////////////// - // Node modification - - //! Sets type of node. - //! \param type Type of node to set. - void type(node_type type) - { - m_type = type; - } - - /////////////////////////////////////////////////////////////////////////// - // Node manipulation - - //! Prepends a new child node. - //! The prepended child becomes the first child, and all existing children are moved one position back. - //! \param child Node to prepend. - void prepend_node(xml_node *child) - { - assert(child && !child->parent() && child->type() != node_document); - if (first_node()) - { - child->m_next_sibling = m_first_node; - m_first_node->m_prev_sibling = child; - } - else - { - child->m_next_sibling = 0; - m_last_node = child; - } - m_first_node = child; - child->m_parent = this; - child->m_prev_sibling = 0; - } - - //! Appends a new child node. - //! The appended child becomes the last child. - //! \param child Node to append. - void append_node(xml_node *child) - { - assert(child && !child->parent() && child->type() != node_document); - if (first_node()) - { - child->m_prev_sibling = m_last_node; - m_last_node->m_next_sibling = child; - } - else - { - child->m_prev_sibling = 0; - m_first_node = child; - } - m_last_node = child; - child->m_parent = this; - child->m_next_sibling = 0; - } - - //! Inserts a new child node at specified place inside the node. - //! All children after and including the specified node are moved one position back. - //! \param where Place where to insert the child, or 0 to insert at the back. - //! \param child Node to insert. - void insert_node(xml_node *where, xml_node *child) - { - assert(!where || where->parent() == this); - assert(child && !child->parent() && child->type() != node_document); - if (where == m_first_node) - prepend_node(child); - else if (where == 0) - append_node(child); - else - { - child->m_prev_sibling = where->m_prev_sibling; - child->m_next_sibling = where; - where->m_prev_sibling->m_next_sibling = child; - where->m_prev_sibling = child; - child->m_parent = this; - } - } - - //! Removes first child node. - //! If node has no children, behaviour is undefined. - //! Use first_node() to test if node has children. - void remove_first_node() - { - assert(first_node()); - xml_node *child = m_first_node; - m_first_node = child->m_next_sibling; - if (child->m_next_sibling) - child->m_next_sibling->m_prev_sibling = 0; - else - m_last_node = 0; - child->m_parent = 0; - } - - //! Removes last child of the node. - //! If node has no children, behaviour is undefined. - //! Use first_node() to test if node has children. - void remove_last_node() - { - assert(first_node()); - xml_node *child = m_last_node; - if (child->m_prev_sibling) - { - m_last_node = child->m_prev_sibling; - child->m_prev_sibling->m_next_sibling = 0; - } - else - m_first_node = 0; - child->m_parent = 0; - } - - //! Removes specified child from the node - // \param where Pointer to child to be removed. - void remove_node(xml_node *where) - { - assert(where && where->parent() == this); - assert(first_node()); - if (where == m_first_node) - remove_first_node(); - else if (where == m_last_node) - remove_last_node(); - else - { - where->m_prev_sibling->m_next_sibling = where->m_next_sibling; - where->m_next_sibling->m_prev_sibling = where->m_prev_sibling; - where->m_parent = 0; - } - } - - //! Removes all child nodes (but not attributes). - void remove_all_nodes() - { - for (xml_node *node = first_node(); node; node = node->m_next_sibling) - node->m_parent = 0; - m_first_node = 0; - } - - //! Prepends a new attribute to the node. - //! \param attribute Attribute to prepend. - void prepend_attribute(xml_attribute *attribute) - { - assert(attribute && !attribute->parent()); - if (first_attribute()) - { - attribute->m_next_attribute = m_first_attribute; - m_first_attribute->m_prev_attribute = attribute; - } - else - { - attribute->m_next_attribute = 0; - m_last_attribute = attribute; - } - m_first_attribute = attribute; - attribute->m_parent = this; - attribute->m_prev_attribute = 0; - } - - //! Appends a new attribute to the node. - //! \param attribute Attribute to append. - void append_attribute(xml_attribute *attribute) - { - assert(attribute && !attribute->parent()); - if (first_attribute()) - { - attribute->m_prev_attribute = m_last_attribute; - m_last_attribute->m_next_attribute = attribute; - } - else - { - attribute->m_prev_attribute = 0; - m_first_attribute = attribute; - } - m_last_attribute = attribute; - attribute->m_parent = this; - attribute->m_next_attribute = 0; - } - - //! Inserts a new attribute at specified place inside the node. - //! All attributes after and including the specified attribute are moved one position back. - //! \param where Place where to insert the attribute, or 0 to insert at the back. - //! \param attribute Attribute to insert. - void insert_attribute(xml_attribute *where, xml_attribute *attribute) - { - assert(!where || where->parent() == this); - assert(attribute && !attribute->parent()); - if (where == m_first_attribute) - prepend_attribute(attribute); - else if (where == 0) - append_attribute(attribute); - else - { - attribute->m_prev_attribute = where->m_prev_attribute; - attribute->m_next_attribute = where; - where->m_prev_attribute->m_next_attribute = attribute; - where->m_prev_attribute = attribute; - attribute->m_parent = this; - } - } - - //! Removes first attribute of the node. - //! If node has no attributes, behaviour is undefined. - //! Use first_attribute() to test if node has attributes. - void remove_first_attribute() - { - assert(first_attribute()); - xml_attribute *attribute = m_first_attribute; - if (attribute->m_next_attribute) - { - attribute->m_next_attribute->m_prev_attribute = 0; - } - else - m_last_attribute = 0; - attribute->m_parent = 0; - m_first_attribute = attribute->m_next_attribute; - } - - //! Removes last attribute of the node. - //! If node has no attributes, behaviour is undefined. - //! Use first_attribute() to test if node has attributes. - void remove_last_attribute() - { - assert(first_attribute()); - xml_attribute *attribute = m_last_attribute; - if (attribute->m_prev_attribute) - { - attribute->m_prev_attribute->m_next_attribute = 0; - m_last_attribute = attribute->m_prev_attribute; - } - else - m_first_attribute = 0; - attribute->m_parent = 0; - } - - //! Removes specified attribute from node. - //! \param where Pointer to attribute to be removed. - void remove_attribute(xml_attribute *where) - { - assert(first_attribute() && where->parent() == this); - if (where == m_first_attribute) - remove_first_attribute(); - else if (where == m_last_attribute) - remove_last_attribute(); - else - { - where->m_prev_attribute->m_next_attribute = where->m_next_attribute; - where->m_next_attribute->m_prev_attribute = where->m_prev_attribute; - where->m_parent = 0; - } - } - - //! Removes all attributes of node. - void remove_all_attributes() - { - for (xml_attribute *attribute = first_attribute(); attribute; attribute = attribute->m_next_attribute) - attribute->m_parent = 0; - m_first_attribute = 0; - } - - private: - - /////////////////////////////////////////////////////////////////////////// - // Restrictions - - // No copying - xml_node(const xml_node &); - void operator =(const xml_node &); - - /////////////////////////////////////////////////////////////////////////// - // Data members - - // Note that some of the pointers below have UNDEFINED values if certain other pointers are 0. - // This is required for maximum performance, as it allows the parser to omit initialization of - // unneded/redundant values. - // - // The rules are as follows: - // 1. first_node and first_attribute contain valid pointers, or 0 if node has no children/attributes respectively - // 2. last_node and last_attribute are valid only if node has at least one child/attribute respectively, otherwise they contain garbage - // 3. prev_sibling and next_sibling are valid only if node has a parent, otherwise they contain garbage - - node_type m_type; // Type of node; always valid - xml_node *m_first_node; // Pointer to first child node, or 0 if none; always valid - xml_node *m_last_node; // Pointer to last child node, or 0 if none; this value is only valid if m_first_node is non-zero - xml_attribute *m_first_attribute; // Pointer to first attribute of node, or 0 if none; always valid - xml_attribute *m_last_attribute; // Pointer to last attribute of node, or 0 if none; this value is only valid if m_first_attribute is non-zero - xml_node *m_prev_sibling; // Pointer to previous sibling of node, or 0 if none; this value is only valid if m_parent is non-zero - xml_node *m_next_sibling; // Pointer to next sibling of node, or 0 if none; this value is only valid if m_parent is non-zero - - }; - - /////////////////////////////////////////////////////////////////////////// - // XML document - - //! This class represents root of the DOM hierarchy. - //! It is also an xml_node and a memory_pool through public inheritance. - //! Use parse() function to build a DOM tree from a zero-terminated XML text string. - //! parse() function allocates memory for nodes and attributes by using functions of xml_document, - //! which are inherited from memory_pool. - //! To access root node of the document, use the document itself, as if it was an xml_node. - //! \param Ch Character type to use. - template - class xml_document: public xml_node, public memory_pool - { - - public: - - //! Constructs empty XML document - xml_document() - : xml_node(node_document) - { - } - - //! Parses zero-terminated XML string according to given flags. - //! Passed string will be modified by the parser, unless rapidxml::parse_non_destructive flag is used. - //! The string must persist for the lifetime of the document. - //! In case of error, rapidxml::parse_error exception will be thrown. - //!

- //! If you want to parse contents of a file, you must first load the file into the memory, and pass pointer to its beginning. - //! Make sure that data is zero-terminated. - //!

- //! Document can be parsed into multiple times. - //! Each new call to parse removes previous nodes and attributes (if any), but does not clear memory pool. - //! \param text XML data to parse; pointer is non-const to denote fact that this data may be modified by the parser. - template - void parse(Ch *text) - { - assert(text); - - // Remove current contents - this->remove_all_nodes(); - this->remove_all_attributes(); - - // Parse BOM, if any - parse_bom(text); - - // Parse children - while (1) - { - // Skip whitespace before node - skip(text); - if (*text == 0) - break; - - // Parse and append new child - if (*text == Ch('<')) - { - ++text; // Skip '<' - if (xml_node *node = parse_node(text)) - this->append_node(node); - } - else - RAPIDXML_PARSE_ERROR("expected <", text); - } - - } - - //! Clears the document by deleting all nodes and clearing the memory pool. - //! All nodes owned by document pool are destroyed. - void clear() - { - this->remove_all_nodes(); - this->remove_all_attributes(); - memory_pool::clear(); - } - - private: - - /////////////////////////////////////////////////////////////////////// - // Internal character utility functions - - // Detect whitespace character - struct whitespace_pred - { - static unsigned char test(Ch ch) - { - return internal::lookup_tables<0>::lookup_whitespace[static_cast(ch)]; - } - }; - - // Detect node name character - struct node_name_pred - { - static unsigned char test(Ch ch) - { - return internal::lookup_tables<0>::lookup_node_name[static_cast(ch)]; - } - }; - - // Detect attribute name character - struct attribute_name_pred - { - static unsigned char test(Ch ch) - { - return internal::lookup_tables<0>::lookup_attribute_name[static_cast(ch)]; - } - }; - - // Detect text character (PCDATA) - struct text_pred - { - static unsigned char test(Ch ch) - { - return internal::lookup_tables<0>::lookup_text[static_cast(ch)]; - } - }; - - // Detect text character (PCDATA) that does not require processing - struct text_pure_no_ws_pred - { - static unsigned char test(Ch ch) - { - return internal::lookup_tables<0>::lookup_text_pure_no_ws[static_cast(ch)]; - } - }; - - // Detect text character (PCDATA) that does not require processing - struct text_pure_with_ws_pred - { - static unsigned char test(Ch ch) - { - return internal::lookup_tables<0>::lookup_text_pure_with_ws[static_cast(ch)]; - } - }; - - // Detect attribute value character - template - struct attribute_value_pred - { - static unsigned char test(Ch ch) - { - if (Quote == Ch('\'')) - return internal::lookup_tables<0>::lookup_attribute_data_1[static_cast(ch)]; - if (Quote == Ch('\"')) - return internal::lookup_tables<0>::lookup_attribute_data_2[static_cast(ch)]; - return 0; // Should never be executed, to avoid warnings on Comeau - } - }; - - // Detect attribute value character - template - struct attribute_value_pure_pred - { - static unsigned char test(Ch ch) - { - if (Quote == Ch('\'')) - return internal::lookup_tables<0>::lookup_attribute_data_1_pure[static_cast(ch)]; - if (Quote == Ch('\"')) - return internal::lookup_tables<0>::lookup_attribute_data_2_pure[static_cast(ch)]; - return 0; // Should never be executed, to avoid warnings on Comeau - } - }; - - // Insert coded character, using UTF8 or 8-bit ASCII - template - static void insert_coded_character(Ch *&text, unsigned long code) - { - if (Flags & parse_no_utf8) - { - // Insert 8-bit ASCII character - // Todo: possibly verify that code is less than 256 and use replacement char otherwise? - text[0] = static_cast(code); - text += 1; - } - else - { - // Insert UTF8 sequence - if (code < 0x80) // 1 byte sequence - { - text[0] = static_cast(code); - text += 1; - } - else if (code < 0x800) // 2 byte sequence - { - text[1] = static_cast((code | 0x80) & 0xBF); code >>= 6; - text[0] = static_cast(code | 0xC0); - text += 2; - } - else if (code < 0x10000) // 3 byte sequence - { - text[2] = static_cast((code | 0x80) & 0xBF); code >>= 6; - text[1] = static_cast((code | 0x80) & 0xBF); code >>= 6; - text[0] = static_cast(code | 0xE0); - text += 3; - } - else if (code < 0x110000) // 4 byte sequence - { - text[3] = static_cast((code | 0x80) & 0xBF); code >>= 6; - text[2] = static_cast((code | 0x80) & 0xBF); code >>= 6; - text[1] = static_cast((code | 0x80) & 0xBF); code >>= 6; - text[0] = static_cast(code | 0xF0); - text += 4; - } - else // Invalid, only codes up to 0x10FFFF are allowed in Unicode - { - RAPIDXML_PARSE_ERROR("invalid numeric character entity", text); - } - } - } - - // Skip characters until predicate evaluates to true - template - static void skip(Ch *&text) - { - Ch *tmp = text; - while (StopPred::test(*tmp)) - ++tmp; - text = tmp; - } - - // Skip characters until predicate evaluates to true while doing the following: - // - replacing XML character entity references with proper characters (' & " < > &#...;) - // - condensing whitespace sequences to single space character - template - static Ch *skip_and_expand_character_refs(Ch *&text) - { - // If entity translation, whitespace condense and whitespace trimming is disabled, use plain skip - if (Flags & parse_no_entity_translation && - !(Flags & parse_normalize_whitespace) && - !(Flags & parse_trim_whitespace)) - { - skip(text); - return text; - } - - // Use simple skip until first modification is detected - skip(text); - - // Use translation skip - Ch *src = text; - Ch *dest = src; - while (StopPred::test(*src)) - { - // If entity translation is enabled - if (!(Flags & parse_no_entity_translation)) - { - // Test if replacement is needed - if (src[0] == Ch('&')) - { - switch (src[1]) - { - - // & ' - case Ch('a'): - if (src[2] == Ch('m') && src[3] == Ch('p') && src[4] == Ch(';')) - { - *dest = Ch('&'); - ++dest; - src += 5; - continue; - } - if (src[2] == Ch('p') && src[3] == Ch('o') && src[4] == Ch('s') && src[5] == Ch(';')) - { - *dest = Ch('\''); - ++dest; - src += 6; - continue; - } - break; - - // " - case Ch('q'): - if (src[2] == Ch('u') && src[3] == Ch('o') && src[4] == Ch('t') && src[5] == Ch(';')) - { - *dest = Ch('"'); - ++dest; - src += 6; - continue; - } - break; - - // > - case Ch('g'): - if (src[2] == Ch('t') && src[3] == Ch(';')) - { - *dest = Ch('>'); - ++dest; - src += 4; - continue; - } - break; - - // < - case Ch('l'): - if (src[2] == Ch('t') && src[3] == Ch(';')) - { - *dest = Ch('<'); - ++dest; - src += 4; - continue; - } - break; - - // &#...; - assumes ASCII - case Ch('#'): - if (src[2] == Ch('x')) - { - unsigned long code = 0; - src += 3; // Skip &#x - while (1) - { - unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast(*src)]; - if (digit == 0xFF) - break; - code = code * 16 + digit; - ++src; - } - insert_coded_character(dest, code); // Put character in output - } - else - { - unsigned long code = 0; - src += 2; // Skip &# - while (1) - { - unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast(*src)]; - if (digit == 0xFF) - break; - code = code * 10 + digit; - ++src; - } - insert_coded_character(dest, code); // Put character in output - } - if (*src == Ch(';')) - ++src; - else - RAPIDXML_PARSE_ERROR("expected ;", src); - continue; - - // Something else - default: - // Ignore, just copy '&' verbatim - break; - - } - } - } - - // If whitespace condensing is enabled - if (Flags & parse_normalize_whitespace) - { - // Test if condensing is needed - if (whitespace_pred::test(*src)) - { - *dest = Ch(' '); ++dest; // Put single space in dest - ++src; // Skip first whitespace char - // Skip remaining whitespace chars - while (whitespace_pred::test(*src)) - ++src; - continue; - } - } - - // No replacement, only copy character - *dest++ = *src++; - - } - - // Return new end - text = src; - return dest; - - } - - /////////////////////////////////////////////////////////////////////// - // Internal parsing functions - - // Parse BOM, if any - template - void parse_bom(Ch *&text) - { - // UTF-8? - if (static_cast(text[0]) == 0xEF && - static_cast(text[1]) == 0xBB && - static_cast(text[2]) == 0xBF) - { - text += 3; // Skup utf-8 bom - } - } - - // Parse XML declaration ( - xml_node *parse_xml_declaration(Ch *&text) - { - // If parsing of declaration is disabled - if (!(Flags & parse_declaration_node)) - { - // Skip until end of declaration - while (text[0] != Ch('?') || text[1] != Ch('>')) - { - if (!text[0]) - RAPIDXML_PARSE_ERROR("unexpected end of data", text); - ++text; - } - text += 2; // Skip '?>' - return 0; - } - - // Create declaration - xml_node *declaration = this->allocate_node(node_declaration); - - // Skip whitespace before attributes or ?> - skip(text); - - // Parse declaration attributes - parse_node_attributes(text, declaration); - - // Skip ?> - if (text[0] != Ch('?') || text[1] != Ch('>')) - RAPIDXML_PARSE_ERROR("expected ?>", text); - text += 2; - - return declaration; - } - - // Parse XML comment (' - return 0; // Do not produce comment node - } - - // Remember value start - Ch *value = text; - - // Skip until end of comment - while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>')) - { - if (!text[0]) - RAPIDXML_PARSE_ERROR("unexpected end of data", text); - ++text; - } - - // Create comment node - xml_node *comment = this->allocate_node(node_comment); - comment->value(value, text - value); - - // Place zero terminator after comment value - if (!(Flags & parse_no_string_terminators)) - *text = Ch('\0'); - - text += 3; // Skip '-->' - return comment; - } - - // Parse DOCTYPE - template - xml_node *parse_doctype(Ch *&text) - { - // Remember value start - Ch *value = text; - - // Skip to > - while (*text != Ch('>')) - { - // Determine character type - switch (*text) - { - - // If '[' encountered, scan for matching ending ']' using naive algorithm with depth - // This works for all W3C test files except for 2 most wicked - case Ch('['): - { - ++text; // Skip '[' - int depth = 1; - while (depth > 0) - { - switch (*text) - { - case Ch('['): ++depth; break; - case Ch(']'): --depth; break; - case 0: RAPIDXML_PARSE_ERROR("unexpected end of data", text); - } - ++text; - } - break; - } - - // Error on end of text - case Ch('\0'): - RAPIDXML_PARSE_ERROR("unexpected end of data", text); - - // Other character, skip it - default: - ++text; - - } - } - - // If DOCTYPE nodes enabled - if (Flags & parse_doctype_node) - { - // Create a new doctype node - xml_node *doctype = this->allocate_node(node_doctype); - doctype->value(value, text - value); - - // Place zero terminator after value - if (!(Flags & parse_no_string_terminators)) - *text = Ch('\0'); - - text += 1; // skip '>' - return doctype; - } - else - { - text += 1; // skip '>' - return 0; - } - - } - - // Parse PI - template - xml_node *parse_pi(Ch *&text) - { - // If creation of PI nodes is enabled - if (Flags & parse_pi_nodes) - { - // Create pi node - xml_node *pi = this->allocate_node(node_pi); - - // Extract PI target name - Ch *name = text; - skip(text); - if (text == name) - RAPIDXML_PARSE_ERROR("expected PI target", text); - pi->name(name, text - name); - - // Skip whitespace between pi target and pi - skip(text); - - // Remember start of pi - Ch *value = text; - - // Skip to '?>' - while (text[0] != Ch('?') || text[1] != Ch('>')) - { - if (*text == Ch('\0')) - RAPIDXML_PARSE_ERROR("unexpected end of data", text); - ++text; - } - - // Set pi value (verbatim, no entity expansion or whitespace normalization) - pi->value(value, text - value); - - // Place zero terminator after name and value - if (!(Flags & parse_no_string_terminators)) - { - pi->name()[pi->name_size()] = Ch('\0'); - pi->value()[pi->value_size()] = Ch('\0'); - } - - text += 2; // Skip '?>' - return pi; - } - else - { - // Skip to '?>' - while (text[0] != Ch('?') || text[1] != Ch('>')) - { - if (*text == Ch('\0')) - RAPIDXML_PARSE_ERROR("unexpected end of data", text); - ++text; - } - text += 2; // Skip '?>' - return 0; - } - } - - // Parse and append data - // Return character that ends data. - // This is necessary because this character might have been overwritten by a terminating 0 - template - Ch parse_and_append_data(xml_node *node, Ch *&text, Ch *contents_start) - { - // Backup to contents start if whitespace trimming is disabled - if (!(Flags & parse_trim_whitespace)) - text = contents_start; - - // Skip until end of data - Ch *value = text, *end; - if (Flags & parse_normalize_whitespace) - end = skip_and_expand_character_refs(text); - else - end = skip_and_expand_character_refs(text); - - // Trim trailing whitespace if flag is set; leading was already trimmed by whitespace skip after > - if (Flags & parse_trim_whitespace) - { - if (Flags & parse_normalize_whitespace) - { - // Whitespace is already condensed to single space characters by skipping function, so just trim 1 char off the end - if (*(end - 1) == Ch(' ')) - --end; - } - else - { - // Backup until non-whitespace character is found - while (whitespace_pred::test(*(end - 1))) - --end; - } - } - - // If characters are still left between end and value (this test is only necessary if normalization is enabled) - // Create new data node - if (!(Flags & parse_no_data_nodes)) - { - xml_node *data = this->allocate_node(node_data); - data->value(value, end - value); - node->append_node(data); - } - - // Add data to parent node if no data exists yet - if (!(Flags & parse_no_element_values)) - if (*node->value() == Ch('\0')) - node->value(value, end - value); - - // Place zero terminator after value - if (!(Flags & parse_no_string_terminators)) - { - Ch ch = *text; - *end = Ch('\0'); - return ch; // Return character that ends data; this is required because zero terminator overwritten it - } - - // Return character that ends data - return *text; - } - - // Parse CDATA - template - xml_node *parse_cdata(Ch *&text) - { - // If CDATA is disabled - if (Flags & parse_no_data_nodes) - { - // Skip until end of cdata - while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>')) - { - if (!text[0]) - RAPIDXML_PARSE_ERROR("unexpected end of data", text); - ++text; - } - text += 3; // Skip ]]> - return 0; // Do not produce CDATA node - } - - // Skip until end of cdata - Ch *value = text; - while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>')) - { - if (!text[0]) - RAPIDXML_PARSE_ERROR("unexpected end of data", text); - ++text; - } - - // Create new cdata node - xml_node *cdata = this->allocate_node(node_cdata); - cdata->value(value, text - value); - - // Place zero terminator after value - if (!(Flags & parse_no_string_terminators)) - *text = Ch('\0'); - - text += 3; // Skip ]]> - return cdata; - } - - // Parse element node - template - xml_node *parse_element(Ch *&text) - { - // Create element node - xml_node *element = this->allocate_node(node_element); - - // Extract element name - Ch *name = text; - skip(text); - if (text == name) - RAPIDXML_PARSE_ERROR("expected element name", text); - element->name(name, text - name); - - // Skip whitespace between element name and attributes or > - skip(text); - - // Parse attributes, if any - parse_node_attributes(text, element); - - // Determine ending type - if (*text == Ch('>')) - { - ++text; - parse_node_contents(text, element); - } - else if (*text == Ch('/')) - { - ++text; - if (*text != Ch('>')) - RAPIDXML_PARSE_ERROR("expected >", text); - ++text; - } - else - RAPIDXML_PARSE_ERROR("expected >", text); - - // Place zero terminator after name - if (!(Flags & parse_no_string_terminators)) - element->name()[element->name_size()] = Ch('\0'); - - // Return parsed element - return element; - } - - // Determine node type, and parse it - template - xml_node *parse_node(Ch *&text) - { - // Parse proper node type - switch (text[0]) - { - - // <... - default: - // Parse and append element node - return parse_element(text); - - // (text); - } - else - { - // Parse PI - return parse_pi(text); - } - - // (text); - } - break; - - // (text); - } - break; - - // (text); - } - - } // switch - - // Attempt to skip other, unrecognized node types starting with ')) - { - if (*text == 0) - RAPIDXML_PARSE_ERROR("unexpected end of data", text); - ++text; - } - ++text; // Skip '>' - return 0; // No node recognized - - } - } - - // Parse contents of the node - children, data etc. - template - void parse_node_contents(Ch *&text, xml_node *node) - { - // For all children and text - while (1) - { - // Skip whitespace between > and node contents - Ch *contents_start = text; // Store start of node contents before whitespace is skipped - skip(text); - Ch next_char = *text; - - // After data nodes, instead of continuing the loop, control jumps here. - // This is because zero termination inside parse_and_append_data() function - // would wreak havoc with the above code. - // Also, skipping whitespace after data nodes is unnecessary. - after_data_node: - - // Determine what comes next: node closing, child node, data node, or 0? - switch (next_char) - { - - // Node closing or child node - case Ch('<'): - if (text[1] == Ch('/')) - { - // Node closing - text += 2; // Skip '(text); - if (!internal::compare(node->name(), node->name_size(), closing_name, text - closing_name, true)) - RAPIDXML_PARSE_ERROR("invalid closing tag name", text); - } - else - { - // No validation, just skip name - skip(text); - } - // Skip remaining whitespace after node name - skip(text); - if (*text != Ch('>')) - RAPIDXML_PARSE_ERROR("expected >", text); - ++text; // Skip '>' - return; // Node closed, finished parsing contents - } - else - { - // Child node - ++text; // Skip '<' - if (xml_node *child = parse_node(text)) - node->append_node(child); - } - break; - - // End of data - error - case Ch('\0'): - RAPIDXML_PARSE_ERROR("unexpected end of data", text); - - // Data node - default: - next_char = parse_and_append_data(node, text, contents_start); - goto after_data_node; // Bypass regular processing after data nodes - - } - } - } - - // Parse XML attributes of the node - template - void parse_node_attributes(Ch *&text, xml_node *node) - { - // For all attributes - while (attribute_name_pred::test(*text)) - { - // Extract attribute name - Ch *name = text; - ++text; // Skip first character of attribute name - skip(text); - if (text == name) - RAPIDXML_PARSE_ERROR("expected attribute name", name); - - // Create new attribute - xml_attribute *attribute = this->allocate_attribute(); - attribute->name(name, text - name); - node->append_attribute(attribute); - - // Skip whitespace after attribute name - skip(text); - - // Skip = - if (*text != Ch('=')) - RAPIDXML_PARSE_ERROR("expected =", text); - ++text; - - // Add terminating zero after name - if (!(Flags & parse_no_string_terminators)) - attribute->name()[attribute->name_size()] = 0; - - // Skip whitespace after = - skip(text); - - // Skip quote and remember if it was ' or " - Ch quote = *text; - if (quote != Ch('\'') && quote != Ch('"')) - RAPIDXML_PARSE_ERROR("expected ' or \"", text); - ++text; - - // Extract attribute value and expand char refs in it - Ch *value = text, *end; - const int AttFlags = Flags & ~parse_normalize_whitespace; // No whitespace normalization in attributes - if (quote == Ch('\'')) - end = skip_and_expand_character_refs, attribute_value_pure_pred, AttFlags>(text); - else - end = skip_and_expand_character_refs, attribute_value_pure_pred, AttFlags>(text); - - // Set attribute value - attribute->value(value, end - value); - - // Make sure that end quote is present - if (*text != quote) - RAPIDXML_PARSE_ERROR("expected ' or \"", text); - ++text; // Skip quote - - // Add terminating zero after value - if (!(Flags & parse_no_string_terminators)) - attribute->value()[attribute->value_size()] = 0; - - // Skip whitespace after attribute value - skip(text); - } - } - - }; - - //! \cond internal - namespace internal - { - - // Whitespace (space \n \r \t) - template - const unsigned char lookup_tables::lookup_whitespace[256] = - { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, // 0 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1 - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 4 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 5 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 6 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 7 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // A - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // B - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // C - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // D - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // E - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // F - }; - - // Node name (anything but space \n \r \t / > ? \0) - template - const unsigned char lookup_tables::lookup_node_name[256] = - { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, // 0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, // 2 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, // 3 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F - }; - - // Text (i.e. PCDATA) (anything but < \0) - template - const unsigned char lookup_tables::lookup_text[256] = - { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, // 3 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F - }; - - // Text (i.e. PCDATA) that does not require processing when ws normalization is disabled - // (anything but < \0 &) - template - const unsigned char lookup_tables::lookup_text_pure_no_ws[256] = - { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 - 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, // 3 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F - }; - - // Text (i.e. PCDATA) that does not require processing when ws normalizationis is enabled - // (anything but < \0 & space \n \r \t) - template - const unsigned char lookup_tables::lookup_text_pure_with_ws[256] = - { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, // 0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 - 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, // 3 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F - }; - - // Attribute name (anything but space \n \r \t / < > = ? ! \0) - template - const unsigned char lookup_tables::lookup_attribute_name[256] = - { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, // 0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 - 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, // 2 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, // 3 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F - }; - - // Attribute data with single quote (anything but ' \0) - template - const unsigned char lookup_tables::lookup_attribute_data_1[256] = - { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 - 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, // 2 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 3 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F - }; - - // Attribute data with single quote that does not require processing (anything but ' \0 &) - template - const unsigned char lookup_tables::lookup_attribute_data_1_pure[256] = - { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 - 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, // 2 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 3 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F - }; - - // Attribute data with double quote (anything but " \0) - template - const unsigned char lookup_tables::lookup_attribute_data_2[256] = - { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 - 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 3 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F - }; - - // Attribute data with double quote that does not require processing (anything but " \0 &) - template - const unsigned char lookup_tables::lookup_attribute_data_2_pure[256] = - { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 - 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 3 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F - }; - - // Digits (dec and hex, 255 denotes end of numeric character reference) - template - const unsigned char lookup_tables::lookup_digits[256] = - { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 0 - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 1 - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 2 - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,255,255,255,255,255,255, // 3 - 255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255, // 4 - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 5 - 255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255, // 6 - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 7 - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 8 - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 9 - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // A - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // B - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // C - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // D - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // E - 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255 // F - }; - - // Upper case conversion - template - const unsigned char lookup_tables::lookup_upcase[256] = - { - // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A B C D E F - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0 - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, // 1 - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, // 2 - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, // 3 - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, // 4 - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, // 5 - 96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, // 6 - 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 123,124,125,126,127, // 7 - 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, // 8 - 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, // 9 - 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, // A - 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, // B - 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, // C - 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, // D - 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, // E - 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 // F - }; - } - //! \endcond - -} - -// Undefine internal macros -#undef RAPIDXML_PARSE_ERROR - -// On MSVC, restore warnings state -#ifdef _MSC_VER - #pragma warning(pop) -#endif - -#endif +#ifndef RAPIDXML_HPP_INCLUDED +#define RAPIDXML_HPP_INCLUDED + +// Copyright (C) 2006, 2009 Marcin Kalicinski +// Version 1.13 +// Revision $DateTime: 2009/05/13 01:46:17 $ +//! \file rapidxml.hpp This file contains rapidxml parser and DOM implementation + +// If standard library is disabled, user must provide implementations of required functions and typedefs +#if !defined(RAPIDXML_NO_STDLIB) + #include // For std::size_t + #include // For assert + #include // For placement new +#endif + +// On MSVC, disable "conditional expression is constant" warning (level 4). +// This warning is almost impossible to avoid with certain types of templated code +#ifdef _MSC_VER + #pragma warning(push) + #pragma warning(disable:4127) // Conditional expression is constant +#endif + +/////////////////////////////////////////////////////////////////////////// +// RAPIDXML_PARSE_ERROR + +#if defined(RAPIDXML_NO_EXCEPTIONS) + +#define RAPIDXML_PARSE_ERROR(what, where) { parse_error_handler(what, where); assert(0); } + +namespace rapidxml +{ + //! When exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, + //! this function is called to notify user about the error. + //! It must be defined by the user. + //!

+ //! This function cannot return. If it does, the results are undefined. + //!

+ //! A very simple definition might look like that: + //!
+    //! void %rapidxml::%parse_error_handler(const char *what, void *where)
+    //! {
+    //!     std::cout << "Parse error: " << what << "\n";
+    //!     std::abort();
+    //! }
+    //! 
+ //! \param what Human readable description of the error. + //! \param where Pointer to character data where error was detected. + void parse_error_handler(const char *what, void *where); +} + +#else + +#include // For std::exception + +#define RAPIDXML_PARSE_ERROR(what, where) throw parse_error(what, where) + +namespace rapidxml +{ + + //! Parse error exception. + //! This exception is thrown by the parser when an error occurs. + //! Use what() function to get human-readable error message. + //! Use where() function to get a pointer to position within source text where error was detected. + //!

+ //! If throwing exceptions by the parser is undesirable, + //! it can be disabled by defining RAPIDXML_NO_EXCEPTIONS macro before rapidxml.hpp is included. + //! This will cause the parser to call rapidxml::parse_error_handler() function instead of throwing an exception. + //! This function must be defined by the user. + //!

+ //! This class derives from std::exception class. + class parse_error: public std::exception + { + + public: + + //! Constructs parse error + parse_error(const char *what, void *where) + : m_what(what) + , m_where(where) + { + } + + //! Gets human readable description of error. + //! \return Pointer to null terminated description of the error. + virtual const char *what() const throw() override + { + return m_what; + } + + //! Gets pointer to character data where error happened. + //! Ch should be the same as char type of xml_document that produced the error. + //! \return Pointer to location within the parsed string where error occured. + template + Ch *where() const + { + return reinterpret_cast(m_where); + } + + private: + + const char *m_what; + void *m_where; + + }; +} + +#endif + +/////////////////////////////////////////////////////////////////////////// +// Pool sizes + +#ifndef RAPIDXML_STATIC_POOL_SIZE + // Size of static memory block of memory_pool. + // Define RAPIDXML_STATIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value. + // No dynamic memory allocations are performed by memory_pool until static memory is exhausted. + #define RAPIDXML_STATIC_POOL_SIZE (64 * 1024) +#endif + +#ifndef RAPIDXML_DYNAMIC_POOL_SIZE + // Size of dynamic memory block of memory_pool. + // Define RAPIDXML_DYNAMIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value. + // After the static block is exhausted, dynamic blocks with approximately this size are allocated by memory_pool. + #define RAPIDXML_DYNAMIC_POOL_SIZE (64 * 1024) +#endif + +#ifndef RAPIDXML_ALIGNMENT + // Memory allocation alignment. + // Define RAPIDXML_ALIGNMENT before including rapidxml.hpp if you want to override the default value, which is the size of pointer. + // All memory allocations for nodes, attributes and strings will be aligned to this value. + // This must be a power of 2 and at least 1, otherwise memory_pool will not work. + #define RAPIDXML_ALIGNMENT sizeof(void *) +#endif + +namespace rapidxml +{ + // Forward declarations + template class xml_node; + template class xml_attribute; + template class xml_document; + + //! Enumeration listing all node types produced by the parser. + //! Use xml_node::type() function to query node type. + enum node_type + { + node_document, //!< A document node. Name and value are empty. + node_element, //!< An element node. Name contains element name. Value contains text of first data node. + node_data, //!< A data node. Name is empty. Value contains data text. + node_cdata, //!< A CDATA node. Name is empty. Value contains data text. + node_comment, //!< A comment node. Name is empty. Value contains comment text. + node_declaration, //!< A declaration node. Name and value are empty. Declaration parameters (version, encoding and standalone) are in node attributes. + node_doctype, //!< A DOCTYPE node. Name is empty. Value contains DOCTYPE text. + node_pi //!< A PI node. Name contains target. Value contains instructions. + }; + + /////////////////////////////////////////////////////////////////////// + // Parsing flags + + //! Parse flag instructing the parser to not create data nodes. + //! Text of first data node will still be placed in value of parent element, unless rapidxml::parse_no_element_values flag is also specified. + //! Can be combined with other flags by use of | operator. + //!

+ //! See xml_document::parse() function. + const int parse_no_data_nodes = 0x1; + + //! Parse flag instructing the parser to not use text of first data node as a value of parent element. + //! Can be combined with other flags by use of | operator. + //! Note that child data nodes of element node take precendence over its value when printing. + //! That is, if element has one or more child data nodes and a value, the value will be ignored. + //! Use rapidxml::parse_no_data_nodes flag to prevent creation of data nodes if you want to manipulate data using values of elements. + //!

+ //! See xml_document::parse() function. + const int parse_no_element_values = 0x2; + + //! Parse flag instructing the parser to not place zero terminators after strings in the source text. + //! By default zero terminators are placed, modifying source text. + //! Can be combined with other flags by use of | operator. + //!

+ //! See xml_document::parse() function. + const int parse_no_string_terminators = 0x4; + + //! Parse flag instructing the parser to not translate entities in the source text. + //! By default entities are translated, modifying source text. + //! Can be combined with other flags by use of | operator. + //!

+ //! See xml_document::parse() function. + const int parse_no_entity_translation = 0x8; + + //! Parse flag instructing the parser to disable UTF-8 handling and assume plain 8 bit characters. + //! By default, UTF-8 handling is enabled. + //! Can be combined with other flags by use of | operator. + //!

+ //! See xml_document::parse() function. + const int parse_no_utf8 = 0x10; + + //! Parse flag instructing the parser to create XML declaration node. + //! By default, declaration node is not created. + //! Can be combined with other flags by use of | operator. + //!

+ //! See xml_document::parse() function. + const int parse_declaration_node = 0x20; + + //! Parse flag instructing the parser to create comments nodes. + //! By default, comment nodes are not created. + //! Can be combined with other flags by use of | operator. + //!

+ //! See xml_document::parse() function. + const int parse_comment_nodes = 0x40; + + //! Parse flag instructing the parser to create DOCTYPE node. + //! By default, doctype node is not created. + //! Although W3C specification allows at most one DOCTYPE node, RapidXml will silently accept documents with more than one. + //! Can be combined with other flags by use of | operator. + //!

+ //! See xml_document::parse() function. + const int parse_doctype_node = 0x80; + + //! Parse flag instructing the parser to create PI nodes. + //! By default, PI nodes are not created. + //! Can be combined with other flags by use of | operator. + //!

+ //! See xml_document::parse() function. + const int parse_pi_nodes = 0x100; + + //! Parse flag instructing the parser to validate closing tag names. + //! If not set, name inside closing tag is irrelevant to the parser. + //! By default, closing tags are not validated. + //! Can be combined with other flags by use of | operator. + //!

+ //! See xml_document::parse() function. + const int parse_validate_closing_tags = 0x200; + + //! Parse flag instructing the parser to trim all leading and trailing whitespace of data nodes. + //! By default, whitespace is not trimmed. + //! This flag does not cause the parser to modify source text. + //! Can be combined with other flags by use of | operator. + //!

+ //! See xml_document::parse() function. + const int parse_trim_whitespace = 0x400; + + //! Parse flag instructing the parser to condense all whitespace runs of data nodes to a single space character. + //! Trimming of leading and trailing whitespace of data is controlled by rapidxml::parse_trim_whitespace flag. + //! By default, whitespace is not normalized. + //! If this flag is specified, source text will be modified. + //! Can be combined with other flags by use of | operator. + //!

+ //! See xml_document::parse() function. + const int parse_normalize_whitespace = 0x800; + + // Compound flags + + //! Parse flags which represent default behaviour of the parser. + //! This is always equal to 0, so that all other flags can be simply ored together. + //! Normally there is no need to inconveniently disable flags by anding with their negated (~) values. + //! This also means that meaning of each flag is a negation of the default setting. + //! For example, if flag name is rapidxml::parse_no_utf8, it means that utf-8 is enabled by default, + //! and using the flag will disable it. + //!

+ //! See xml_document::parse() function. + const int parse_default = 0; + + //! A combination of parse flags that forbids any modifications of the source text. + //! This also results in faster parsing. However, note that the following will occur: + //!
    + //!
  • names and values of nodes will not be zero terminated, you have to use xml_base::name_size() and xml_base::value_size() functions to determine where name and value ends
  • + //!
  • entities will not be translated
  • + //!
  • whitespace will not be normalized
  • + //!
+ //! See xml_document::parse() function. + const int parse_non_destructive = parse_no_string_terminators | parse_no_entity_translation; + + //! A combination of parse flags resulting in fastest possible parsing, without sacrificing important data. + //!

+ //! See xml_document::parse() function. + const int parse_fastest = parse_non_destructive | parse_no_data_nodes; + + //! A combination of parse flags resulting in largest amount of data being extracted. + //! This usually results in slowest parsing. + //!

+ //! See xml_document::parse() function. + const int parse_full = parse_declaration_node | parse_comment_nodes | parse_doctype_node | parse_pi_nodes | parse_validate_closing_tags; + + /////////////////////////////////////////////////////////////////////// + // Internals + + //! \cond internal + namespace internal + { + + // Struct that contains lookup tables for the parser + // It must be a template to allow correct linking (because it has static data members, which are defined in a header file). + template + struct lookup_tables + { + static const unsigned char lookup_whitespace[256]; // Whitespace table + static const unsigned char lookup_node_name[256]; // Node name table + static const unsigned char lookup_text[256]; // Text table + static const unsigned char lookup_text_pure_no_ws[256]; // Text table + static const unsigned char lookup_text_pure_with_ws[256]; // Text table + static const unsigned char lookup_attribute_name[256]; // Attribute name table + static const unsigned char lookup_attribute_data_1[256]; // Attribute data table with single quote + static const unsigned char lookup_attribute_data_1_pure[256]; // Attribute data table with single quote + static const unsigned char lookup_attribute_data_2[256]; // Attribute data table with double quotes + static const unsigned char lookup_attribute_data_2_pure[256]; // Attribute data table with double quotes + static const unsigned char lookup_digits[256]; // Digits + static const unsigned char lookup_upcase[256]; // To uppercase conversion table for ASCII characters + }; + + // Find length of the string + template + inline std::size_t measure(const Ch *p) + { + const Ch *tmp = p; + while (*tmp) + ++tmp; + return tmp - p; + } + + // Compare strings for equality + template + inline bool compare(const Ch *p1, std::size_t size1, const Ch *p2, std::size_t size2, bool case_sensitive) + { + if (size1 != size2) + return false; + if (case_sensitive) + { + for (const Ch *end = p1 + size1; p1 < end; ++p1, ++p2) + if (*p1 != *p2) + return false; + } + else + { + for (const Ch *end = p1 + size1; p1 < end; ++p1, ++p2) + if (lookup_tables<0>::lookup_upcase[static_cast(*p1)] != lookup_tables<0>::lookup_upcase[static_cast(*p2)]) + return false; + } + return true; + } + } + //! \endcond + + /////////////////////////////////////////////////////////////////////// + // Memory pool + + //! This class is used by the parser to create new nodes and attributes, without overheads of dynamic memory allocation. + //! In most cases, you will not need to use this class directly. + //! However, if you need to create nodes manually or modify names/values of nodes, + //! you are encouraged to use memory_pool of relevant xml_document to allocate the memory. + //! Not only is this faster than allocating them by using new operator, + //! but also their lifetime will be tied to the lifetime of document, + //! possibly simplyfing memory management. + //!

+ //! Call allocate_node() or allocate_attribute() functions to obtain new nodes or attributes from the pool. + //! You can also call allocate_string() function to allocate strings. + //! Such strings can then be used as names or values of nodes without worrying about their lifetime. + //! Note that there is no free() function -- all allocations are freed at once when clear() function is called, + //! or when the pool is destroyed. + //!

+ //! It is also possible to create a standalone memory_pool, and use it + //! to allocate nodes, whose lifetime will not be tied to any document. + //!

+ //! Pool maintains RAPIDXML_STATIC_POOL_SIZE bytes of statically allocated memory. + //! Until static memory is exhausted, no dynamic memory allocations are done. + //! When static memory is exhausted, pool allocates additional blocks of memory of size RAPIDXML_DYNAMIC_POOL_SIZE each, + //! by using global new[] and delete[] operators. + //! This behaviour can be changed by setting custom allocation routines. + //! Use set_allocator() function to set them. + //!

+ //! Allocations for nodes, attributes and strings are aligned at RAPIDXML_ALIGNMENT bytes. + //! This value defaults to the size of pointer on target architecture. + //!

+ //! To obtain absolutely top performance from the parser, + //! it is important that all nodes are allocated from a single, contiguous block of memory. + //! Otherwise, cache misses when jumping between two (or more) disjoint blocks of memory can slow down parsing quite considerably. + //! If required, you can tweak RAPIDXML_STATIC_POOL_SIZE, RAPIDXML_DYNAMIC_POOL_SIZE and RAPIDXML_ALIGNMENT + //! to obtain best wasted memory to performance compromise. + //! To do it, define their values before rapidxml.hpp file is included. + //! \param Ch Character type of created nodes. + template + class memory_pool + { + + public: + + //! \cond internal + typedef void *(alloc_func)(std::size_t); // Type of user-defined function used to allocate memory + typedef void (free_func)(void *); // Type of user-defined function used to free memory + //! \endcond + + //! Constructs empty pool with default allocator functions. + memory_pool() + : m_alloc_func(nullptr) + , m_free_func(nullptr) + { + init(); + } + + //! Destroys pool and frees all the memory. + //! This causes memory occupied by nodes allocated by the pool to be freed. + //! Nodes allocated from the pool are no longer valid. + ~memory_pool() + { + clear(); + } + + //! Allocates a new node from the pool, and optionally assigns name and value to it. + //! If the allocation request cannot be accomodated, this function will throw std::bad_alloc. + //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function + //! will call rapidxml::parse_error_handler() function. + //! \param type Type of node to create. + //! \param name Name to assign to the node, or 0 to assign no name. + //! \param value Value to assign to the node, or 0 to assign no value. + //! \param name_size Size of name to assign, or 0 to automatically calculate size from name string. + //! \param value_size Size of value to assign, or 0 to automatically calculate size from value string. + //! \return Pointer to allocated node. This pointer will never be NULL. + xml_node *allocate_node(node_type type, + const Ch *name = 0, const Ch *value = 0, + std::size_t name_size = 0, std::size_t value_size = 0) + { + void *memory = allocate_aligned(sizeof(xml_node)); + auto node = new(memory) xml_node(type); + if (name) + { + if (name_size > 0) + node->name(name, name_size); + else + node->name(name); + } + if (value) + { + if (value_size > 0) + node->value(value, value_size); + else + node->value(value); + } + return node; + } + + //! Allocates a new attribute from the pool, and optionally assigns name and value to it. + //! If the allocation request cannot be accomodated, this function will throw std::bad_alloc. + //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function + //! will call rapidxml::parse_error_handler() function. + //! \param name Name to assign to the attribute, or 0 to assign no name. + //! \param value Value to assign to the attribute, or 0 to assign no value. + //! \param name_size Size of name to assign, or 0 to automatically calculate size from name string. + //! \param value_size Size of value to assign, or 0 to automatically calculate size from value string. + //! \return Pointer to allocated attribute. This pointer will never be NULL. + xml_attribute *allocate_attribute(const Ch *name = 0, const Ch *value = 0, + std::size_t name_size = 0, std::size_t value_size = 0) + { + void *memory = allocate_aligned(sizeof(xml_attribute)); + auto attribute = new(memory) xml_attribute; + if (name) + { + if (name_size > 0) + attribute->name(name, name_size); + else + attribute->name(name); + } + if (value) + { + if (value_size > 0) + attribute->value(value, value_size); + else + attribute->value(value); + } + return attribute; + } + + //! Allocates a char array of given size from the pool, and optionally copies a given string to it. + //! If the allocation request cannot be accomodated, this function will throw std::bad_alloc. + //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function + //! will call rapidxml::parse_error_handler() function. + //! \param source String to initialize the allocated memory with, or 0 to not initialize it. + //! \param size Number of characters to allocate, or zero to calculate it automatically from source string length; if size is 0, source string must be specified and null terminated. + //! \return Pointer to allocated char array. This pointer will never be NULL. + Ch *allocate_string(const Ch *source = 0, std::size_t size = 0) + { + assert(source || size); // Either source or size (or both) must be specified + if (size == 0) + size = internal::measure(source) + 1; + Ch *result = static_cast(allocate_aligned(size * sizeof(Ch))); + if (source) + for (std::size_t i = 0; i < size; ++i) + result[i] = source[i]; + return result; + } + + //! Clones an xml_node and its hierarchy of child nodes and attributes. + //! Nodes and attributes are allocated from this memory pool. + //! Names and values are not cloned, they are shared between the clone and the source. + //! Result node can be optionally specified as a second parameter, + //! in which case its contents will be replaced with cloned source node. + //! This is useful when you want to clone entire document. + //! \param source Node to clone. + //! \param result Node to put results in, or 0 to automatically allocate result node + //! \return Pointer to cloned node. This pointer will never be NULL. + xml_node *clone_node(const xml_node *source, xml_node *result = 0) + { + // Prepare result node + if (result) + { + result->remove_all_attributes(); + result->remove_all_nodes(); + result->type(source->type()); + } + else + result = allocate_node(source->type()); + + // Clone name and value + result->name(source->name(), source->name_size()); + result->value(source->value(), source->value_size()); + + // Clone child nodes and attributes + for (xml_node *child = source->first_node(); child; child = child->next_sibling()) + result->append_node(clone_node(child)); + for (xml_attribute *attr = source->first_attribute(); attr; attr = attr->next_attribute()) + result->append_attribute(allocate_attribute(attr->name(), attr->value(), attr->name_size(), attr->value_size())); + + return result; + } + + //! Clears the pool. + //! This causes memory occupied by nodes allocated by the pool to be freed. + //! Any nodes or strings allocated from the pool will no longer be valid. + void clear() + { + while (m_begin != m_static_memory) + { + char *previous_begin = reinterpret_cast
(align(m_begin))->previous_begin; + if (m_free_func) + m_free_func(m_begin); + else + delete[] m_begin; + m_begin = previous_begin; + } + init(); + } + + //! Sets or resets the user-defined memory allocation functions for the pool. + //! This can only be called when no memory is allocated from the pool yet, otherwise results are undefined. + //! Allocation function must not return invalid pointer on failure. It should either throw, + //! stop the program, or use longjmp() function to pass control to other place of program. + //! If it returns invalid pointer, results are undefined. + //!

+ //! User defined allocation functions must have the following forms: + //!
+ //!
void *allocate(std::size_t size); + //!
void free(void *pointer); + //!

+ //! \param af Allocation function, or 0 to restore default function + //! \param ff Free function, or 0 to restore default function + void set_allocator(alloc_func *af, free_func *ff) + { + assert(m_begin == m_static_memory && m_ptr == align(m_begin)); // Verify that no memory is allocated yet + m_alloc_func = af; + m_free_func = ff; + } + + private: + + struct header + { + char *previous_begin; + }; + + void init() + { + m_begin = m_static_memory; + m_ptr = align(m_begin); + m_end = m_static_memory + sizeof(m_static_memory); + } + + char *align(char *ptr) + { + std::size_t alignment = ((RAPIDXML_ALIGNMENT - (std::size_t(ptr) & (RAPIDXML_ALIGNMENT - 1))) & (RAPIDXML_ALIGNMENT - 1)); + return ptr + alignment; + } + + char *allocate_raw(std::size_t size) + { + // Allocate + void *memory; + if (m_alloc_func) // Allocate memory using either user-specified allocation function or global operator new[] + { + memory = m_alloc_func(size); + assert(memory); // Allocator is not allowed to return 0, on failure it must either throw, stop the program or use longjmp + } + else + { + memory = new char[size]; +#ifdef RAPIDXML_NO_EXCEPTIONS + if (!memory) // If exceptions are disabled, verify memory allocation, because new will not be able to throw bad_alloc + RAPIDXML_PARSE_ERROR("out of memory", 0); +#endif + } + return static_cast(memory); + } + + void *allocate_aligned(std::size_t size) + { + // Calculate aligned pointer + char *result = align(m_ptr); + + // If not enough memory left in current pool, allocate a new pool + if (result + size > m_end) + { + // Calculate required pool size (may be bigger than RAPIDXML_DYNAMIC_POOL_SIZE) + std::size_t pool_size = RAPIDXML_DYNAMIC_POOL_SIZE; + if (pool_size < size) + pool_size = size; + + // Allocate + std::size_t alloc_size = sizeof(header) + (2 * RAPIDXML_ALIGNMENT - 2) + pool_size; // 2 alignments required in worst case: one for header, one for actual allocation + char *raw_memory = allocate_raw(alloc_size); + + // Setup new pool in allocated memory + char *pool = align(raw_memory); + header *new_header = reinterpret_cast
(pool); + new_header->previous_begin = m_begin; + m_begin = raw_memory; + m_ptr = pool + sizeof(header); + m_end = raw_memory + alloc_size; + + // Calculate aligned pointer again using new pool + result = align(m_ptr); + } + + // Update pool and return aligned pointer + m_ptr = result + size; + return result; + } + + char *m_begin; // Start of raw memory making up current pool + char *m_ptr; // First free byte in current pool + char *m_end; // One past last available byte in current pool + char m_static_memory[RAPIDXML_STATIC_POOL_SIZE]; // Static raw memory + alloc_func *m_alloc_func; // Allocator function, or 0 if default is to be used + free_func *m_free_func; // Free function, or 0 if default is to be used + }; + + /////////////////////////////////////////////////////////////////////////// + // XML base + + //! Base class for xml_node and xml_attribute implementing common functions: + //! name(), name_size(), value(), value_size() and parent(). + //! \param Ch Character type to use + template + class xml_base + { + + public: + + /////////////////////////////////////////////////////////////////////////// + // Construction & destruction + + // Construct a base with empty name, value and parent + xml_base() + : m_name(0) + , m_value(0) + , m_parent(0) + { + } + + /////////////////////////////////////////////////////////////////////////// + // Node data access + + //! Gets name of the node. + //! Interpretation of name depends on type of node. + //! Note that name will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse. + //!

+ //! Use name_size() function to determine length of the name. + //! \return Name of node, or empty string if node has no name. + Ch *name() const + { + return m_name ? m_name : nullstr(); + } + + //! Gets size of node name, not including terminator character. + //! This function works correctly irrespective of whether name is or is not zero terminated. + //! \return Size of node name, in characters. + std::size_t name_size() const + { + return m_name ? m_name_size : 0; + } + + //! Gets value of node. + //! Interpretation of value depends on type of node. + //! Note that value will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse. + //!

+ //! Use value_size() function to determine length of the value. + //! \return Value of node, or empty string if node has no value. + Ch *value() const + { + return m_value ? m_value : nullstr(); + } + + //! Gets size of node value, not including terminator character. + //! This function works correctly irrespective of whether value is or is not zero terminated. + //! \return Size of node value, in characters. + std::size_t value_size() const + { + return m_value ? m_value_size : 0; + } + + /////////////////////////////////////////////////////////////////////////// + // Node modification + + //! Sets name of node to a non zero-terminated string. + //! See \ref ownership_of_strings. + //!

+ //! Note that node does not own its name or value, it only stores a pointer to it. + //! It will not delete or otherwise free the pointer on destruction. + //! It is reponsibility of the user to properly manage lifetime of the string. + //! The easiest way to achieve it is to use memory_pool of the document to allocate the string - + //! on destruction of the document the string will be automatically freed. + //!

+ //! Size of name must be specified separately, because name does not have to be zero terminated. + //! Use name(const Ch *) function to have the length automatically calculated (string must be zero terminated). + //! \param name Name of node to set. Does not have to be zero terminated. + //! \param size Size of name, in characters. This does not include zero terminator, if one is present. + void name(const Ch *name, std::size_t size) + { + m_name = const_cast(name); + m_name_size = size; + } + + //! Sets name of node to a zero-terminated string. + //! See also \ref ownership_of_strings and xml_node::name(const Ch *, std::size_t). + //! \param name Name of node to set. Must be zero terminated. + void name(const Ch *name) + { + this->name(name, internal::measure(name)); + } + + //! Sets value of node to a non zero-terminated string. + //! See \ref ownership_of_strings. + //!

+ //! Note that node does not own its name or value, it only stores a pointer to it. + //! It will not delete or otherwise free the pointer on destruction. + //! It is reponsibility of the user to properly manage lifetime of the string. + //! The easiest way to achieve it is to use memory_pool of the document to allocate the string - + //! on destruction of the document the string will be automatically freed. + //!

+ //! Size of value must be specified separately, because it does not have to be zero terminated. + //! Use value(const Ch *) function to have the length automatically calculated (string must be zero terminated). + //!

+ //! If an element has a child node of type node_data, it will take precedence over element value when printing. + //! If you want to manipulate data of elements using values, use parser flag rapidxml::parse_no_data_nodes to prevent creation of data nodes by the parser. + //! \param value value of node to set. Does not have to be zero terminated. + //! \param size Size of value, in characters. This does not include zero terminator, if one is present. + void value(const Ch *value, std::size_t size) + { + m_value = const_cast(value); + m_value_size = size; + } + + //! Sets value of node to a zero-terminated string. + //! See also \ref ownership_of_strings and xml_node::value(const Ch *, std::size_t). + //! \param value Vame of node to set. Must be zero terminated. + void value(const Ch *value) + { + this->value(value, internal::measure(value)); + } + + /////////////////////////////////////////////////////////////////////////// + // Related nodes access + + //! Gets node parent. + //! \return Pointer to parent node, or 0 if there is no parent. + xml_node *parent() const + { + return m_parent; + } + + protected: + + // Return empty string + static Ch *nullstr() + { + static Ch zero = Ch('\0'); + return &zero; + } + + Ch *m_name; // Name of node, or 0 if no name + Ch *m_value; // Value of node, or 0 if no value + std::size_t m_name_size; // Length of node name, or undefined of no name + std::size_t m_value_size; // Length of node value, or undefined if no value + xml_node *m_parent; // Pointer to parent node, or 0 if none + + }; + + //! Class representing attribute node of XML document. + //! Each attribute has name and value strings, which are available through name() and value() functions (inherited from xml_base). + //! Note that after parse, both name and value of attribute will point to interior of source text used for parsing. + //! Thus, this text must persist in memory for the lifetime of attribute. + //! \param Ch Character type to use. + template + class xml_attribute: public xml_base + { + + friend class xml_node; + + public: + + /////////////////////////////////////////////////////////////////////////// + // Construction & destruction + + //! Constructs an empty attribute with the specified type. + //! Consider using memory_pool of appropriate xml_document if allocating attributes manually. + xml_attribute() + { + } + + /////////////////////////////////////////////////////////////////////////// + // Related nodes access + + //! Gets document of which attribute is a child. + //! \return Pointer to document that contains this attribute, or 0 if there is no parent document. + xml_document *document() const + { + if (xml_node *node = this->parent()) + { + while (node->parent()) + node = node->parent(); + return node->type() == node_document ? static_cast *>(node) : 0; + } + else + return 0; + } + + //! Gets previous attribute, optionally matching attribute name. + //! \param name Name of attribute to find, or 0 to return previous attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero + //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string + //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters + //! \return Pointer to found attribute, or 0 if not found. + xml_attribute *previous_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const + { + if (name) + { + if (name_size == 0) + name_size = internal::measure(name); + for (xml_attribute *attribute = m_prev_attribute; attribute; attribute = attribute->m_prev_attribute) + if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive)) + return attribute; + return 0; + } + else + return this->m_parent ? m_prev_attribute : 0; + } + + //! Gets next attribute, optionally matching attribute name. + //! \param name Name of attribute to find, or 0 to return next attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero + //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string + //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters + //! \return Pointer to found attribute, or 0 if not found. + xml_attribute *next_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const + { + if (name) + { + if (name_size == 0) + name_size = internal::measure(name); + for (xml_attribute *attribute = m_next_attribute; attribute; attribute = attribute->m_next_attribute) + if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive)) + return attribute; + return 0; + } + else + return this->m_parent ? m_next_attribute : 0; + } + + private: + + xml_attribute *m_prev_attribute; // Pointer to previous sibling of attribute, or 0 if none; only valid if parent is non-zero + xml_attribute *m_next_attribute; // Pointer to next sibling of attribute, or 0 if none; only valid if parent is non-zero + + }; + + /////////////////////////////////////////////////////////////////////////// + // XML node + + //! Class representing a node of XML document. + //! Each node may have associated name and value strings, which are available through name() and value() functions. + //! Interpretation of name and value depends on type of the node. + //! Type of node can be determined by using type() function. + //!

+ //! Note that after parse, both name and value of node, if any, will point interior of source text used for parsing. + //! Thus, this text must persist in the memory for the lifetime of node. + //! \param Ch Character type to use. + template + class xml_node: public xml_base + { + + public: + + /////////////////////////////////////////////////////////////////////////// + // Construction & destruction + + //! Constructs an empty node with the specified type. + //! Consider using memory_pool of appropriate document to allocate nodes manually. + //! \param type Type of node to construct. + xml_node(node_type type) + : m_type(type) + , m_first_node(0) + , m_first_attribute(0) + { + } + + /////////////////////////////////////////////////////////////////////////// + // Node data access + + //! Gets type of node. + //! \return Type of node. + node_type type() const + { + return m_type; + } + + /////////////////////////////////////////////////////////////////////////// + // Related nodes access + + //! Gets document of which node is a child. + //! \return Pointer to document that contains this node, or 0 if there is no parent document. + xml_document *document() const + { + xml_node *node = const_cast *>(this); + while (node->parent()) + node = node->parent(); + return node->type() == node_document ? static_cast *>(node) : 0; + } + + //! Gets first child node, optionally matching node name. + //! \param name Name of child to find, or 0 to return first child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero + //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string + //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters + //! \return Pointer to found child, or 0 if not found. + xml_node *first_node(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const + { + if (name) + { + if (name_size == 0) + name_size = internal::measure(name); + for (xml_node *child = m_first_node; child; child = child->next_sibling()) + if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive)) + return child; + return 0; + } + else + return m_first_node; + } + + //! Gets last child node, optionally matching node name. + //! Behaviour is undefined if node has no children. + //! Use first_node() to test if node has children. + //! \param name Name of child to find, or 0 to return last child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero + //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string + //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters + //! \return Pointer to found child, or 0 if not found. + xml_node *last_node(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const + { + assert(m_first_node); // Cannot query for last child if node has no children + if (name) + { + if (name_size == 0) + name_size = internal::measure(name); + for (xml_node *child = m_last_node; child; child = child->previous_sibling()) + if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive)) + return child; + return 0; + } + else + return m_last_node; + } + + //! Gets previous sibling node, optionally matching node name. + //! Behaviour is undefined if node has no parent. + //! Use parent() to test if node has a parent. + //! \param name Name of sibling to find, or 0 to return previous sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero + //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string + //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters + //! \return Pointer to found sibling, or 0 if not found. + xml_node *previous_sibling(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const + { + assert(this->m_parent); // Cannot query for siblings if node has no parent + if (name) + { + if (name_size == 0) + name_size = internal::measure(name); + for (xml_node *sibling = m_prev_sibling; sibling; sibling = sibling->m_prev_sibling) + if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive)) + return sibling; + return 0; + } + else + return m_prev_sibling; + } + + //! Gets next sibling node, optionally matching node name. + //! Behaviour is undefined if node has no parent. + //! Use parent() to test if node has a parent. + //! \param name Name of sibling to find, or 0 to return next sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero + //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string + //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters + //! \return Pointer to found sibling, or 0 if not found. + xml_node *next_sibling(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const + { + assert(this->m_parent); // Cannot query for siblings if node has no parent + if (name) + { + if (name_size == 0) + name_size = internal::measure(name); + for (xml_node *sibling = m_next_sibling; sibling; sibling = sibling->m_next_sibling) + if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive)) + return sibling; + return 0; + } + else + return m_next_sibling; + } + + //! Gets first attribute of node, optionally matching attribute name. + //! \param name Name of attribute to find, or 0 to return first attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero + //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string + //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters + //! \return Pointer to found attribute, or 0 if not found. + xml_attribute *first_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const + { + if (name) + { + if (name_size == 0) + name_size = internal::measure(name); + for (xml_attribute *attribute = m_first_attribute; attribute; attribute = attribute->m_next_attribute) + if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive)) + return attribute; + return 0; + } + else + return m_first_attribute; + } + + //! Gets last attribute of node, optionally matching attribute name. + //! \param name Name of attribute to find, or 0 to return last attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero + //! \param name_size Size of name, in characters, or 0 to have size calculated automatically from string + //! \param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters + //! \return Pointer to found attribute, or 0 if not found. + xml_attribute *last_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const + { + if (name) + { + if (name_size == 0) + name_size = internal::measure(name); + for (xml_attribute *attribute = m_last_attribute; attribute; attribute = attribute->m_prev_attribute) + if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive)) + return attribute; + return 0; + } + else + return m_first_attribute ? m_last_attribute : 0; + } + + /////////////////////////////////////////////////////////////////////////// + // Node modification + + //! Sets type of node. + //! \param type Type of node to set. + void type(node_type type) + { + m_type = type; + } + + /////////////////////////////////////////////////////////////////////////// + // Node manipulation + + //! Prepends a new child node. + //! The prepended child becomes the first child, and all existing children are moved one position back. + //! \param child Node to prepend. + void prepend_node(xml_node *child) + { + assert(child && !child->parent() && child->type() != node_document); + if (first_node()) + { + child->m_next_sibling = m_first_node; + m_first_node->m_prev_sibling = child; + } + else + { + child->m_next_sibling = 0; + m_last_node = child; + } + m_first_node = child; + child->m_parent = this; + child->m_prev_sibling = 0; + } + + //! Appends a new child node. + //! The appended child becomes the last child. + //! \param child Node to append. + void append_node(xml_node *child) + { + assert(child && !child->parent() && child->type() != node_document); + if (first_node()) + { + child->m_prev_sibling = m_last_node; + m_last_node->m_next_sibling = child; + } + else + { + child->m_prev_sibling = 0; + m_first_node = child; + } + m_last_node = child; + child->m_parent = this; + child->m_next_sibling = 0; + } + + //! Inserts a new child node at specified place inside the node. + //! All children after and including the specified node are moved one position back. + //! \param where Place where to insert the child, or 0 to insert at the back. + //! \param child Node to insert. + void insert_node(xml_node *where, xml_node *child) + { + assert(!where || where->parent() == this); + assert(child && !child->parent() && child->type() != node_document); + if (where == m_first_node) + prepend_node(child); + else if (where == 0) + append_node(child); + else + { + child->m_prev_sibling = where->m_prev_sibling; + child->m_next_sibling = where; + where->m_prev_sibling->m_next_sibling = child; + where->m_prev_sibling = child; + child->m_parent = this; + } + } + + //! Removes first child node. + //! If node has no children, behaviour is undefined. + //! Use first_node() to test if node has children. + void remove_first_node() + { + assert(first_node()); + xml_node *child = m_first_node; + m_first_node = child->m_next_sibling; + if (child->m_next_sibling) + child->m_next_sibling->m_prev_sibling = 0; + else + m_last_node = 0; + child->m_parent = 0; + } + + //! Removes last child of the node. + //! If node has no children, behaviour is undefined. + //! Use first_node() to test if node has children. + void remove_last_node() + { + assert(first_node()); + xml_node *child = m_last_node; + if (child->m_prev_sibling) + { + m_last_node = child->m_prev_sibling; + child->m_prev_sibling->m_next_sibling = 0; + } + else + m_first_node = 0; + child->m_parent = 0; + } + + //! Removes specified child from the node + // \param where Pointer to child to be removed. + void remove_node(xml_node *where) + { + assert(where && where->parent() == this); + assert(first_node()); + if (where == m_first_node) + remove_first_node(); + else if (where == m_last_node) + remove_last_node(); + else + { + where->m_prev_sibling->m_next_sibling = where->m_next_sibling; + where->m_next_sibling->m_prev_sibling = where->m_prev_sibling; + where->m_parent = 0; + } + } + + //! Removes all child nodes (but not attributes). + void remove_all_nodes() + { + for (xml_node *node = first_node(); node; node = node->m_next_sibling) + node->m_parent = 0; + m_first_node = 0; + } + + //! Prepends a new attribute to the node. + //! \param attribute Attribute to prepend. + void prepend_attribute(xml_attribute *attribute) + { + assert(attribute && !attribute->parent()); + if (first_attribute()) + { + attribute->m_next_attribute = m_first_attribute; + m_first_attribute->m_prev_attribute = attribute; + } + else + { + attribute->m_next_attribute = 0; + m_last_attribute = attribute; + } + m_first_attribute = attribute; + attribute->m_parent = this; + attribute->m_prev_attribute = 0; + } + + //! Appends a new attribute to the node. + //! \param attribute Attribute to append. + void append_attribute(xml_attribute *attribute) + { + assert(attribute && !attribute->parent()); + if (first_attribute()) + { + attribute->m_prev_attribute = m_last_attribute; + m_last_attribute->m_next_attribute = attribute; + } + else + { + attribute->m_prev_attribute = 0; + m_first_attribute = attribute; + } + m_last_attribute = attribute; + attribute->m_parent = this; + attribute->m_next_attribute = 0; + } + + //! Inserts a new attribute at specified place inside the node. + //! All attributes after and including the specified attribute are moved one position back. + //! \param where Place where to insert the attribute, or 0 to insert at the back. + //! \param attribute Attribute to insert. + void insert_attribute(xml_attribute *where, xml_attribute *attribute) + { + assert(!where || where->parent() == this); + assert(attribute && !attribute->parent()); + if (where == m_first_attribute) + prepend_attribute(attribute); + else if (where == 0) + append_attribute(attribute); + else + { + attribute->m_prev_attribute = where->m_prev_attribute; + attribute->m_next_attribute = where; + where->m_prev_attribute->m_next_attribute = attribute; + where->m_prev_attribute = attribute; + attribute->m_parent = this; + } + } + + //! Removes first attribute of the node. + //! If node has no attributes, behaviour is undefined. + //! Use first_attribute() to test if node has attributes. + void remove_first_attribute() + { + assert(first_attribute()); + xml_attribute *attribute = m_first_attribute; + if (attribute->m_next_attribute) + { + attribute->m_next_attribute->m_prev_attribute = 0; + } + else + m_last_attribute = 0; + attribute->m_parent = 0; + m_first_attribute = attribute->m_next_attribute; + } + + //! Removes last attribute of the node. + //! If node has no attributes, behaviour is undefined. + //! Use first_attribute() to test if node has attributes. + void remove_last_attribute() + { + assert(first_attribute()); + xml_attribute *attribute = m_last_attribute; + if (attribute->m_prev_attribute) + { + attribute->m_prev_attribute->m_next_attribute = 0; + m_last_attribute = attribute->m_prev_attribute; + } + else + m_first_attribute = 0; + attribute->m_parent = 0; + } + + //! Removes specified attribute from node. + //! \param where Pointer to attribute to be removed. + void remove_attribute(xml_attribute *where) + { + assert(first_attribute() && where->parent() == this); + if (where == m_first_attribute) + remove_first_attribute(); + else if (where == m_last_attribute) + remove_last_attribute(); + else + { + where->m_prev_attribute->m_next_attribute = where->m_next_attribute; + where->m_next_attribute->m_prev_attribute = where->m_prev_attribute; + where->m_parent = 0; + } + } + + //! Removes all attributes of node. + void remove_all_attributes() + { + for (xml_attribute *attribute = first_attribute(); attribute; attribute = attribute->m_next_attribute) + attribute->m_parent = 0; + m_first_attribute = 0; + } + + private: + + /////////////////////////////////////////////////////////////////////////// + // Restrictions + + // No copying + xml_node(const xml_node &); + void operator =(const xml_node &); + + /////////////////////////////////////////////////////////////////////////// + // Data members + + // Note that some of the pointers below have UNDEFINED values if certain other pointers are 0. + // This is required for maximum performance, as it allows the parser to omit initialization of + // unneded/redundant values. + // + // The rules are as follows: + // 1. first_node and first_attribute contain valid pointers, or 0 if node has no children/attributes respectively + // 2. last_node and last_attribute are valid only if node has at least one child/attribute respectively, otherwise they contain garbage + // 3. prev_sibling and next_sibling are valid only if node has a parent, otherwise they contain garbage + + node_type m_type; // Type of node; always valid + xml_node *m_first_node; // Pointer to first child node, or 0 if none; always valid + xml_node *m_last_node; // Pointer to last child node, or 0 if none; this value is only valid if m_first_node is non-zero + xml_attribute *m_first_attribute; // Pointer to first attribute of node, or 0 if none; always valid + xml_attribute *m_last_attribute; // Pointer to last attribute of node, or 0 if none; this value is only valid if m_first_attribute is non-zero + xml_node *m_prev_sibling; // Pointer to previous sibling of node, or 0 if none; this value is only valid if m_parent is non-zero + xml_node *m_next_sibling; // Pointer to next sibling of node, or 0 if none; this value is only valid if m_parent is non-zero + + }; + + /////////////////////////////////////////////////////////////////////////// + // XML document + + //! This class represents root of the DOM hierarchy. + //! It is also an xml_node and a memory_pool through public inheritance. + //! Use parse() function to build a DOM tree from a zero-terminated XML text string. + //! parse() function allocates memory for nodes and attributes by using functions of xml_document, + //! which are inherited from memory_pool. + //! To access root node of the document, use the document itself, as if it was an xml_node. + //! \param Ch Character type to use. + template + class xml_document: public xml_node, public memory_pool + { + + public: + + //! Constructs empty XML document + xml_document() + : xml_node(node_document) + { + } + + //! Parses zero-terminated XML string according to given flags. + //! Passed string will be modified by the parser, unless rapidxml::parse_non_destructive flag is used. + //! The string must persist for the lifetime of the document. + //! In case of error, rapidxml::parse_error exception will be thrown. + //!

+ //! If you want to parse contents of a file, you must first load the file into the memory, and pass pointer to its beginning. + //! Make sure that data is zero-terminated. + //!

+ //! Document can be parsed into multiple times. + //! Each new call to parse removes previous nodes and attributes (if any), but does not clear memory pool. + //! \param text XML data to parse; pointer is non-const to denote fact that this data may be modified by the parser. + template + void parse(Ch *text) + { + assert(text); + + // Remove current contents + this->remove_all_nodes(); + this->remove_all_attributes(); + + // Parse BOM, if any + parse_bom(text); + + // Parse children + while (1) + { + // Skip whitespace before node + skip(text); + if (*text == 0) + break; + + // Parse and append new child + if (*text == Ch('<')) + { + ++text; // Skip '<' + if (xml_node *node = parse_node(text)) + this->append_node(node); + } + else + RAPIDXML_PARSE_ERROR("expected <", text); + } + + } + + //! Clears the document by deleting all nodes and clearing the memory pool. + //! All nodes owned by document pool are destroyed. + void clear() + { + this->remove_all_nodes(); + this->remove_all_attributes(); + memory_pool::clear(); + } + + private: + + /////////////////////////////////////////////////////////////////////// + // Internal character utility functions + + // Detect whitespace character + struct whitespace_pred + { + static unsigned char test(Ch ch) + { + return internal::lookup_tables<0>::lookup_whitespace[static_cast(ch)]; + } + }; + + // Detect node name character + struct node_name_pred + { + static unsigned char test(Ch ch) + { + return internal::lookup_tables<0>::lookup_node_name[static_cast(ch)]; + } + }; + + // Detect attribute name character + struct attribute_name_pred + { + static unsigned char test(Ch ch) + { + return internal::lookup_tables<0>::lookup_attribute_name[static_cast(ch)]; + } + }; + + // Detect text character (PCDATA) + struct text_pred + { + static unsigned char test(Ch ch) + { + return internal::lookup_tables<0>::lookup_text[static_cast(ch)]; + } + }; + + // Detect text character (PCDATA) that does not require processing + struct text_pure_no_ws_pred + { + static unsigned char test(Ch ch) + { + return internal::lookup_tables<0>::lookup_text_pure_no_ws[static_cast(ch)]; + } + }; + + // Detect text character (PCDATA) that does not require processing + struct text_pure_with_ws_pred + { + static unsigned char test(Ch ch) + { + return internal::lookup_tables<0>::lookup_text_pure_with_ws[static_cast(ch)]; + } + }; + + // Detect attribute value character + template + struct attribute_value_pred + { + static unsigned char test(Ch ch) + { + if (Quote == Ch('\'')) + return internal::lookup_tables<0>::lookup_attribute_data_1[static_cast(ch)]; + if (Quote == Ch('\"')) + return internal::lookup_tables<0>::lookup_attribute_data_2[static_cast(ch)]; + return 0; // Should never be executed, to avoid warnings on Comeau + } + }; + + // Detect attribute value character + template + struct attribute_value_pure_pred + { + static unsigned char test(Ch ch) + { + if (Quote == Ch('\'')) + return internal::lookup_tables<0>::lookup_attribute_data_1_pure[static_cast(ch)]; + if (Quote == Ch('\"')) + return internal::lookup_tables<0>::lookup_attribute_data_2_pure[static_cast(ch)]; + return 0; // Should never be executed, to avoid warnings on Comeau + } + }; + + // Insert coded character, using UTF8 or 8-bit ASCII + template + static void insert_coded_character(Ch *&text, unsigned long code) + { + if (Flags & parse_no_utf8) + { + // Insert 8-bit ASCII character + // Todo: possibly verify that code is less than 256 and use replacement char otherwise? + text[0] = static_cast(code); + text += 1; + } + else + { + // Insert UTF8 sequence + if (code < 0x80) // 1 byte sequence + { + text[0] = static_cast(code); + text += 1; + } + else if (code < 0x800) // 2 byte sequence + { + text[1] = static_cast((code | 0x80) & 0xBF); code >>= 6; + text[0] = static_cast(code | 0xC0); + text += 2; + } + else if (code < 0x10000) // 3 byte sequence + { + text[2] = static_cast((code | 0x80) & 0xBF); code >>= 6; + text[1] = static_cast((code | 0x80) & 0xBF); code >>= 6; + text[0] = static_cast(code | 0xE0); + text += 3; + } + else if (code < 0x110000) // 4 byte sequence + { + text[3] = static_cast((code | 0x80) & 0xBF); code >>= 6; + text[2] = static_cast((code | 0x80) & 0xBF); code >>= 6; + text[1] = static_cast((code | 0x80) & 0xBF); code >>= 6; + text[0] = static_cast(code | 0xF0); + text += 4; + } + else // Invalid, only codes up to 0x10FFFF are allowed in Unicode + { + RAPIDXML_PARSE_ERROR("invalid numeric character entity", text); + } + } + } + + // Skip characters until predicate evaluates to true + template + static void skip(Ch *&text) + { + Ch *tmp = text; + while (StopPred::test(*tmp)) + ++tmp; + text = tmp; + } + + // Skip characters until predicate evaluates to true while doing the following: + // - replacing XML character entity references with proper characters (' & " < > &#...;) + // - condensing whitespace sequences to single space character + template + static Ch *skip_and_expand_character_refs(Ch *&text) + { + // If entity translation, whitespace condense and whitespace trimming is disabled, use plain skip + if (Flags & parse_no_entity_translation && + !(Flags & parse_normalize_whitespace) && + !(Flags & parse_trim_whitespace)) + { + skip(text); + return text; + } + + // Use simple skip until first modification is detected + skip(text); + + // Use translation skip + Ch *src = text; + Ch *dest = src; + while (StopPred::test(*src)) + { + // If entity translation is enabled + if (!(Flags & parse_no_entity_translation)) + { + // Test if replacement is needed + if (src[0] == Ch('&')) + { + switch (src[1]) + { + + // & ' + case Ch('a'): + if (src[2] == Ch('m') && src[3] == Ch('p') && src[4] == Ch(';')) + { + *dest = Ch('&'); + ++dest; + src += 5; + continue; + } + if (src[2] == Ch('p') && src[3] == Ch('o') && src[4] == Ch('s') && src[5] == Ch(';')) + { + *dest = Ch('\''); + ++dest; + src += 6; + continue; + } + break; + + // " + case Ch('q'): + if (src[2] == Ch('u') && src[3] == Ch('o') && src[4] == Ch('t') && src[5] == Ch(';')) + { + *dest = Ch('"'); + ++dest; + src += 6; + continue; + } + break; + + // > + case Ch('g'): + if (src[2] == Ch('t') && src[3] == Ch(';')) + { + *dest = Ch('>'); + ++dest; + src += 4; + continue; + } + break; + + // < + case Ch('l'): + if (src[2] == Ch('t') && src[3] == Ch(';')) + { + *dest = Ch('<'); + ++dest; + src += 4; + continue; + } + break; + + // &#...; - assumes ASCII + case Ch('#'): + if (src[2] == Ch('x')) + { + unsigned long code = 0; + src += 3; // Skip &#x + while (1) + { + unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast(*src)]; + if (digit == 0xFF) + break; + code = code * 16 + digit; + ++src; + } + insert_coded_character(dest, code); // Put character in output + } + else + { + unsigned long code = 0; + src += 2; // Skip &# + while (1) + { + unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast(*src)]; + if (digit == 0xFF) + break; + code = code * 10 + digit; + ++src; + } + insert_coded_character(dest, code); // Put character in output + } + if (*src == Ch(';')) + ++src; + else + RAPIDXML_PARSE_ERROR("expected ;", src); + continue; + + // Something else + default: + // Ignore, just copy '&' verbatim + break; + + } + } + } + + // If whitespace condensing is enabled + if (Flags & parse_normalize_whitespace) + { + // Test if condensing is needed + if (whitespace_pred::test(*src)) + { + *dest = Ch(' '); ++dest; // Put single space in dest + ++src; // Skip first whitespace char + // Skip remaining whitespace chars + while (whitespace_pred::test(*src)) + ++src; + continue; + } + } + + // No replacement, only copy character + *dest++ = *src++; + + } + + // Return new end + text = src; + return dest; + + } + + /////////////////////////////////////////////////////////////////////// + // Internal parsing functions + + // Parse BOM, if any + template + void parse_bom(Ch *&text) + { + // UTF-8? + if (static_cast(text[0]) == 0xEF && + static_cast(text[1]) == 0xBB && + static_cast(text[2]) == 0xBF) + { + text += 3; // Skup utf-8 bom + } + } + + // Parse XML declaration ( + xml_node *parse_xml_declaration(Ch *&text) + { + // If parsing of declaration is disabled + if (!(Flags & parse_declaration_node)) + { + // Skip until end of declaration + while (text[0] != Ch('?') || text[1] != Ch('>')) + { + if (!text[0]) + RAPIDXML_PARSE_ERROR("unexpected end of data", text); + ++text; + } + text += 2; // Skip '?>' + return 0; + } + + // Create declaration + xml_node *declaration = this->allocate_node(node_declaration); + + // Skip whitespace before attributes or ?> + skip(text); + + // Parse declaration attributes + parse_node_attributes(text, declaration); + + // Skip ?> + if (text[0] != Ch('?') || text[1] != Ch('>')) + RAPIDXML_PARSE_ERROR("expected ?>", text); + text += 2; + + return declaration; + } + + // Parse XML comment (' + return 0; // Do not produce comment node + } + + // Remember value start + Ch *value = text; + + // Skip until end of comment + while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>')) + { + if (!text[0]) + RAPIDXML_PARSE_ERROR("unexpected end of data", text); + ++text; + } + + // Create comment node + xml_node *comment = this->allocate_node(node_comment); + comment->value(value, text - value); + + // Place zero terminator after comment value + if (!(Flags & parse_no_string_terminators)) + *text = Ch('\0'); + + text += 3; // Skip '-->' + return comment; + } + + // Parse DOCTYPE + template + xml_node *parse_doctype(Ch *&text) + { + // Remember value start + Ch *value = text; + + // Skip to > + while (*text != Ch('>')) + { + // Determine character type + switch (*text) + { + + // If '[' encountered, scan for matching ending ']' using naive algorithm with depth + // This works for all W3C test files except for 2 most wicked + case Ch('['): + { + ++text; // Skip '[' + int depth = 1; + while (depth > 0) + { + switch (*text) + { + case Ch('['): ++depth; break; + case Ch(']'): --depth; break; + case 0: RAPIDXML_PARSE_ERROR("unexpected end of data", text); + } + ++text; + } + break; + } + + // Error on end of text + case Ch('\0'): + RAPIDXML_PARSE_ERROR("unexpected end of data", text); + + // Other character, skip it + default: + ++text; + + } + } + + // If DOCTYPE nodes enabled + if (Flags & parse_doctype_node) + { + // Create a new doctype node + xml_node *doctype = this->allocate_node(node_doctype); + doctype->value(value, text - value); + + // Place zero terminator after value + if (!(Flags & parse_no_string_terminators)) + *text = Ch('\0'); + + text += 1; // skip '>' + return doctype; + } + else + { + text += 1; // skip '>' + return 0; + } + + } + + // Parse PI + template + xml_node *parse_pi(Ch *&text) + { + // If creation of PI nodes is enabled + if (Flags & parse_pi_nodes) + { + // Create pi node + xml_node *pi = this->allocate_node(node_pi); + + // Extract PI target name + Ch *name = text; + skip(text); + if (text == name) + RAPIDXML_PARSE_ERROR("expected PI target", text); + pi->name(name, text - name); + + // Skip whitespace between pi target and pi + skip(text); + + // Remember start of pi + Ch *value = text; + + // Skip to '?>' + while (text[0] != Ch('?') || text[1] != Ch('>')) + { + if (*text == Ch('\0')) + RAPIDXML_PARSE_ERROR("unexpected end of data", text); + ++text; + } + + // Set pi value (verbatim, no entity expansion or whitespace normalization) + pi->value(value, text - value); + + // Place zero terminator after name and value + if (!(Flags & parse_no_string_terminators)) + { + pi->name()[pi->name_size()] = Ch('\0'); + pi->value()[pi->value_size()] = Ch('\0'); + } + + text += 2; // Skip '?>' + return pi; + } + else + { + // Skip to '?>' + while (text[0] != Ch('?') || text[1] != Ch('>')) + { + if (*text == Ch('\0')) + RAPIDXML_PARSE_ERROR("unexpected end of data", text); + ++text; + } + text += 2; // Skip '?>' + return 0; + } + } + + // Parse and append data + // Return character that ends data. + // This is necessary because this character might have been overwritten by a terminating 0 + template + Ch parse_and_append_data(xml_node *node, Ch *&text, Ch *contents_start) + { + // Backup to contents start if whitespace trimming is disabled + if (!(Flags & parse_trim_whitespace)) + text = contents_start; + + // Skip until end of data + Ch *value = text, *end; + if (Flags & parse_normalize_whitespace) + end = skip_and_expand_character_refs(text); + else + end = skip_and_expand_character_refs(text); + + // Trim trailing whitespace if flag is set; leading was already trimmed by whitespace skip after > + if (Flags & parse_trim_whitespace) + { + if (Flags & parse_normalize_whitespace) + { + // Whitespace is already condensed to single space characters by skipping function, so just trim 1 char off the end + if (*(end - 1) == Ch(' ')) + --end; + } + else + { + // Backup until non-whitespace character is found + while (whitespace_pred::test(*(end - 1))) + --end; + } + } + + // If characters are still left between end and value (this test is only necessary if normalization is enabled) + // Create new data node + if (!(Flags & parse_no_data_nodes)) + { + xml_node *data = this->allocate_node(node_data); + data->value(value, end - value); + node->append_node(data); + } + + // Add data to parent node if no data exists yet + if (!(Flags & parse_no_element_values)) + if (*node->value() == Ch('\0')) + node->value(value, end - value); + + // Place zero terminator after value + if (!(Flags & parse_no_string_terminators)) + { + Ch ch = *text; + *end = Ch('\0'); + return ch; // Return character that ends data; this is required because zero terminator overwritten it + } + + // Return character that ends data + return *text; + } + + // Parse CDATA + template + xml_node *parse_cdata(Ch *&text) + { + // If CDATA is disabled + if (Flags & parse_no_data_nodes) + { + // Skip until end of cdata + while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>')) + { + if (!text[0]) + RAPIDXML_PARSE_ERROR("unexpected end of data", text); + ++text; + } + text += 3; // Skip ]]> + return 0; // Do not produce CDATA node + } + + // Skip until end of cdata + Ch *value = text; + while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>')) + { + if (!text[0]) + RAPIDXML_PARSE_ERROR("unexpected end of data", text); + ++text; + } + + // Create new cdata node + xml_node *cdata = this->allocate_node(node_cdata); + cdata->value(value, text - value); + + // Place zero terminator after value + if (!(Flags & parse_no_string_terminators)) + *text = Ch('\0'); + + text += 3; // Skip ]]> + return cdata; + } + + // Parse element node + template + xml_node *parse_element(Ch *&text) + { + // Create element node + xml_node *element = this->allocate_node(node_element); + + // Extract element name + Ch *name = text; + skip(text); + if (text == name) + RAPIDXML_PARSE_ERROR("expected element name", text); + element->name(name, text - name); + + // Skip whitespace between element name and attributes or > + skip(text); + + // Parse attributes, if any + parse_node_attributes(text, element); + + // Determine ending type + if (*text == Ch('>')) + { + ++text; + parse_node_contents(text, element); + } + else if (*text == Ch('/')) + { + ++text; + if (*text != Ch('>')) + RAPIDXML_PARSE_ERROR("expected >", text); + ++text; + } + else + RAPIDXML_PARSE_ERROR("expected >", text); + + // Place zero terminator after name + if (!(Flags & parse_no_string_terminators)) + element->name()[element->name_size()] = Ch('\0'); + + // Return parsed element + return element; + } + + // Determine node type, and parse it + template + xml_node *parse_node(Ch *&text) + { + // Parse proper node type + switch (text[0]) + { + + // <... + default: + // Parse and append element node + return parse_element(text); + + // (text); + } + else + { + // Parse PI + return parse_pi(text); + } + + // (text); + } + break; + + // (text); + } + break; + + // (text); + } + + } // switch + + // Attempt to skip other, unrecognized node types starting with ')) + { + if (*text == 0) + RAPIDXML_PARSE_ERROR("unexpected end of data", text); + ++text; + } + ++text; // Skip '>' + return 0; // No node recognized + + } + } + + // Parse contents of the node - children, data etc. + template + void parse_node_contents(Ch *&text, xml_node *node) + { + // For all children and text + while (1) + { + // Skip whitespace between > and node contents + Ch *contents_start = text; // Store start of node contents before whitespace is skipped + skip(text); + Ch next_char = *text; + + // After data nodes, instead of continuing the loop, control jumps here. + // This is because zero termination inside parse_and_append_data() function + // would wreak havoc with the above code. + // Also, skipping whitespace after data nodes is unnecessary. + after_data_node: + + // Determine what comes next: node closing, child node, data node, or 0? + switch (next_char) + { + + // Node closing or child node + case Ch('<'): + if (text[1] == Ch('/')) + { + // Node closing + text += 2; // Skip '(text); + if (!internal::compare(node->name(), node->name_size(), closing_name, text - closing_name, true)) + RAPIDXML_PARSE_ERROR("invalid closing tag name", text); + } + else + { + // No validation, just skip name + skip(text); + } + // Skip remaining whitespace after node name + skip(text); + if (*text != Ch('>')) + RAPIDXML_PARSE_ERROR("expected >", text); + ++text; // Skip '>' + return; // Node closed, finished parsing contents + } + else + { + // Child node + ++text; // Skip '<' + if (xml_node *child = parse_node(text)) + node->append_node(child); + } + break; + + // End of data - error + case Ch('\0'): + RAPIDXML_PARSE_ERROR("unexpected end of data", text); + + // Data node + default: + next_char = parse_and_append_data(node, text, contents_start); + goto after_data_node; // Bypass regular processing after data nodes + + } + } + } + + // Parse XML attributes of the node + template + void parse_node_attributes(Ch *&text, xml_node *node) + { + // For all attributes + while (attribute_name_pred::test(*text)) + { + // Extract attribute name + Ch *name = text; + ++text; // Skip first character of attribute name + skip(text); + if (text == name) + RAPIDXML_PARSE_ERROR("expected attribute name", name); + + // Create new attribute + xml_attribute *attribute = this->allocate_attribute(); + attribute->name(name, text - name); + node->append_attribute(attribute); + + // Skip whitespace after attribute name + skip(text); + + // Skip = + if (*text != Ch('=')) + RAPIDXML_PARSE_ERROR("expected =", text); + ++text; + + // Add terminating zero after name + if (!(Flags & parse_no_string_terminators)) + attribute->name()[attribute->name_size()] = 0; + + // Skip whitespace after = + skip(text); + + // Skip quote and remember if it was ' or " + Ch quote = *text; + if (quote != Ch('\'') && quote != Ch('"')) + RAPIDXML_PARSE_ERROR("expected ' or \"", text); + ++text; + + // Extract attribute value and expand char refs in it + Ch *value = text, *end; + const int AttFlags = Flags & ~parse_normalize_whitespace; // No whitespace normalization in attributes + if (quote == Ch('\'')) + end = skip_and_expand_character_refs, attribute_value_pure_pred, AttFlags>(text); + else + end = skip_and_expand_character_refs, attribute_value_pure_pred, AttFlags>(text); + + // Set attribute value + attribute->value(value, end - value); + + // Make sure that end quote is present + if (*text != quote) + RAPIDXML_PARSE_ERROR("expected ' or \"", text); + ++text; // Skip quote + + // Add terminating zero after value + if (!(Flags & parse_no_string_terminators)) + attribute->value()[attribute->value_size()] = 0; + + // Skip whitespace after attribute value + skip(text); + } + } + + }; + + //! \cond internal + namespace internal + { + + // Whitespace (space \n \r \t) + template + const unsigned char lookup_tables::lookup_whitespace[256] = + { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, // 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1 + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 4 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 5 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 6 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 7 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // A + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // B + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // C + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // D + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // E + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // F + }; + + // Node name (anything but space \n \r \t / > ? \0) + template + const unsigned char lookup_tables::lookup_node_name[256] = + { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, // 0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, // 2 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, // 3 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F + }; + + // Text (i.e. PCDATA) (anything but < \0) + template + const unsigned char lookup_tables::lookup_text[256] = + { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, // 3 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F + }; + + // Text (i.e. PCDATA) that does not require processing when ws normalization is disabled + // (anything but < \0 &) + template + const unsigned char lookup_tables::lookup_text_pure_no_ws[256] = + { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 + 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, // 3 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F + }; + + // Text (i.e. PCDATA) that does not require processing when ws normalizationis is enabled + // (anything but < \0 & space \n \r \t) + template + const unsigned char lookup_tables::lookup_text_pure_with_ws[256] = + { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, // 0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 + 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, // 3 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F + }; + + // Attribute name (anything but space \n \r \t / < > = ? ! \0) + template + const unsigned char lookup_tables::lookup_attribute_name[256] = + { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, // 0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 + 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, // 2 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, // 3 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F + }; + + // Attribute data with single quote (anything but ' \0) + template + const unsigned char lookup_tables::lookup_attribute_data_1[256] = + { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 + 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, // 2 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 3 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F + }; + + // Attribute data with single quote that does not require processing (anything but ' \0 &) + template + const unsigned char lookup_tables::lookup_attribute_data_1_pure[256] = + { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 + 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, // 2 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 3 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F + }; + + // Attribute data with double quote (anything but " \0) + template + const unsigned char lookup_tables::lookup_attribute_data_2[256] = + { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 + 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 3 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F + }; + + // Attribute data with double quote that does not require processing (anything but " \0 &) + template + const unsigned char lookup_tables::lookup_attribute_data_2_pure[256] = + { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 + 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 3 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // F + }; + + // Digits (dec and hex, 255 denotes end of numeric character reference) + template + const unsigned char lookup_tables::lookup_digits[256] = + { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 0 + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 1 + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 2 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,255,255,255,255,255,255, // 3 + 255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255, // 4 + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 5 + 255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255, // 6 + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 7 + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 8 + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // 9 + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // A + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // B + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // C + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // D + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, // E + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255 // F + }; + + // Upper case conversion + template + const unsigned char lookup_tables::lookup_upcase[256] = + { + // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A B C D E F + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 0 + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, // 1 + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, // 2 + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, // 3 + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, // 4 + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, // 5 + 96, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, // 6 + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 123,124,125,126,127, // 7 + 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, // 8 + 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, // 9 + 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175, // A + 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, // B + 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, // C + 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, // D + 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, // E + 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255 // F + }; + } + //! \endcond + +} + +// Undefine internal macros +#undef RAPIDXML_PARSE_ERROR + +// On MSVC, restore warnings state +#ifdef _MSC_VER + #pragma warning(pop) +#endif + +#endif diff --git a/engine/util/rapidxml/rapidxml_print.hpp b/engine/lib/rapidxml/rapidxml_print.hpp similarity index 97% rename from engine/util/rapidxml/rapidxml_print.hpp rename to engine/lib/rapidxml/rapidxml_print.hpp index 5847ce8a627..b2db471a936 100644 --- a/engine/util/rapidxml/rapidxml_print.hpp +++ b/engine/lib/rapidxml/rapidxml_print.hpp @@ -1,435 +1,435 @@ -#ifndef RAPIDXML_PRINT_HPP_INCLUDED -#define RAPIDXML_PRINT_HPP_INCLUDED - -// Copyright (C) 2006, 2009 Marcin Kalicinski -// Version 1.13 -// Revision $DateTime: 2009/05/13 01:46:17 $ -//! \file rapidxml_print.hpp This file contains rapidxml printer implementation - -#include "rapidxml.hpp" - -// Only include streams if not disabled -#ifndef RAPIDXML_NO_STREAMS - #include - #include -#endif - -namespace rapidxml -{ - - /////////////////////////////////////////////////////////////////////// - // Printing flags - - const int print_no_indenting = 0x1; //!< Printer flag instructing the printer to suppress indenting of XML. See print() function. - - /////////////////////////////////////////////////////////////////////// - // Internal - - //! \cond internal - namespace internal - { - - /////////////////////////////////////////////////////////////////////////// - // Internal character operations - - // Copy characters from given range to given output iterator - template - inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out) - { - while (begin != end) - *out++ = *begin++; - return out; - } - - // Copy characters from given range to given output iterator and expand - // characters into references (< > ' " &) - template - inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out) - { - while (begin != end) - { - if (*begin == noexpand) - { - *out++ = *begin; // No expansion, copy character - } - else - { - switch (*begin) - { - case Ch('<'): - *out++ = Ch('&'); *out++ = Ch('l'); *out++ = Ch('t'); *out++ = Ch(';'); - break; - case Ch('>'): - *out++ = Ch('&'); *out++ = Ch('g'); *out++ = Ch('t'); *out++ = Ch(';'); - break; - case Ch('\''): - *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('p'); *out++ = Ch('o'); *out++ = Ch('s'); *out++ = Ch(';'); - break; - case Ch('"'): - *out++ = Ch('&'); *out++ = Ch('q'); *out++ = Ch('u'); *out++ = Ch('o'); *out++ = Ch('t'); *out++ = Ch(';'); - break; - case Ch('&'): - *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';'); - break; - default: - *out++ = *begin; // No expansion, copy character - } - } - ++begin; // Step to next character - } - return out; - } - - // Fill given output iterator with repetitions of the same character - template - inline OutIt fill_chars(OutIt out, int n, Ch ch) - { - for (int i = 0; i < n; ++i) - *out++ = ch; - return out; - } - - // Find character - template - inline bool find_char(const Ch *begin, const Ch *end) - { - while (begin != end) - if (*begin++ == ch) - return true; - return false; - } - - /////////////////////////////////////////////////////////////////////////// - // Internal printing operations - - // ===================================== - // fix for clang for this bug in gcc and others: http://sourceforge.net/p/rapidxml/bugs/16/ - - template inline OutIt print_children(OutIt out, const xml_node *node, int flags, int indent); - template inline OutIt print_element_node(OutIt out, const xml_node *node, int flags, int indent); - template inline OutIt print_data_node(OutIt out, const xml_node *node, int flags, int indent); - template inline OutIt print_cdata_node(OutIt out, const xml_node *node, int flags, int indent); - template inline OutIt print_declaration_node(OutIt out, const xml_node *node, int flags, int indent); - template inline OutIt print_comment_node(OutIt out, const xml_node *node, int flags, int indent); - template inline OutIt print_doctype_node(OutIt out, const xml_node *node, int flags, int indent); - template inline OutIt print_pi_node(OutIt out, const xml_node *node, int flags, int indent); - - // ===================================== - - // Print node - template - inline OutIt print_node(OutIt out, const xml_node *node, int flags, int indent) - { - // Print proper node type - switch (node->type()) - { - - // Document - case node_document: - out = print_children(out, node, flags, indent); - break; - - // Element - case node_element: - out = print_element_node(out, node, flags, indent); - break; - - // Data - case node_data: - out = print_data_node(out, node, flags, indent); - break; - - // CDATA - case node_cdata: - out = print_cdata_node(out, node, flags, indent); - break; - - // Declaration - case node_declaration: - out = print_declaration_node(out, node, flags, indent); - break; - - // Comment - case node_comment: - out = print_comment_node(out, node, flags, indent); - break; - - // Doctype - case node_doctype: - out = print_doctype_node(out, node, flags, indent); - break; - - // Pi - case node_pi: - out = print_pi_node(out, node, flags, indent); - break; - - // Unknown - default: - assert(0); - break; - } - - // If indenting not disabled, add line break after node - if (!(flags & print_no_indenting)) - *out = Ch('\n'), ++out; - - // Return modified iterator - return out; - } - - // Print children of the node - template - inline OutIt print_children(OutIt out, const xml_node *node, int flags, int indent) - { - for (xml_node *child = node->first_node(); child; child = child->next_sibling()) - out = print_node(out, child, flags, indent); - return out; - } - - // Print attributes of the node - template - inline OutIt print_attributes(OutIt out, const xml_node *node, int /*flags*/) - { - for (xml_attribute *attribute = node->first_attribute(); attribute; attribute = attribute->next_attribute()) - { - if (attribute->name() && attribute->value()) - { - // Print attribute name - *out = Ch(' '), ++out; - out = copy_chars(attribute->name(), attribute->name() + attribute->name_size(), out); - *out = Ch('='), ++out; - // Print attribute value using appropriate quote type - if (find_char(attribute->value(), attribute->value() + attribute->value_size())) - { - *out = Ch('\''), ++out; - out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('"'), out); - *out = Ch('\''), ++out; - } - else - { - *out = Ch('"'), ++out; - out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('\''), out); - *out = Ch('"'), ++out; - } - } - } - return out; - } - - // Print data node - template - inline OutIt print_data_node(OutIt out, const xml_node *node, int flags, int indent) - { - assert(node->type() == node_data); - if (!(flags & print_no_indenting)) - out = fill_chars(out, indent, Ch('\t')); - out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out); - return out; - } - - // Print data node - template - inline OutIt print_cdata_node(OutIt out, const xml_node *node, int flags, int indent) - { - assert(node->type() == node_cdata); - if (!(flags & print_no_indenting)) - out = fill_chars(out, indent, Ch('\t')); - *out = Ch('<'); ++out; - *out = Ch('!'); ++out; - *out = Ch('['); ++out; - *out = Ch('C'); ++out; - *out = Ch('D'); ++out; - *out = Ch('A'); ++out; - *out = Ch('T'); ++out; - *out = Ch('A'); ++out; - *out = Ch('['); ++out; - out = copy_chars(node->value(), node->value() + node->value_size(), out); - *out = Ch(']'); ++out; - *out = Ch(']'); ++out; - *out = Ch('>'); ++out; - return out; - } - - // Print element node - template - inline OutIt print_element_node(OutIt out, const xml_node *node, int flags, int indent) - { - assert(node->type() == node_element); - - // Print element name and attributes, if any - if (!(flags & print_no_indenting)) - out = fill_chars(out, indent, Ch('\t')); - *out = Ch('<'), ++out; - out = copy_chars(node->name(), node->name() + node->name_size(), out); - out = print_attributes(out, node, flags); - - // If node is childless - if (node->value_size() == 0 && !node->first_node()) - { - // Print childless node tag ending - *out = Ch('/'), ++out; - *out = Ch('>'), ++out; - } - else - { - // Print normal node tag ending - *out = Ch('>'), ++out; - - // Test if node contains a single data node only (and no other nodes) - xml_node *child = node->first_node(); - if (!child) - { - // If node has no children, only print its value without indenting - out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out); - } - else if (child->next_sibling() == 0 && child->type() == node_data) - { - // If node has a sole data child, only print its value without indenting - out = copy_and_expand_chars(child->value(), child->value() + child->value_size(), Ch(0), out); - } - else - { - // Print all children with full indenting - if (!(flags & print_no_indenting)) - *out = Ch('\n'), ++out; - out = print_children(out, node, flags, indent + 1); - if (!(flags & print_no_indenting)) - out = fill_chars(out, indent, Ch('\t')); - } - - // Print node end - *out = Ch('<'), ++out; - *out = Ch('/'), ++out; - out = copy_chars(node->name(), node->name() + node->name_size(), out); - *out = Ch('>'), ++out; - } - return out; - } - - // Print declaration node - template - inline OutIt print_declaration_node(OutIt out, const xml_node *node, int flags, int indent) - { - // Print declaration start - if (!(flags & print_no_indenting)) - out = fill_chars(out, indent, Ch('\t')); - *out = Ch('<'), ++out; - *out = Ch('?'), ++out; - *out = Ch('x'), ++out; - *out = Ch('m'), ++out; - *out = Ch('l'), ++out; - - // Print attributes - out = print_attributes(out, node, flags); - - // Print declaration end - *out = Ch('?'), ++out; - *out = Ch('>'), ++out; - - return out; - } - - // Print comment node - template - inline OutIt print_comment_node(OutIt out, const xml_node *node, int flags, int indent) - { - assert(node->type() == node_comment); - if (!(flags & print_no_indenting)) - out = fill_chars(out, indent, Ch('\t')); - *out = Ch('<'), ++out; - *out = Ch('!'), ++out; - *out = Ch('-'), ++out; - *out = Ch('-'), ++out; - out = copy_chars(node->value(), node->value() + node->value_size(), out); - *out = Ch('-'), ++out; - *out = Ch('-'), ++out; - *out = Ch('>'), ++out; - return out; - } - - // Print doctype node - template - inline OutIt print_doctype_node(OutIt out, const xml_node *node, int flags, int indent) - { - assert(node->type() == node_doctype); - if (!(flags & print_no_indenting)) - out = fill_chars(out, indent, Ch('\t')); - *out = Ch('<'), ++out; - *out = Ch('!'), ++out; - *out = Ch('D'), ++out; - *out = Ch('O'), ++out; - *out = Ch('C'), ++out; - *out = Ch('T'), ++out; - *out = Ch('Y'), ++out; - *out = Ch('P'), ++out; - *out = Ch('E'), ++out; - *out = Ch(' '), ++out; - out = copy_chars(node->value(), node->value() + node->value_size(), out); - *out = Ch('>'), ++out; - return out; - } - - // Print pi node - template - inline OutIt print_pi_node(OutIt out, const xml_node *node, int flags, int indent) - { - assert(node->type() == node_pi); - if (!(flags & print_no_indenting)) - out = fill_chars(out, indent, Ch('\t')); - *out = Ch('<'), ++out; - *out = Ch('?'), ++out; - out = copy_chars(node->name(), node->name() + node->name_size(), out); - *out = Ch(' '), ++out; - out = copy_chars(node->value(), node->value() + node->value_size(), out); - *out = Ch('?'), ++out; - *out = Ch('>'), ++out; - return out; - } - - } - //! \endcond - - /////////////////////////////////////////////////////////////////////////// - // Printing - - //! Prints XML to given output iterator. - //! \param out Output iterator to print to. - //! \param node Node to be printed. Pass xml_document to print entire document. - //! \param flags Flags controlling how XML is printed. - //! \return Output iterator pointing to position immediately after last character of printed text. - template - inline OutIt print(OutIt out, const xml_node &node, int flags = 0) - { - return internal::print_node(out, &node, flags, 0); - } - -#ifndef RAPIDXML_NO_STREAMS - - //! Prints XML to given output stream. - //! \param out Output stream to print to. - //! \param node Node to be printed. Pass xml_document to print entire document. - //! \param flags Flags controlling how XML is printed. - //! \return Output stream. - template - inline std::basic_ostream &print(std::basic_ostream &out, const xml_node &node, int flags = 0) - { - print(std::ostream_iterator(out), node, flags); - return out; - } - - //! Prints formatted XML to given output stream. Uses default printing flags. Use print() function to customize printing process. - //! \param out Output stream to print to. - //! \param node Node to be printed. - //! \return Output stream. - template - inline std::basic_ostream &operator <<(std::basic_ostream &out, const xml_node &node) - { - return print(out, node); - } - -#endif - -} - -#endif +#ifndef RAPIDXML_PRINT_HPP_INCLUDED +#define RAPIDXML_PRINT_HPP_INCLUDED + +// Copyright (C) 2006, 2009 Marcin Kalicinski +// Version 1.13 +// Revision $DateTime: 2009/05/13 01:46:17 $ +//! \file rapidxml_print.hpp This file contains rapidxml printer implementation + +#include "rapidxml.hpp" + +// Only include streams if not disabled +#ifndef RAPIDXML_NO_STREAMS + #include + #include +#endif + +namespace rapidxml +{ + + /////////////////////////////////////////////////////////////////////// + // Printing flags + + const int print_no_indenting = 0x1; //!< Printer flag instructing the printer to suppress indenting of XML. See print() function. + + /////////////////////////////////////////////////////////////////////// + // Internal + + //! \cond internal + namespace internal + { + + /////////////////////////////////////////////////////////////////////////// + // Internal character operations + + // Copy characters from given range to given output iterator + template + inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out) + { + while (begin != end) + *out++ = *begin++; + return out; + } + + // Copy characters from given range to given output iterator and expand + // characters into references (< > ' " &) + template + inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out) + { + while (begin != end) + { + if (*begin == noexpand) + { + *out++ = *begin; // No expansion, copy character + } + else + { + switch (*begin) + { + case Ch('<'): + *out++ = Ch('&'); *out++ = Ch('l'); *out++ = Ch('t'); *out++ = Ch(';'); + break; + case Ch('>'): + *out++ = Ch('&'); *out++ = Ch('g'); *out++ = Ch('t'); *out++ = Ch(';'); + break; + case Ch('\''): + *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('p'); *out++ = Ch('o'); *out++ = Ch('s'); *out++ = Ch(';'); + break; + case Ch('"'): + *out++ = Ch('&'); *out++ = Ch('q'); *out++ = Ch('u'); *out++ = Ch('o'); *out++ = Ch('t'); *out++ = Ch(';'); + break; + case Ch('&'): + *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';'); + break; + default: + *out++ = *begin; // No expansion, copy character + } + } + ++begin; // Step to next character + } + return out; + } + + // Fill given output iterator with repetitions of the same character + template + inline OutIt fill_chars(OutIt out, int n, Ch ch) + { + for (int i = 0; i < n; ++i) + *out++ = ch; + return out; + } + + // Find character + template + inline bool find_char(const Ch *begin, const Ch *end) + { + while (begin != end) + if (*begin++ == ch) + return true; + return false; + } + + /////////////////////////////////////////////////////////////////////////// + // Internal printing operations + + // ===================================== + // fix for clang for this bug in gcc and others: http://sourceforge.net/p/rapidxml/bugs/16/ + + template inline OutIt print_children(OutIt out, const xml_node *node, int flags, int indent); + template inline OutIt print_element_node(OutIt out, const xml_node *node, int flags, int indent); + template inline OutIt print_data_node(OutIt out, const xml_node *node, int flags, int indent); + template inline OutIt print_cdata_node(OutIt out, const xml_node *node, int flags, int indent); + template inline OutIt print_declaration_node(OutIt out, const xml_node *node, int flags, int indent); + template inline OutIt print_comment_node(OutIt out, const xml_node *node, int flags, int indent); + template inline OutIt print_doctype_node(OutIt out, const xml_node *node, int flags, int indent); + template inline OutIt print_pi_node(OutIt out, const xml_node *node, int flags, int indent); + + // ===================================== + + // Print node + template + inline OutIt print_node(OutIt out, const xml_node *node, int flags, int indent) + { + // Print proper node type + switch (node->type()) + { + + // Document + case node_document: + out = print_children(out, node, flags, indent); + break; + + // Element + case node_element: + out = print_element_node(out, node, flags, indent); + break; + + // Data + case node_data: + out = print_data_node(out, node, flags, indent); + break; + + // CDATA + case node_cdata: + out = print_cdata_node(out, node, flags, indent); + break; + + // Declaration + case node_declaration: + out = print_declaration_node(out, node, flags, indent); + break; + + // Comment + case node_comment: + out = print_comment_node(out, node, flags, indent); + break; + + // Doctype + case node_doctype: + out = print_doctype_node(out, node, flags, indent); + break; + + // Pi + case node_pi: + out = print_pi_node(out, node, flags, indent); + break; + + // Unknown + default: + assert(0); + break; + } + + // If indenting not disabled, add line break after node + if (!(flags & print_no_indenting)) + *out = Ch('\n'), ++out; + + // Return modified iterator + return out; + } + + // Print children of the node + template + inline OutIt print_children(OutIt out, const xml_node *node, int flags, int indent) + { + for (xml_node *child = node->first_node(); child; child = child->next_sibling()) + out = print_node(out, child, flags, indent); + return out; + } + + // Print attributes of the node + template + inline OutIt print_attributes(OutIt out, const xml_node *node, int /*flags*/) + { + for (xml_attribute *attribute = node->first_attribute(); attribute; attribute = attribute->next_attribute()) + { + if (attribute->name() && attribute->value()) + { + // Print attribute name + *out = Ch(' '), ++out; + out = copy_chars(attribute->name(), attribute->name() + attribute->name_size(), out); + *out = Ch('='), ++out; + // Print attribute value using appropriate quote type + if (find_char(attribute->value(), attribute->value() + attribute->value_size())) + { + *out = Ch('\''), ++out; + out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('"'), out); + *out = Ch('\''), ++out; + } + else + { + *out = Ch('"'), ++out; + out = copy_and_expand_chars(attribute->value(), attribute->value() + attribute->value_size(), Ch('\''), out); + *out = Ch('"'), ++out; + } + } + } + return out; + } + + // Print data node + template + inline OutIt print_data_node(OutIt out, const xml_node *node, int flags, int indent) + { + assert(node->type() == node_data); + if (!(flags & print_no_indenting)) + out = fill_chars(out, indent, Ch('\t')); + out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out); + return out; + } + + // Print data node + template + inline OutIt print_cdata_node(OutIt out, const xml_node *node, int flags, int indent) + { + assert(node->type() == node_cdata); + if (!(flags & print_no_indenting)) + out = fill_chars(out, indent, Ch('\t')); + *out = Ch('<'); ++out; + *out = Ch('!'); ++out; + *out = Ch('['); ++out; + *out = Ch('C'); ++out; + *out = Ch('D'); ++out; + *out = Ch('A'); ++out; + *out = Ch('T'); ++out; + *out = Ch('A'); ++out; + *out = Ch('['); ++out; + out = copy_chars(node->value(), node->value() + node->value_size(), out); + *out = Ch(']'); ++out; + *out = Ch(']'); ++out; + *out = Ch('>'); ++out; + return out; + } + + // Print element node + template + inline OutIt print_element_node(OutIt out, const xml_node *node, int flags, int indent) + { + assert(node->type() == node_element); + + // Print element name and attributes, if any + if (!(flags & print_no_indenting)) + out = fill_chars(out, indent, Ch('\t')); + *out = Ch('<'), ++out; + out = copy_chars(node->name(), node->name() + node->name_size(), out); + out = print_attributes(out, node, flags); + + // If node is childless + if (node->value_size() == 0 && !node->first_node()) + { + // Print childless node tag ending + *out = Ch('/'), ++out; + *out = Ch('>'), ++out; + } + else + { + // Print normal node tag ending + *out = Ch('>'), ++out; + + // Test if node contains a single data node only (and no other nodes) + xml_node *child = node->first_node(); + if (!child) + { + // If node has no children, only print its value without indenting + out = copy_and_expand_chars(node->value(), node->value() + node->value_size(), Ch(0), out); + } + else if (child->next_sibling() == 0 && child->type() == node_data) + { + // If node has a sole data child, only print its value without indenting + out = copy_and_expand_chars(child->value(), child->value() + child->value_size(), Ch(0), out); + } + else + { + // Print all children with full indenting + if (!(flags & print_no_indenting)) + *out = Ch('\n'), ++out; + out = print_children(out, node, flags, indent + 1); + if (!(flags & print_no_indenting)) + out = fill_chars(out, indent, Ch('\t')); + } + + // Print node end + *out = Ch('<'), ++out; + *out = Ch('/'), ++out; + out = copy_chars(node->name(), node->name() + node->name_size(), out); + *out = Ch('>'), ++out; + } + return out; + } + + // Print declaration node + template + inline OutIt print_declaration_node(OutIt out, const xml_node *node, int flags, int indent) + { + // Print declaration start + if (!(flags & print_no_indenting)) + out = fill_chars(out, indent, Ch('\t')); + *out = Ch('<'), ++out; + *out = Ch('?'), ++out; + *out = Ch('x'), ++out; + *out = Ch('m'), ++out; + *out = Ch('l'), ++out; + + // Print attributes + out = print_attributes(out, node, flags); + + // Print declaration end + *out = Ch('?'), ++out; + *out = Ch('>'), ++out; + + return out; + } + + // Print comment node + template + inline OutIt print_comment_node(OutIt out, const xml_node *node, int flags, int indent) + { + assert(node->type() == node_comment); + if (!(flags & print_no_indenting)) + out = fill_chars(out, indent, Ch('\t')); + *out = Ch('<'), ++out; + *out = Ch('!'), ++out; + *out = Ch('-'), ++out; + *out = Ch('-'), ++out; + out = copy_chars(node->value(), node->value() + node->value_size(), out); + *out = Ch('-'), ++out; + *out = Ch('-'), ++out; + *out = Ch('>'), ++out; + return out; + } + + // Print doctype node + template + inline OutIt print_doctype_node(OutIt out, const xml_node *node, int flags, int indent) + { + assert(node->type() == node_doctype); + if (!(flags & print_no_indenting)) + out = fill_chars(out, indent, Ch('\t')); + *out = Ch('<'), ++out; + *out = Ch('!'), ++out; + *out = Ch('D'), ++out; + *out = Ch('O'), ++out; + *out = Ch('C'), ++out; + *out = Ch('T'), ++out; + *out = Ch('Y'), ++out; + *out = Ch('P'), ++out; + *out = Ch('E'), ++out; + *out = Ch(' '), ++out; + out = copy_chars(node->value(), node->value() + node->value_size(), out); + *out = Ch('>'), ++out; + return out; + } + + // Print pi node + template + inline OutIt print_pi_node(OutIt out, const xml_node *node, int flags, int indent) + { + assert(node->type() == node_pi); + if (!(flags & print_no_indenting)) + out = fill_chars(out, indent, Ch('\t')); + *out = Ch('<'), ++out; + *out = Ch('?'), ++out; + out = copy_chars(node->name(), node->name() + node->name_size(), out); + *out = Ch(' '), ++out; + out = copy_chars(node->value(), node->value() + node->value_size(), out); + *out = Ch('?'), ++out; + *out = Ch('>'), ++out; + return out; + } + + } + //! \endcond + + /////////////////////////////////////////////////////////////////////////// + // Printing + + //! Prints XML to given output iterator. + //! \param out Output iterator to print to. + //! \param node Node to be printed. Pass xml_document to print entire document. + //! \param flags Flags controlling how XML is printed. + //! \return Output iterator pointing to position immediately after last character of printed text. + template + inline OutIt print(OutIt out, const xml_node &node, int flags = 0) + { + return internal::print_node(out, &node, flags, 0); + } + +#ifndef RAPIDXML_NO_STREAMS + + //! Prints XML to given output stream. + //! \param out Output stream to print to. + //! \param node Node to be printed. Pass xml_document to print entire document. + //! \param flags Flags controlling how XML is printed. + //! \return Output stream. + template + inline std::basic_ostream &print(std::basic_ostream &out, const xml_node &node, int flags = 0) + { + print(std::ostream_iterator(out), node, flags); + return out; + } + + //! Prints formatted XML to given output stream. Uses default printing flags. Use print() function to customize printing process. + //! \param out Output stream to print to. + //! \param node Node to be printed. + //! \return Output stream. + template + inline std::basic_ostream &operator <<(std::basic_ostream &out, const xml_node &node) + { + return print(out, node); + } + +#endif + +} + +#endif diff --git a/engine/util/utf8-cpp/Readme.md b/engine/lib/utf8-cpp/Readme.md similarity index 100% rename from engine/util/utf8-cpp/Readme.md rename to engine/lib/utf8-cpp/Readme.md diff --git a/engine/util/utf8-cpp/utf8.h b/engine/lib/utf8-cpp/utf8.h similarity index 100% rename from engine/util/utf8-cpp/utf8.h rename to engine/lib/utf8-cpp/utf8.h diff --git a/engine/util/utf8-cpp/utf8/checked.h b/engine/lib/utf8-cpp/utf8/checked.h similarity index 100% rename from engine/util/utf8-cpp/utf8/checked.h rename to engine/lib/utf8-cpp/utf8/checked.h diff --git a/engine/util/utf8-cpp/utf8/core.h b/engine/lib/utf8-cpp/utf8/core.h similarity index 100% rename from engine/util/utf8-cpp/utf8/core.h rename to engine/lib/utf8-cpp/utf8/core.h diff --git a/engine/util/utf8-cpp/utf8/unchecked.h b/engine/lib/utf8-cpp/utf8/unchecked.h similarity index 100% rename from engine/util/utf8-cpp/utf8/unchecked.h rename to engine/lib/utf8-cpp/utf8/unchecked.h diff --git a/engine/util/utf8-h/Readme.md b/engine/lib/utf8-h/Readme.md similarity index 100% rename from engine/util/utf8-h/Readme.md rename to engine/lib/utf8-h/Readme.md diff --git a/engine/util/utf8-h/utf8.h b/engine/lib/utf8-h/utf8.h similarity index 100% rename from engine/util/utf8-h/utf8.h rename to engine/lib/utf8-h/utf8.h diff --git a/engine/player/actor.hpp b/engine/player/actor.hpp index 6d1cd4c414e..e8bff4c7d37 100644 --- a/engine/player/actor.hpp +++ b/engine/player/actor.hpp @@ -6,8 +6,8 @@ #pragma once #include "config.hpp" -#include "generic.hpp" -#include "stopwatch.hpp" +#include "util/generic.hpp" +#include "util/stopwatch.hpp" #include struct sim_t; diff --git a/engine/player/actor_target_data.hpp b/engine/player/actor_target_data.hpp index b7753e6d1e8..de160bc928f 100644 --- a/engine/player/actor_target_data.hpp +++ b/engine/player/actor_target_data.hpp @@ -7,7 +7,7 @@ #include "config.hpp" #include "sc_actor_pair.hpp" -#include "generic.hpp" +#include "util/generic.hpp" struct buff_t; struct player_t; diff --git a/engine/player/assessor.hpp b/engine/player/assessor.hpp index b22e1cd4676..97e6dbe0116 100644 --- a/engine/player/assessor.hpp +++ b/engine/player/assessor.hpp @@ -6,7 +6,7 @@ #pragma once #include "config.hpp" -#include "generic.hpp" +#include "util/generic.hpp" #include "sc_enums.hpp" #include #include diff --git a/engine/player/azerite_data.hpp b/engine/player/azerite_data.hpp index 44e6f901f40..86f6ceb9857 100644 --- a/engine/player/azerite_data.hpp +++ b/engine/player/azerite_data.hpp @@ -10,7 +10,7 @@ #include #include "sc_util.hpp" -#include "util/rapidjson/document.h" +#include "rapidjson/document.h" #include "report/sc_report.hpp" #include "sc_timespan.hpp" diff --git a/engine/player/gear_stats.hpp b/engine/player/gear_stats.hpp index 12b12674d0e..a69c0a70a8d 100644 --- a/engine/player/gear_stats.hpp +++ b/engine/player/gear_stats.hpp @@ -6,7 +6,7 @@ #pragma once #include "config.hpp" -#include "generic.hpp" +#include "util/generic.hpp" #include "sc_enums.hpp" #include #include diff --git a/engine/player/player_collected_data.hpp b/engine/player/player_collected_data.hpp index c5fca567383..29caa8156cc 100644 --- a/engine/player/player_collected_data.hpp +++ b/engine/player/player_collected_data.hpp @@ -6,9 +6,9 @@ #pragma once #include "config.hpp" -#include "sample_data.hpp" -#include "timeline.hpp" -#include "concurrency.hpp" +#include "util/sample_data.hpp" +#include "util/timeline.hpp" +#include "util/concurrency.hpp" #include "sc_enums.hpp" struct action_t; diff --git a/engine/player/player_scaling.hpp b/engine/player/player_scaling.hpp index 2fa6232f1f9..05c3a623135 100644 --- a/engine/player/player_scaling.hpp +++ b/engine/player/player_scaling.hpp @@ -6,7 +6,7 @@ #pragma once #include "config.hpp" -#include "generic.hpp" +#include "util/generic.hpp" #include "sc_enums.hpp" #include #include diff --git a/engine/player/player_talent_points.hpp b/engine/player/player_talent_points.hpp index a7ff0be2887..eeb432046ad 100644 --- a/engine/player/player_talent_points.hpp +++ b/engine/player/player_talent_points.hpp @@ -6,7 +6,7 @@ #pragma once #include "config.hpp" -#include "generic.hpp" +#include "util/generic.hpp" #include "sc_enums.hpp" #include #include diff --git a/engine/player/stats.hpp b/engine/player/stats.hpp index db98c6f8cf7..d9ef019a9a0 100644 --- a/engine/player/stats.hpp +++ b/engine/player/stats.hpp @@ -8,7 +8,7 @@ #include "config.hpp" #include "sc_enums.hpp" #include "sc_timespan.hpp" -#include "sample_data.hpp" +#include "util/sample_data.hpp" #include "sim/gain.hpp" #include #include diff --git a/engine/player/target_specific.hpp b/engine/player/target_specific.hpp index de0a4b46684..fd8cd43db21 100644 --- a/engine/player/target_specific.hpp +++ b/engine/player/target_specific.hpp @@ -6,7 +6,7 @@ #pragma once #include "config.hpp" -#include "generic.hpp" +#include "util/generic.hpp" #include "player/sc_player.hpp" #include diff --git a/engine/report/sc_report_json.cpp b/engine/report/sc_report_json.cpp index b49536c6a91..d5d02103e91 100644 --- a/engine/report/sc_report_json.cpp +++ b/engine/report/sc_report_json.cpp @@ -9,10 +9,10 @@ #include "simulationcraft.hpp" #include "util/git_info.hpp" -#include "util/rapidjson/filewritestream.h" -#include "util/rapidjson/document.h" -#include "util/rapidjson/stringbuffer.h" -#include "util/rapidjson/prettywriter.h" +#include "rapidjson/filewritestream.h" +#include "rapidjson/document.h" +#include "rapidjson/stringbuffer.h" +#include "rapidjson/prettywriter.h" using namespace rapidjson; using namespace js; diff --git a/engine/sc_timespan.hpp b/engine/sc_timespan.hpp index da1cd1fba58..dc6a01bfc92 100644 --- a/engine/sc_timespan.hpp +++ b/engine/sc_timespan.hpp @@ -19,8 +19,8 @@ #include #include "util/generic.hpp" -#include "util/fmt/format.h" -#include "util/fmt/ostream.h" +#include "fmt/format.h" +#include "fmt/ostream.h" // if timespan_t is in the global namespace, there's a name lookup issue with // one of the Qt headers. Problem is avoided by defining in a sub-namespace diff --git a/engine/sc_util.hpp b/engine/sc_util.hpp index 18b992ec90a..64e7ea4fdde 100644 --- a/engine/sc_util.hpp +++ b/engine/sc_util.hpp @@ -7,9 +7,9 @@ #include "config.hpp" -#include "util/fmt/format.h" -#include "util/fmt/ostream.h" -#include "util/fmt/printf.h" +#include "fmt/format.h" +#include "fmt/ostream.h" +#include "fmt/printf.h" #include "sc_enums.hpp" #include "dbc/data_enums.hh" #include "dbc/specialization.hpp" diff --git a/engine/sim/event.hpp b/engine/sim/event.hpp index 037e855443c..97355937cce 100644 --- a/engine/sim/event.hpp +++ b/engine/sim/event.hpp @@ -6,7 +6,7 @@ #pragma once #include "config.hpp" -#include "generic.hpp" +#include "util/generic.hpp" #include "sc_timespan.hpp" struct actor_t; diff --git a/engine/sim/event_manager.hpp b/engine/sim/event_manager.hpp index 6bd877e72c5..81e258c33be 100644 --- a/engine/sim/event_manager.hpp +++ b/engine/sim/event_manager.hpp @@ -7,7 +7,7 @@ #include "config.hpp" #include "sc_timespan.hpp" -#include "stopwatch.hpp" +#include "util/stopwatch.hpp" #include #include diff --git a/engine/sim/raid_event.hpp b/engine/sim/raid_event.hpp index 4e85bff8f7e..679a7756f54 100644 --- a/engine/sim/raid_event.hpp +++ b/engine/sim/raid_event.hpp @@ -6,7 +6,7 @@ #pragma once #include "config.hpp" -#include "generic.hpp" +#include "util/generic.hpp" #include "sc_timespan.hpp" #include "sc_enums.hpp" #include diff --git a/engine/sim/real_ppm.cpp b/engine/sim/real_ppm.cpp index bf8989cf1f4..08f8275f8c4 100644 --- a/engine/sim/real_ppm.cpp +++ b/engine/sim/real_ppm.cpp @@ -6,7 +6,7 @@ #include "real_ppm.hpp" #include "player/sc_player.hpp" #include "sim/sc_sim.hpp" -#include "rng.hpp" +#include "util/rng.hpp" #include "item/item.hpp" real_ppm_t::real_ppm_t( const std::string& name, player_t* p, const spell_data_t* data, const item_t* item ) diff --git a/engine/sim/sc_option.cpp b/engine/sim/sc_option.cpp index 16777c517f8..6ca0daca9be 100644 --- a/engine/sim/sc_option.cpp +++ b/engine/sim/sc_option.cpp @@ -8,7 +8,7 @@ #include #include -#include "util/fmt/format.h" +#include "fmt/format.h" #include "util/io.hpp" #include "sc_util.hpp" diff --git a/engine/sim/sc_progress_bar.cpp b/engine/sim/sc_progress_bar.cpp index 533b1d56f1b..a9eeb7c7969 100644 --- a/engine/sim/sc_progress_bar.cpp +++ b/engine/sim/sc_progress_bar.cpp @@ -10,7 +10,7 @@ #include "player/player_scaling.hpp" #include "sim_control.hpp" #include "scale_factor_control.hpp" -#include "util/gsl-lite/gsl-lite.hpp" +#include "gsl-lite/gsl-lite.hpp" #include #include "simulationcraft.hpp" diff --git a/engine/sim/sc_sim.cpp b/engine/sim/sc_sim.cpp index 62be53b7fa4..44acf71879f 100644 --- a/engine/sim/sc_sim.cpp +++ b/engine/sim/sc_sim.cpp @@ -4,6 +4,7 @@ // ========================================================================== #include "sc_sim.hpp" +#include "simulationcraft.hpp" #include "sim_control.hpp" #include "sc_option.hpp" #include "report/sc_highchart.hpp" @@ -13,7 +14,6 @@ #ifdef SC_WINDOWS #include #endif -#include "simulationcraft.hpp" namespace { // UNNAMED NAMESPACE ============================================ diff --git a/engine/sim/sc_sim.hpp b/engine/sim/sc_sim.hpp index e8763104796..2a27df30b1e 100644 --- a/engine/sim/sc_sim.hpp +++ b/engine/sim/sc_sim.hpp @@ -6,7 +6,7 @@ #pragma once #include "config.hpp" -#include "concurrency.hpp" +#include "util/concurrency.hpp" #include "sim_ostream.hpp" #include "util/vector_with_callback.hpp" #include "dbc/dbc.hpp" diff --git a/engine/simulationcraft.hpp b/engine/simulationcraft.hpp index 4e899ef91de..6450b6b6a71 100644 --- a/engine/simulationcraft.hpp +++ b/engine/simulationcraft.hpp @@ -116,16 +116,16 @@ namespace highchart { #include "dbc/data_enums.hh" #include "dbc/data_definitions.hh" -#include "util/utf8-cpp/utf8.h" +#include "utf8-cpp/utf8.h" // string formatting library -#include "util/fmt/format.h" -#include "util/fmt/ostream.h" -#include "util/fmt/printf.h" +#include "fmt/format.h" +#include "fmt/ostream.h" +#include "fmt/printf.h" // GSL-Lite: Guideline Support Library, light version // Lib to assist with CPP Core Guidelines. -#include "util/gsl-lite/gsl-lite.hpp" +#include "gsl-lite/gsl-lite.hpp" // Time class representing ingame time #include "sc_timespan.hpp" @@ -224,7 +224,7 @@ struct luxurious_sample_data_t : public extended_sample_data_t, private noncopya #include "sim/iteration_data_entry.hpp" - +#include "sim/sim_control.hpp" #include "sim/progress_bar.hpp" #include "sim/event_manager.hpp" diff --git a/engine/util/cache.hpp b/engine/util/cache.hpp index 9043a70a1a5..3d7e05fc8cc 100644 --- a/engine/util/cache.hpp +++ b/engine/util/cache.hpp @@ -6,7 +6,7 @@ #pragma once #include "config.hpp" -#include "generic.hpp" +#include "util/generic.hpp" #include // Cache Control ============================================================ diff --git a/engine/util/concurrency.hpp b/engine/util/concurrency.hpp index a4d974bb837..82e76366d1c 100644 --- a/engine/util/concurrency.hpp +++ b/engine/util/concurrency.hpp @@ -12,7 +12,7 @@ #pragma once #include "config.hpp" -#include "generic.hpp" +#include "util/generic.hpp" #include #ifndef SC_NO_THREADING diff --git a/engine/util/io.cpp b/engine/util/io.cpp index df7de23eb12..8059f77a487 100644 --- a/engine/util/io.cpp +++ b/engine/util/io.cpp @@ -5,7 +5,7 @@ #include "io.hpp" #include "utf8-cpp/utf8.h" -#include "util/gsl-lite/gsl-lite.hpp" +#include "gsl-lite/gsl-lite.hpp" #include #include #include diff --git a/engine/util/io.hpp b/engine/util/io.hpp index 046ce948710..21b0d67b49d 100644 --- a/engine/util/io.hpp +++ b/engine/util/io.hpp @@ -7,7 +7,7 @@ #define SC_IO_HPP #include "config.hpp" -#include "util/fmt/printf.h" +#include "fmt/printf.h" #include #include #include diff --git a/engine/util/timeline.hpp b/engine/util/timeline.hpp index 2b8b09b83af..828b36ed018 100644 --- a/engine/util/timeline.hpp +++ b/engine/util/timeline.hpp @@ -12,7 +12,7 @@ #include #include -#include "generic.hpp" +#include "util/generic.hpp" #include "sample_data.hpp" #include "sc_timespan.hpp" diff --git a/simulationcraft.pri b/simulationcraft.pri index 915ecb7ab40..e0abf3f71a6 100644 --- a/simulationcraft.pri +++ b/simulationcraft.pri @@ -2,7 +2,8 @@ ORG_NAME = SimulationCraft APP_NAME = SimulationCraft INCLUDEPATH = ../engine -INCLUDEPATH += ../engine/util +INCLUDEPATH += ../engine/include +INCLUDEPATH += ../engine/lib DEPENDPATH = ../engine VPATH = .. CONFIG += c++14 diff --git a/source_files/QT_engine.pri b/source_files/QT_engine.pri index f70cd34832f..ccbd919f389 100644 --- a/source_files/QT_engine.pri +++ b/source_files/QT_engine.pri @@ -1,211 +1,216 @@ -# This is an input file for synchronize.py -# To change the list of source files for the simc engine lib, update this file and run synchronize.py +# This file is automatically generated by synchronize.py +# To change the list of source files run synchronize.py +HEADERS += engine/config.hpp +HEADERS += engine/sc_enums.hpp +HEADERS += engine/sc_timespan.hpp +HEADERS += engine/sc_util.hpp +HEADERS += engine/simulationcraft.hpp +HEADERS += engine/action/attack.hpp +HEADERS += engine/action/heal.hpp +HEADERS += engine/action/sc_action.hpp +HEADERS += engine/action/sc_action_state.hpp +HEADERS += engine/action/spell.hpp +HEADERS += engine/action/spell_base.hpp +HEADERS += engine/buff/sc_buff.hpp +HEADERS += engine/class_modules/class_module.hpp +HEADERS += engine/class_modules/paladin/sc_paladin.hpp +HEADERS += engine/class_modules/priest/sc_priest.hpp +HEADERS += engine/class_modules/warlock/sc_warlock.hpp +HEADERS += engine/class_modules/warlock/sc_warlock_pets.hpp +HEADERS += engine/dbc/azerite.hpp +HEADERS += engine/dbc/client_data.hpp +HEADERS += engine/dbc/dbc.hpp +HEADERS += engine/dbc/gem_data.hpp +HEADERS += engine/dbc/item_armor.hpp +HEADERS += engine/dbc/item_database.hpp +HEADERS += engine/dbc/item_effect.hpp +HEADERS += engine/dbc/item_weapon.hpp +HEADERS += engine/dbc/rand_prop_points.hpp +HEADERS += engine/dbc/sc_spell_info.hpp +HEADERS += engine/dbc/specialization.hpp +HEADERS += engine/dbc/spell_item_enchantment.hpp +HEADERS += engine/dbc/spell_query/spell_data_expr.hpp +HEADERS += engine/interfaces/sc_http.hpp +HEADERS += engine/interfaces/sc_http_curl.hpp +HEADERS += engine/interfaces/sc_http_wininet.hpp +HEADERS += engine/interfaces/sc_js.hpp +HEADERS += engine/interfaces/wowhead.hpp +HEADERS += engine/item/enchants.hpp +HEADERS += engine/item/item.hpp +HEADERS += engine/item/special_effect.hpp +HEADERS += engine/lib/gsl-lite/gsl-lite.hpp +HEADERS += engine/lib/rapidxml/rapidxml.hpp +HEADERS += engine/lib/rapidxml/rapidxml_print.hpp +HEADERS += engine/player/actor.hpp +HEADERS += engine/player/actor_target_data.hpp +HEADERS += engine/player/artifact_data.hpp +HEADERS += engine/player/assessor.hpp +HEADERS += engine/player/azerite_data.hpp +HEADERS += engine/player/effect_callbacks.hpp +HEADERS += engine/player/expansion_effects.hpp +HEADERS += engine/player/gear_stats.hpp +HEADERS += engine/player/pet.hpp +HEADERS += engine/player/pet_spawner.hpp +HEADERS += engine/player/pet_spawner_impl.hpp +HEADERS += engine/player/player_collected_data.hpp +HEADERS += engine/player/player_processed_report_information.hpp +HEADERS += engine/player/player_resources.hpp +HEADERS += engine/player/player_scaling.hpp +HEADERS += engine/player/player_stat_cache.hpp +HEADERS += engine/player/player_talent_points.hpp +HEADERS += engine/player/rating.hpp +HEADERS += engine/player/scaling_metric_data.hpp +HEADERS += engine/player/sc_actor_pair.hpp +HEADERS += engine/player/sc_player.hpp +HEADERS += engine/player/stats.hpp +HEADERS += engine/player/target_specific.hpp +HEADERS += engine/player/unique_gear.hpp +HEADERS += engine/player/weapon.hpp +HEADERS += engine/report/sc_highchart.hpp +HEADERS += engine/report/sc_report.hpp +HEADERS += engine/sim/artifact_power.hpp +HEADERS += engine/sim/event.hpp +HEADERS += engine/sim/event_manager.hpp +HEADERS += engine/sim/gain.hpp +HEADERS += engine/sim/iteration_data_entry.hpp +HEADERS += engine/sim/plot.hpp +HEADERS += engine/sim/progress_bar.hpp +HEADERS += engine/sim/raid_event.hpp +HEADERS += engine/sim/real_ppm.hpp +HEADERS += engine/sim/reforge_plot.hpp +HEADERS += engine/sim/scale_factor_control.hpp +HEADERS += engine/sim/sc_cooldown.hpp +HEADERS += engine/sim/sc_expressions.hpp +HEADERS += engine/sim/sc_option.hpp +HEADERS += engine/sim/sc_profileset.hpp +HEADERS += engine/sim/sc_sim.hpp +HEADERS += engine/sim/sim_control.hpp +HEADERS += engine/sim/sim_ostream.hpp +HEADERS += engine/sim/unique_gear.hpp +HEADERS += engine/sim/x6_pantheon.hpp +HEADERS += engine/util/array_view.hpp +HEADERS += engine/util/cache.hpp +HEADERS += engine/util/concurrency.hpp +HEADERS += engine/util/generic.hpp +HEADERS += engine/util/git_info.hpp +HEADERS += engine/util/io.hpp +HEADERS += engine/util/plot_data.hpp +HEADERS += engine/util/rng.hpp +HEADERS += engine/util/sample_data.hpp +HEADERS += engine/util/scoped_callback.hpp +HEADERS += engine/util/sc_resourcepaths.hpp +HEADERS += engine/util/sc_uptime.hpp +HEADERS += engine/util/stopwatch.hpp +HEADERS += engine/util/timeline.hpp +HEADERS += engine/util/vector_with_callback.hpp +HEADERS += engine/util/xml.hpp +HEADERS += engine/dbc/data_definitions.hh +HEADERS += engine/dbc/data_enums.hh - HEADERS += engine/action/attack.hpp - HEADERS += engine/action/heal.hpp - HEADERS += engine/action/sc_action_state.hpp - HEADERS += engine/action/sc_action.hpp - HEADERS += engine/action/spell_base.hpp - HEADERS += engine/action/spell.hpp - HEADERS += engine/buff/sc_buff.hpp - HEADERS += engine/class_modules/paladin/sc_paladin.hpp - HEADERS += engine/class_modules/warlock/sc_warlock.hpp - HEADERS += engine/class_modules/priest/sc_priest.hpp - HEADERS += engine/dbc/azerite.hpp - HEADERS += engine/dbc/data_enums.hh - HEADERS += engine/dbc/data_definitions.hh - HEADERS += engine/dbc/dbc.hpp - HEADERS += engine/dbc/item_database.hpp - HEADERS += engine/dbc/item_effect.hpp - HEADERS += engine/dbc/sc_spell_info.hpp - HEADERS += engine/dbc/specialization.hpp - HEADERS += engine/interfaces/sc_http_curl.hpp - HEADERS += engine/interfaces/sc_http_wininet.hpp - HEADERS += engine/interfaces/sc_http.hpp - HEADERS += engine/interfaces/sc_js.hpp - HEADERS += engine/interfaces/wowhead.hpp - HEADERS += engine/item/enchants.hpp - HEADERS += engine/item/item.hpp - HEADERS += engine/item/special_effect.hpp - HEADERS += engine/player/actor.hpp - HEADERS += engine/player/artifact_data.hpp - HEADERS += engine/player/assessor.hpp - HEADERS += engine/player/azerite_data.hpp - HEADERS += engine/player/effect_callbacks.hpp - HEADERS += engine/player/expansion_effects.hpp - HEADERS += engine/player/gear_stats.hpp - HEADERS += engine/player/pet_spawner.hpp - HEADERS += engine/player/pet_spawner_impl.hpp - HEADERS += engine/player/player_collected_data.hpp - HEADERS += engine/player/player_processed_report_information.hpp - HEADERS += engine/player/player_resources.hpp - HEADERS += engine/player/player_scaling.hpp - HEADERS += engine/player/player_stat_cache.hpp - HEADERS += engine/player/player_talent_points.hpp - HEADERS += engine/player/rating.hpp - HEADERS += engine/player/sc_actor_pair.hpp - HEADERS += engine/player/sc_player.hpp - HEADERS += engine/player/scaling_metric_data.hpp - HEADERS += engine/player/stats.hpp - HEADERS += engine/player/target_specific.hpp - HEADERS += engine/player/unique_gear.hpp - HEADERS += engine/player/weapon.hpp - HEADERS += engine/report/sc_highchart.hpp - HEADERS += engine/report/sc_report.hpp - HEADERS += engine/sim/artifact_power.hpp - HEADERS += engine/sim/event_manager.hpp - HEADERS += engine/sim/event.hpp - HEADERS += engine/sim/gain.hpp - HEADERS += engine/sim/plot.hpp - HEADERS += engine/sim/progress_bar.hpp - HEADERS += engine/sim/real_ppm.hpp - HEADERS += engine/sim/reforge_plot.hpp - HEADERS += engine/sim/sc_cooldown.hpp - HEADERS += engine/sim/sc_expressions.hpp - HEADERS += engine/sim/sc_option.hpp - HEADERS += engine/sim/sc_profileset.hpp - HEADERS += engine/sim/sc_sim.hpp - HEADERS += engine/sim/scale_factor_control.hpp - HEADERS += engine/sim/sim_control.hpp - HEADERS += engine/sim/sim_ostream.hpp - HEADERS += engine/sim/unique_gear.hpp - HEADERS += engine/sim/x6_pantheon.hpp - HEADERS += engine/util/plot_data.hpp - HEADERS += engine/util/xml.hpp - HEADERS += engine/util/timeline.hpp - HEADERS += engine/util/stopwatch.hpp - HEADERS += engine/util/sc_resourcepaths.hpp - HEADERS += engine/util/sample_data.hpp - HEADERS += engine/util/rng.hpp - HEADERS += engine/util/io.hpp - HEADERS += engine/util/generic.hpp - HEADERS += engine/util/concurrency.hpp - HEADERS += engine/util/cache.hpp - HEADERS += engine/util/utf8-cpp/utf8/unchecked.h - HEADERS += engine/util/utf8-cpp/utf8/core.h - HEADERS += engine/util/utf8-cpp/utf8/checked.h - HEADERS += engine/util/utf8-cpp/utf8.h - HEADERS += engine/util/utf8-h/utf8.h - HEADERS += engine/util/fmt/chrono.h - HEADERS += engine/util/fmt/color.h - HEADERS += engine/util/fmt/compile.h - HEADERS += engine/util/fmt/core.h - HEADERS += engine/util/fmt/format.h - HEADERS += engine/util/fmt/format-inl.h - HEADERS += engine/util/fmt/locale.h - HEADERS += engine/util/fmt/os.h - HEADERS += engine/util/fmt/ostream.h - HEADERS += engine/util/fmt/posix.h - HEADERS += engine/util/fmt/printf.h - HEADERS += engine/util/fmt/ranges.h - PRECOMPILED_HEADER += engine/simulationcraft.hpp - HEADERS += engine/simulationcraft.hpp - HEADERS += engine/sc_util.hpp - HEADERS += engine/sc_timespan.hpp - HEADERS += engine/sc_enums.hpp - HEADERS += engine/config.hpp - SOURCES += engine/util/xml.cpp - SOURCES += engine/util/stopwatch.cpp - SOURCES += engine/util/rng.cpp - SOURCES += engine/util/io.cpp - SOURCES += engine/util/concurrency.cpp - SOURCES += engine/util/git_info.cpp - SOURCES += engine/util/fmt/format.cpp - SOURCES += engine/util/fmt/os.cpp - SOURCES += engine/sim/artifact_power.cpp - SOURCES += engine/sim/event_manager.cpp - SOURCES += engine/sim/x6_pantheon.cpp - SOURCES += engine/sim/real_ppm.cpp - SOURCES += engine/sim/spawner.cpp - SOURCES += engine/sim/sc_sim.cpp - SOURCES += engine/sim/scale_factor_control.cpp - SOURCES += engine/sim/sc_reforge_plot.cpp - SOURCES += engine/sim/sc_raid_event.cpp - SOURCES += engine/sim/sc_progress_bar.cpp - SOURCES += engine/sim/sc_profileset.cpp - SOURCES += engine/sim/sc_plot.cpp - SOURCES += engine/sim/sc_option.cpp - SOURCES += engine/sim/sc_gear_stats.cpp - SOURCES += engine/sim/sc_expressions.cpp - SOURCES += engine/sim/sc_event.cpp - SOURCES += engine/sim/sc_cooldown.cpp - SOURCES += engine/report/sc_report_text.cpp - SOURCES += engine/report/sc_report_json.cpp - SOURCES += engine/report/sc_report_html_sim.cpp - SOURCES += engine/report/sc_report_html_player.cpp - SOURCES += engine/report/sc_report.cpp - SOURCES += engine/report/sc_highchart.cpp - SOURCES += engine/report/sc_gear_weights.cpp - SOURCES += engine/report/sc_color.cpp - SOURCES += engine/report/sc_chart.cpp - SOURCES += engine/player/actor_target_data.cpp - SOURCES += engine/player/actor.cpp - SOURCES += engine/player/player_talent_points.cpp - SOURCES += engine/player/sc_unique_gear_x6.cpp - SOURCES += engine/player/sc_unique_gear_x7.cpp - SOURCES += engine/player/sc_unique_gear.cpp - SOURCES += engine/player/player_stat_cache.cpp - SOURCES += engine/player/sc_set_bonus.cpp - SOURCES += engine/player/sc_proc.cpp - SOURCES += engine/player/sc_player.cpp - SOURCES += engine/player/sc_pet.cpp - SOURCES += engine/player/sc_consumable.cpp - SOURCES += engine/player/artifact_data.cpp - SOURCES += engine/player/azerite_data.cpp - SOURCES += engine/interfaces/wowhead.cpp - SOURCES += engine/interfaces/sc_js.cpp - SOURCES += engine/interfaces/sc_http.cpp - SOURCES += engine/interfaces/sc_http_curl.cpp - SOURCES += engine/interfaces/sc_http_wininet.cpp - SOURCES += engine/interfaces/sc_bcp_api.cpp - SOURCES += engine/item/enchants.cpp - SOURCES += engine/item/item.cpp - SOURCES += engine/item/special_effect.cpp - SOURCES += engine/dbc/sc_spell_info.cpp - SOURCES += engine/dbc/sc_spell_data.cpp - SOURCES += engine/dbc/sc_item_data_import_ptr.cpp - SOURCES += engine/dbc/sc_item_data_import_noptr.cpp - SOURCES += engine/dbc/sc_item_data.cpp - SOURCES += engine/dbc/sc_data.cpp - SOURCES += engine/dbc/sc_const_data.cpp - SOURCES += engine/dbc/item_effect.cpp - SOURCES += engine/class_modules/sc_warrior.cpp - SOURCES += engine/class_modules/warlock/sc_warlock.cpp - SOURCES += engine/class_modules/warlock/sc_warlock_affliction.cpp - SOURCES += engine/class_modules/warlock/sc_warlock_demonology.cpp - SOURCES += engine/class_modules/warlock/sc_warlock_destruction.cpp - SOURCES += engine/class_modules/warlock/sc_warlock_pets.cpp - SOURCES += engine/class_modules/sc_shaman.cpp - SOURCES += engine/class_modules/sc_rogue.cpp - SOURCES += engine/class_modules/priest/sc_priest.cpp - SOURCES += engine/class_modules/priest/sc_priest_discipline.cpp - SOURCES += engine/class_modules/priest/sc_priest_holy.cpp - SOURCES += engine/class_modules/priest/sc_priest_shadow.cpp - SOURCES += engine/class_modules/paladin/sc_paladin.cpp - SOURCES += engine/class_modules/paladin/sc_paladin_retribution.cpp - SOURCES += engine/class_modules/paladin/sc_paladin_protection.cpp - SOURCES += engine/class_modules/paladin/sc_paladin_holy.cpp - SOURCES += engine/class_modules/sc_monk.cpp - SOURCES += engine/class_modules/sc_mage.cpp - SOURCES += engine/class_modules/sc_hunter.cpp - SOURCES += engine/class_modules/sc_enemy.cpp - SOURCES += engine/class_modules/sc_druid.cpp - SOURCES += engine/class_modules/sc_demon_hunter.cpp - SOURCES += engine/class_modules/sc_death_knight.cpp - SOURCES += engine/buff/sc_buff.cpp - SOURCES += engine/action/sc_stats.cpp - SOURCES += engine/action/sc_spell.cpp - SOURCES += engine/action/sc_sequence.cpp - SOURCES += engine/action/sc_dot.cpp - SOURCES += engine/action/sc_distance_targeting.cpp - SOURCES += engine/action/sc_attack.cpp - SOURCES += engine/action/sc_action_state.cpp - SOURCES += engine/action/sc_action.cpp - SOURCES += engine/sc_util.cpp - SOURCES += engine/dbc/azerite.cpp - SOURCES += engine/dbc/rand_prop_points.cpp - SOURCES += engine/dbc/spell_item_enchantment.cpp - SOURCES += engine/dbc/item_armor.cpp - SOURCES += engine/dbc/item_weapon.cpp - SOURCES += engine/dbc/gem_data.cpp +SOURCES += engine/sc_util.cpp +SOURCES += engine/action/sc_action.cpp +SOURCES += engine/action/sc_action_state.cpp +SOURCES += engine/action/sc_attack.cpp +SOURCES += engine/action/sc_distance_targeting.cpp +SOURCES += engine/action/sc_dot.cpp +SOURCES += engine/action/sc_sequence.cpp +SOURCES += engine/action/sc_spell.cpp +SOURCES += engine/action/sc_stats.cpp +SOURCES += engine/buff/sc_buff.cpp +SOURCES += engine/class_modules/sc_death_knight.cpp +SOURCES += engine/class_modules/sc_demon_hunter.cpp +SOURCES += engine/class_modules/sc_druid.cpp +SOURCES += engine/class_modules/sc_enemy.cpp +SOURCES += engine/class_modules/sc_hunter.cpp +SOURCES += engine/class_modules/sc_mage.cpp +SOURCES += engine/class_modules/sc_monk.cpp +SOURCES += engine/class_modules/sc_rogue.cpp +SOURCES += engine/class_modules/sc_shaman.cpp +SOURCES += engine/class_modules/sc_warrior.cpp +SOURCES += engine/class_modules/paladin/sc_paladin.cpp +SOURCES += engine/class_modules/paladin/sc_paladin_holy.cpp +SOURCES += engine/class_modules/paladin/sc_paladin_protection.cpp +SOURCES += engine/class_modules/paladin/sc_paladin_retribution.cpp +SOURCES += engine/class_modules/priest/sc_priest.cpp +SOURCES += engine/class_modules/priest/sc_priest_discipline.cpp +SOURCES += engine/class_modules/priest/sc_priest_holy.cpp +SOURCES += engine/class_modules/priest/sc_priest_shadow.cpp +SOURCES += engine/class_modules/warlock/sc_warlock.cpp +SOURCES += engine/class_modules/warlock/sc_warlock_affliction.cpp +SOURCES += engine/class_modules/warlock/sc_warlock_demonology.cpp +SOURCES += engine/class_modules/warlock/sc_warlock_destruction.cpp +SOURCES += engine/class_modules/warlock/sc_warlock_pets.cpp +SOURCES += engine/dbc/azerite.cpp +SOURCES += engine/dbc/gem_data.cpp +SOURCES += engine/dbc/item_armor.cpp +SOURCES += engine/dbc/item_effect.cpp +SOURCES += engine/dbc/item_weapon.cpp +SOURCES += engine/dbc/rand_prop_points.cpp +SOURCES += engine/dbc/sc_const_data.cpp +SOURCES += engine/dbc/sc_data.cpp +SOURCES += engine/dbc/sc_item_data.cpp +SOURCES += engine/dbc/sc_item_data_import_noptr.cpp +SOURCES += engine/dbc/sc_item_data_import_ptr.cpp +SOURCES += engine/dbc/sc_spell_data.cpp +SOURCES += engine/dbc/sc_spell_info.cpp +SOURCES += engine/dbc/spell_item_enchantment.cpp +SOURCES += engine/interfaces/sc_bcp_api.cpp +SOURCES += engine/interfaces/sc_http.cpp +SOURCES += engine/interfaces/sc_http_curl.cpp +SOURCES += engine/interfaces/sc_http_wininet.cpp +SOURCES += engine/interfaces/sc_js.cpp +SOURCES += engine/interfaces/wowhead.cpp +SOURCES += engine/item/enchants.cpp +SOURCES += engine/item/item.cpp +SOURCES += engine/item/special_effect.cpp +SOURCES += engine/lib/fmt/format.cpp +SOURCES += engine/lib/fmt/os.cpp +SOURCES += engine/player/actor.cpp +SOURCES += engine/player/actor_target_data.cpp +SOURCES += engine/player/artifact_data.cpp +SOURCES += engine/player/azerite_data.cpp +SOURCES += engine/player/player_stat_cache.cpp +SOURCES += engine/player/player_talent_points.cpp +SOURCES += engine/player/sc_consumable.cpp +SOURCES += engine/player/sc_pet.cpp +SOURCES += engine/player/sc_player.cpp +SOURCES += engine/player/sc_proc.cpp +SOURCES += engine/player/sc_set_bonus.cpp +SOURCES += engine/player/sc_unique_gear.cpp +SOURCES += engine/player/sc_unique_gear_x6.cpp +SOURCES += engine/player/sc_unique_gear_x7.cpp +SOURCES += engine/report/sc_chart.cpp +SOURCES += engine/report/sc_color.cpp +SOURCES += engine/report/sc_gear_weights.cpp +SOURCES += engine/report/sc_highchart.cpp +SOURCES += engine/report/sc_report.cpp +SOURCES += engine/report/sc_report_html_player.cpp +SOURCES += engine/report/sc_report_html_sim.cpp +SOURCES += engine/report/sc_report_json.cpp +SOURCES += engine/report/sc_report_text.cpp +SOURCES += engine/sim/artifact_power.cpp +SOURCES += engine/sim/event_manager.cpp +SOURCES += engine/sim/real_ppm.cpp +SOURCES += engine/sim/scale_factor_control.cpp +SOURCES += engine/sim/sc_cooldown.cpp +SOURCES += engine/sim/sc_event.cpp +SOURCES += engine/sim/sc_expressions.cpp +SOURCES += engine/sim/sc_gear_stats.cpp +SOURCES += engine/sim/sc_option.cpp +SOURCES += engine/sim/sc_plot.cpp +SOURCES += engine/sim/sc_profileset.cpp +SOURCES += engine/sim/sc_progress_bar.cpp +SOURCES += engine/sim/sc_raid_event.cpp +SOURCES += engine/sim/sc_reforge_plot.cpp +SOURCES += engine/sim/sc_sim.cpp +SOURCES += engine/sim/spawner.cpp +SOURCES += engine/sim/x6_pantheon.cpp +SOURCES += engine/util/concurrency.cpp +SOURCES += engine/util/git_info.cpp +SOURCES += engine/util/io.cpp +SOURCES += engine/util/rng.cpp +SOURCES += engine/util/sample_data.cpp +SOURCES += engine/util/stopwatch.cpp +SOURCES += engine/util/timeline.cpp +SOURCES += engine/util/xml.cpp \ No newline at end of file diff --git a/source_files/QT_gui.pri b/source_files/QT_gui.pri index ef0b064507d..232b1ed908a 100644 --- a/source_files/QT_gui.pri +++ b/source_files/QT_gui.pri @@ -1,44 +1,44 @@ -# This is an input file for synchronize.py -# To change the list of source files for the gui app, update this file and run synchronize.py +# This file is automatically generated by synchronize.py +# To change the list of source files run synchronize.py +HEADERS += qt/sc_AddonImportTab.hpp +HEADERS += qt/sc_importWidget.hpp +HEADERS += qt/sc_importWindow.hpp +HEADERS += qt/sc_OptionsTab.hpp +HEADERS += qt/sc_SampleProfilesTab.hpp +HEADERS += qt/sc_SimulateTab.hpp +HEADERS += qt/sc_SimulationThread.hpp +HEADERS += qt/sc_SpellQueryTab.hpp +HEADERS += qt/sc_UpdateCheck.hpp +HEADERS += qt/sc_WelcomeTab.hpp +HEADERS += qt/sc_Workaround.hpp +HEADERS += qt/simulationcraftqt.hpp +HEADERS += qt/util/sc_hoverarea.hpp +HEADERS += qt/util/sc_mainwindowcommandline.hpp +HEADERS += qt/util/sc_recentlyclosed.hpp +HEADERS += qt/util/sc_relativepopup.hpp +HEADERS += qt/util/sc_searchbox.hpp +HEADERS += qt/util/sc_tabbar.hpp +HEADERS += qt/util/sc_textedit.hpp - HEADERS += qt/util/sc_textedit.hpp - HEADERS += qt/util/sc_tabbar.hpp - HEADERS += qt/util/sc_searchbox.hpp - HEADERS += qt/util/sc_relativepopup.hpp - HEADERS += qt/util/sc_recentlyclosed.hpp - HEADERS += qt/util/sc_mainwindowcommandline.hpp - HEADERS += qt/util/sc_hoverarea.hpp - HEADERS += qt/simulationcraftqt.hpp - HEADERS += qt/sc_importWindow.hpp - HEADERS += qt/sc_importWidget.hpp - HEADERS += qt/sc_Workaround.hpp - HEADERS += qt/sc_WelcomeTab.hpp - HEADERS += qt/sc_SpellQueryTab.hpp - HEADERS += qt/sc_SimulationThread.hpp - HEADERS += qt/sc_SimulateTab.hpp - HEADERS += qt/sc_SampleProfilesTab.hpp - HEADERS += qt/sc_OptionsTab.hpp - HEADERS += qt/sc_UpdateCheck.hpp - HEADERS += qt/sc_AddonImportTab.hpp - SOURCES += qt/util/sc_textedit.cpp - SOURCES += qt/util/sc_tabbar.cpp - SOURCES += qt/util/sc_searchbox.cpp - SOURCES += qt/util/sc_relativepopup.cpp - SOURCES += qt/util/sc_recentlyclosed.cpp - SOURCES += qt/util/sc_mainwindowcommandline.cpp - SOURCES += qt/sc_window.cpp - SOURCES += qt/sc_importWindow.cpp - SOURCES += qt/sc_importWidget.cpp - SOURCES += qt/sc_Workaround.cpp - SOURCES += qt/sc_WelcomeTab.cpp - SOURCES += qt/sc_SpellQueryTab.cpp - SOURCES += qt/sc_SimulationThread.cpp - SOURCES += qt/sc_SimulateTab.cpp - SOURCES += qt/sc_SampleProfilesTab.cpp - SOURCES += qt/sc_OptionsTab.cpp - SOURCES += qt/sc_UpdateCheck.cpp - SOURCES += qt/sc_ImportThread.cpp - SOURCES += qt/sc_ImportTab.cpp - SOURCES += qt/sc_AddonImportTab.cpp - SOURCES += qt/main.cpp +SOURCES += qt/main.cpp +SOURCES += qt/sc_AddonImportTab.cpp +SOURCES += qt/sc_ImportTab.cpp +SOURCES += qt/sc_ImportThread.cpp +SOURCES += qt/sc_importWidget.cpp +SOURCES += qt/sc_importWindow.cpp +SOURCES += qt/sc_OptionsTab.cpp +SOURCES += qt/sc_SampleProfilesTab.cpp +SOURCES += qt/sc_SimulateTab.cpp +SOURCES += qt/sc_SimulationThread.cpp +SOURCES += qt/sc_SpellQueryTab.cpp +SOURCES += qt/sc_UpdateCheck.cpp +SOURCES += qt/sc_WelcomeTab.cpp +SOURCES += qt/sc_window.cpp +SOURCES += qt/sc_Workaround.cpp +SOURCES += qt/util/sc_mainwindowcommandline.cpp +SOURCES += qt/util/sc_recentlyclosed.cpp +SOURCES += qt/util/sc_relativepopup.cpp +SOURCES += qt/util/sc_searchbox.cpp +SOURCES += qt/util/sc_tabbar.cpp +SOURCES += qt/util/sc_textedit.cpp \ No newline at end of file diff --git a/source_files/VS_engine.props b/source_files/VS_engine.props index d09869c55e1..370e04e76ff 100644 --- a/source_files/VS_engine.props +++ b/source_files/VS_engine.props @@ -1,43 +1,60 @@ + + + + + - - + + + - + + - - + + + + + + + + - + + + + + @@ -47,9 +64,9 @@ To change the list of source files, update the QT_ files and run synchronize.py + - @@ -57,204 +74,185 @@ To change the list of source files, update the QT_ files and run synchronize.py - + + + + - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NotUsing + + + + + + + + + + + + - - NotUsing + + - - NotUsing + + - - NotUsing + + - - NotUsing + + - - NotUsing + + - - NotUsing + + - - NotUsing + + - - NotUsing + + - + NotUsing - + - - NotUsing - - + - + - - NotUsing + + - - NotUsing + + - + - + - - NotUsing + + - - NotUsing + + - - NotUsing + + - - NotUsing + + - + - - NotUsing + + - - NotUsing + + - + - + - + - + - + - + - + - - NotUsing + + - + - + NotUsing - + NotUsing - + NotUsing - - - - - + + NotUsing - - + + NotUsing - + NotUsing - - + + NotUsing - - + + NotUsing - + - - + + NotUsing - - + + NotUsing - + NotUsing - + NotUsing - - + + NotUsing - + @@ -266,7 +264,10 @@ To change the list of source files, update the QT_ files and run synchronize.py - + + + + @@ -278,145 +279,154 @@ To change the list of source files, update the QT_ files and run synchronize.py - + NotUsing - + NotUsing - + NotUsing - + NotUsing - - + + NotUsing - + NotUsing - + NotUsing - + NotUsing - + - + - + - + - + - + - + - + - + - - + + NotUsing - + - + - + - + - + - + - + - - + + NotUsing - - + + NotUsing - - + + NotUsing - - + + NotUsing - - + + NotUsing - + + NotUsing + + - + NotUsing - - + + NotUsing - - + + NotUsing - - + + NotUsing - + - + - - + + NotUsing - + - + - + - + NotUsing - + NotUsing - + NotUsing - + NotUsing - + NotUsing - + + NotUsing + + + NotUsing + + NotUsing diff --git a/source_files/VS_engine_main.props b/source_files/VS_engine_main.props index b50a0fb7b3e..0e1f18a55c7 100644 --- a/source_files/VS_engine_main.props +++ b/source_files/VS_engine_main.props @@ -1,6 +1,6 @@ diff --git a/source_files/VS_gui.props b/source_files/VS_gui.props index 667a800d650..1d3a4d4cea5 100644 --- a/source_files/VS_gui.props +++ b/source_files/VS_gui.props @@ -1,129 +1,129 @@ - + NotUsing - + NotUsing - + NotUsing - + NotUsing - + NotUsing - + NotUsing - + NotUsing - + NotUsing - + NotUsing - + NotUsing NotUsing - + NotUsing - + NotUsing - + NotUsing - + NotUsing - + NotUsing - + NotUsing - + NotUsing - + NotUsing - - NotUsing + + - + NotUsing - + NotUsing - - NotUsing + + - + NotUsing - + NotUsing - + - + NotUsing - + NotUsing - + NotUsing + + + + + + NotUsing - + - + NotUsing - + NotUsing - + NotUsing - - - - - - - - + + NotUsing - + NotUsing - + NotUsing - - + + NotUsing @@ -154,74 +154,74 @@ To change the list of source files, update the QT_ files and run synchronize.py - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\util\sc_textedit.hpp;%(AdditionalInputs) + Rem;..\qt\sc_AddonImportTab.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\util\sc_tabbar.hpp;%(AdditionalInputs) + Rem;..\qt\sc_importWidget.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\util\sc_searchbox.hpp;%(AdditionalInputs) + Rem;..\qt\sc_importWindow.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\util\sc_relativepopup.hpp;%(AdditionalInputs) + Rem;..\qt\sc_OptionsTab.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\util\sc_recentlyclosed.hpp;%(AdditionalInputs) + Rem;..\qt\sc_SampleProfilesTab.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\util\sc_mainwindowcommandline.hpp;%(AdditionalInputs) + Rem;..\qt\sc_SimulateTab.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\util\sc_hoverarea.hpp;%(AdditionalInputs) + Rem;..\qt\sc_SimulationThread.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\simulationcraftqt.hpp;%(AdditionalInputs) + Rem;..\qt\sc_SpellQueryTab.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\sc_importWindow.hpp;%(AdditionalInputs) + Rem;..\qt\sc_UpdateCheck.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\sc_importWidget.hpp;%(AdditionalInputs) + Rem;..\qt\sc_WelcomeTab.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp @@ -231,60 +231,60 @@ To change the list of source files, update the QT_ files and run synchronize.py Rem;..\qt\sc_Workaround.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\sc_WelcomeTab.hpp;%(AdditionalInputs) + Rem;..\qt\simulationcraftqt.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\sc_SpellQueryTab.hpp;%(AdditionalInputs) + Rem;..\qt\util\sc_hoverarea.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\sc_SimulationThread.hpp;%(AdditionalInputs) + Rem;..\qt\util\sc_mainwindowcommandline.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\sc_SimulateTab.hpp;%(AdditionalInputs) + Rem;..\qt\util\sc_recentlyclosed.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\sc_SampleProfilesTab.hpp;%(AdditionalInputs) + Rem;..\qt\util\sc_relativepopup.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\sc_OptionsTab.hpp;%(AdditionalInputs) + Rem;..\qt\util\sc_searchbox.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\sc_UpdateCheck.hpp;%(AdditionalInputs) + Rem;..\qt\util\sc_tabbar.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp - + $(QTDIR)\bin\moc.exe Moc%27ing %(Identity)... ( with $(QTDIR)\bin\moc.exe ) "$(QTDIR)\bin\moc.exe" $(MOC_DEFINES) -I"$(QTDIR)\include" -I"(SolutionDir)engine" -I"$(QTDIR)\mkspecs\default" "%(Identity)" -o "$(IntDir)moc_%(Filename).cpp" - Rem;..\qt\sc_AddonImportTab.hpp;%(AdditionalInputs) + Rem;..\qt\util\sc_textedit.hpp;%(AdditionalInputs) $(IntDir)\moc_%(Filename).cpp diff --git a/source_files/cmake_engine.txt b/source_files/cmake_engine.txt index 0a9edef2aee..a2a6b8e5e32 100644 --- a/source_files/cmake_engine.txt +++ b/source_files/cmake_engine.txt @@ -1,37 +1,54 @@ set(source_files +config.hpp +sc_enums.hpp +sc_timespan.hpp +sc_util.hpp +simulationcraft.hpp action/attack.hpp action/heal.hpp -action/sc_action_state.hpp action/sc_action.hpp -action/spell_base.hpp +action/sc_action_state.hpp action/spell.hpp +action/spell_base.hpp buff/sc_buff.hpp +class_modules/class_module.hpp class_modules/paladin/sc_paladin.hpp -class_modules/warlock/sc_warlock.hpp class_modules/priest/sc_priest.hpp +class_modules/warlock/sc_warlock.hpp +class_modules/warlock/sc_warlock_pets.hpp dbc/azerite.hpp -dbc/data_enums.hh -dbc/data_definitions.hh +dbc/client_data.hpp dbc/dbc.hpp +dbc/gem_data.hpp +dbc/item_armor.hpp dbc/item_database.hpp dbc/item_effect.hpp +dbc/item_weapon.hpp +dbc/rand_prop_points.hpp dbc/sc_spell_info.hpp dbc/specialization.hpp +dbc/spell_item_enchantment.hpp +dbc/spell_query/spell_data_expr.hpp +interfaces/sc_http.hpp interfaces/sc_http_curl.hpp interfaces/sc_http_wininet.hpp -interfaces/sc_http.hpp interfaces/sc_js.hpp interfaces/wowhead.hpp item/enchants.hpp item/item.hpp item/special_effect.hpp +lib/gsl-lite/gsl-lite.hpp +lib/rapidxml/rapidxml.hpp +lib/rapidxml/rapidxml_print.hpp player/actor.hpp +player/actor_target_data.hpp player/artifact_data.hpp player/assessor.hpp player/azerite_data.hpp player/effect_callbacks.hpp player/expansion_effects.hpp player/gear_stats.hpp +player/pet.hpp player/pet_spawner.hpp player/pet_spawner_impl.hpp player/player_collected_data.hpp @@ -41,9 +58,9 @@ player/player_scaling.hpp player/player_stat_cache.hpp player/player_talent_points.hpp player/rating.hpp +player/scaling_metric_data.hpp player/sc_actor_pair.hpp player/sc_player.hpp -player/scaling_metric_data.hpp player/stats.hpp player/target_specific.hpp player/unique_gear.hpp @@ -51,163 +68,147 @@ player/weapon.hpp report/sc_highchart.hpp report/sc_report.hpp sim/artifact_power.hpp -sim/event_manager.hpp sim/event.hpp +sim/event_manager.hpp sim/gain.hpp +sim/iteration_data_entry.hpp sim/plot.hpp sim/progress_bar.hpp +sim/raid_event.hpp sim/real_ppm.hpp sim/reforge_plot.hpp +sim/scale_factor_control.hpp sim/sc_cooldown.hpp sim/sc_expressions.hpp sim/sc_option.hpp sim/sc_profileset.hpp sim/sc_sim.hpp -sim/scale_factor_control.hpp sim/sim_control.hpp sim/sim_ostream.hpp sim/unique_gear.hpp sim/x6_pantheon.hpp +util/array_view.hpp +util/cache.hpp +util/concurrency.hpp +util/generic.hpp +util/git_info.hpp +util/io.hpp util/plot_data.hpp -util/xml.hpp -util/timeline.hpp -util/stopwatch.hpp -util/sc_resourcepaths.hpp -util/sample_data.hpp util/rng.hpp -util/io.hpp -util/generic.hpp -util/concurrency.hpp -util/cache.hpp -util/utf8-cpp/utf8/unchecked.h -util/utf8-cpp/utf8/core.h -util/utf8-cpp/utf8/checked.h -util/utf8-cpp/utf8.h -util/utf8-h/utf8.h -util/fmt/chrono.h -util/fmt/color.h -util/fmt/compile.h -util/fmt/core.h -util/fmt/format.h -util/fmt/format-inl.h -util/fmt/locale.h -util/fmt/os.h -util/fmt/ostream.h -util/fmt/posix.h -util/fmt/printf.h -util/fmt/ranges.h -simulationcraft.hpp -sc_util.hpp -sc_timespan.hpp -sc_enums.hpp -config.hpp -dbc/data_enums.hh +util/sample_data.hpp +util/scoped_callback.hpp +util/sc_resourcepaths.hpp +util/sc_uptime.hpp +util/stopwatch.hpp +util/timeline.hpp +util/vector_with_callback.hpp +util/xml.hpp dbc/data_definitions.hh -class_modules/paladin/sc_paladin.hpp -class_modules/warlock/sc_warlock.hpp -class_modules/priest/sc_priest.hpp -util/xml.cpp -util/stopwatch.cpp -util/rng.cpp -util/io.cpp -util/concurrency.cpp -util/git_info.cpp -util/fmt/format.cpp -util/fmt/os.cpp -sim/artifact_power.cpp -sim/event_manager.cpp -sim/x6_pantheon.cpp -sim/real_ppm.cpp -sim/spawner.cpp -sim/sc_sim.cpp -sim/scale_factor_control.cpp -sim/sc_reforge_plot.cpp -sim/sc_raid_event.cpp -sim/sc_progress_bar.cpp -sim/sc_profileset.cpp -sim/sc_plot.cpp -sim/sc_option.cpp -sim/sc_gear_stats.cpp -sim/sc_expressions.cpp -sim/sc_event.cpp -sim/sc_cooldown.cpp -report/sc_report_text.cpp -report/sc_report_json.cpp -report/sc_report_html_sim.cpp -report/sc_report_html_player.cpp -report/sc_report.cpp -report/sc_highchart.cpp -report/sc_gear_weights.cpp -report/sc_color.cpp -report/sc_chart.cpp -player/actor_target_data.cpp -player/actor.cpp -player/player_talent_points.cpp -player/sc_unique_gear_x6.cpp -player/sc_unique_gear_x7.cpp -player/sc_unique_gear.cpp -player/player_stat_cache.cpp -player/sc_set_bonus.cpp -player/sc_proc.cpp -player/sc_player.cpp -player/sc_pet.cpp -player/sc_consumable.cpp -player/artifact_data.cpp -player/azerite_data.cpp -interfaces/wowhead.cpp -interfaces/sc_js.cpp -interfaces/sc_http.cpp -interfaces/sc_http_curl.cpp -interfaces/sc_http_wininet.cpp -interfaces/sc_bcp_api.cpp -item/enchants.cpp -item/item.cpp -item/special_effect.cpp -dbc/sc_spell_info.cpp -dbc/sc_spell_data.cpp -dbc/sc_item_data_import_ptr.cpp -dbc/sc_item_data_import_noptr.cpp -dbc/sc_item_data.cpp -dbc/sc_data.cpp -dbc/sc_const_data.cpp -dbc/item_effect.cpp +dbc/data_enums.hh +sc_util.cpp +action/sc_action.cpp +action/sc_action_state.cpp +action/sc_attack.cpp +action/sc_distance_targeting.cpp +action/sc_dot.cpp +action/sc_sequence.cpp +action/sc_spell.cpp +action/sc_stats.cpp +buff/sc_buff.cpp +class_modules/sc_death_knight.cpp +class_modules/sc_demon_hunter.cpp +class_modules/sc_druid.cpp +class_modules/sc_enemy.cpp +class_modules/sc_hunter.cpp +class_modules/sc_mage.cpp +class_modules/sc_monk.cpp +class_modules/sc_rogue.cpp +class_modules/sc_shaman.cpp class_modules/sc_warrior.cpp +class_modules/paladin/sc_paladin.cpp +class_modules/paladin/sc_paladin_holy.cpp +class_modules/paladin/sc_paladin_protection.cpp +class_modules/paladin/sc_paladin_retribution.cpp +class_modules/priest/sc_priest.cpp +class_modules/priest/sc_priest_discipline.cpp +class_modules/priest/sc_priest_holy.cpp +class_modules/priest/sc_priest_shadow.cpp class_modules/warlock/sc_warlock.cpp class_modules/warlock/sc_warlock_affliction.cpp class_modules/warlock/sc_warlock_demonology.cpp class_modules/warlock/sc_warlock_destruction.cpp class_modules/warlock/sc_warlock_pets.cpp -class_modules/sc_shaman.cpp -class_modules/sc_rogue.cpp -class_modules/priest/sc_priest.cpp -class_modules/priest/sc_priest_discipline.cpp -class_modules/priest/sc_priest_holy.cpp -class_modules/priest/sc_priest_shadow.cpp -class_modules/paladin/sc_paladin.cpp -class_modules/paladin/sc_paladin_retribution.cpp -class_modules/paladin/sc_paladin_protection.cpp -class_modules/paladin/sc_paladin_holy.cpp -class_modules/sc_monk.cpp -class_modules/sc_mage.cpp -class_modules/sc_hunter.cpp -class_modules/sc_enemy.cpp -class_modules/sc_druid.cpp -class_modules/sc_demon_hunter.cpp -class_modules/sc_death_knight.cpp -buff/sc_buff.cpp -action/sc_stats.cpp -action/sc_spell.cpp -action/sc_sequence.cpp -action/sc_dot.cpp -action/sc_distance_targeting.cpp -action/sc_attack.cpp -action/sc_action_state.cpp -action/sc_action.cpp -sc_util.cpp dbc/azerite.cpp -dbc/rand_prop_points.cpp -dbc/spell_item_enchantment.cpp +dbc/gem_data.cpp dbc/item_armor.cpp +dbc/item_effect.cpp dbc/item_weapon.cpp -dbc/gem_data.cpp +dbc/rand_prop_points.cpp +dbc/sc_const_data.cpp +dbc/sc_data.cpp +dbc/sc_item_data.cpp +dbc/sc_item_data_import_noptr.cpp +dbc/sc_item_data_import_ptr.cpp +dbc/sc_spell_data.cpp +dbc/sc_spell_info.cpp +dbc/spell_item_enchantment.cpp +interfaces/sc_bcp_api.cpp +interfaces/sc_http.cpp +interfaces/sc_http_curl.cpp +interfaces/sc_http_wininet.cpp +interfaces/sc_js.cpp +interfaces/wowhead.cpp +item/enchants.cpp +item/item.cpp +item/special_effect.cpp +lib/fmt/format.cpp +lib/fmt/os.cpp +player/actor.cpp +player/actor_target_data.cpp +player/artifact_data.cpp +player/azerite_data.cpp +player/player_stat_cache.cpp +player/player_talent_points.cpp +player/sc_consumable.cpp +player/sc_pet.cpp +player/sc_player.cpp +player/sc_proc.cpp +player/sc_set_bonus.cpp +player/sc_unique_gear.cpp +player/sc_unique_gear_x6.cpp +player/sc_unique_gear_x7.cpp +report/sc_chart.cpp +report/sc_color.cpp +report/sc_gear_weights.cpp +report/sc_highchart.cpp +report/sc_report.cpp +report/sc_report_html_player.cpp +report/sc_report_html_sim.cpp +report/sc_report_json.cpp +report/sc_report_text.cpp +sim/artifact_power.cpp +sim/event_manager.cpp +sim/real_ppm.cpp +sim/scale_factor_control.cpp +sim/sc_cooldown.cpp +sim/sc_event.cpp +sim/sc_expressions.cpp +sim/sc_gear_stats.cpp +sim/sc_option.cpp +sim/sc_plot.cpp +sim/sc_profileset.cpp +sim/sc_progress_bar.cpp +sim/sc_raid_event.cpp +sim/sc_reforge_plot.cpp +sim/sc_sim.cpp +sim/spawner.cpp +sim/x6_pantheon.cpp +util/concurrency.cpp +util/git_info.cpp +util/io.cpp +util/rng.cpp +util/sample_data.cpp +util/stopwatch.cpp +util/timeline.cpp +util/xml.cpp ) \ No newline at end of file diff --git a/source_files/cmake_gui.txt b/source_files/cmake_gui.txt index 58998bd2805..8ee3b3dcdd6 100644 --- a/source_files/cmake_gui.txt +++ b/source_files/cmake_gui.txt @@ -1,42 +1,42 @@ set(source_files -util/sc_textedit.hpp -util/sc_tabbar.hpp -util/sc_searchbox.hpp -util/sc_relativepopup.hpp -util/sc_recentlyclosed.hpp -util/sc_mainwindowcommandline.hpp -util/sc_hoverarea.hpp -simulationcraftqt.hpp -sc_importWindow.hpp +sc_AddonImportTab.hpp sc_importWidget.hpp -sc_Workaround.hpp -sc_WelcomeTab.hpp -sc_SpellQueryTab.hpp -sc_SimulationThread.hpp -sc_SimulateTab.hpp -sc_SampleProfilesTab.hpp +sc_importWindow.hpp sc_OptionsTab.hpp +sc_SampleProfilesTab.hpp +sc_SimulateTab.hpp +sc_SimulationThread.hpp +sc_SpellQueryTab.hpp sc_UpdateCheck.hpp -sc_AddonImportTab.hpp -util/sc_textedit.cpp -util/sc_tabbar.cpp -util/sc_searchbox.cpp -util/sc_relativepopup.cpp -util/sc_recentlyclosed.cpp -util/sc_mainwindowcommandline.cpp -sc_window.cpp -sc_importWindow.cpp +sc_WelcomeTab.hpp +sc_Workaround.hpp +simulationcraftqt.hpp +util/sc_hoverarea.hpp +util/sc_mainwindowcommandline.hpp +util/sc_recentlyclosed.hpp +util/sc_relativepopup.hpp +util/sc_searchbox.hpp +util/sc_tabbar.hpp +util/sc_textedit.hpp +main.cpp +sc_AddonImportTab.cpp +sc_ImportTab.cpp +sc_ImportThread.cpp sc_importWidget.cpp -sc_Workaround.cpp -sc_WelcomeTab.cpp -sc_SpellQueryTab.cpp -sc_SimulationThread.cpp -sc_SimulateTab.cpp -sc_SampleProfilesTab.cpp +sc_importWindow.cpp sc_OptionsTab.cpp +sc_SampleProfilesTab.cpp +sc_SimulateTab.cpp +sc_SimulationThread.cpp +sc_SpellQueryTab.cpp sc_UpdateCheck.cpp -sc_ImportThread.cpp -sc_ImportTab.cpp -sc_AddonImportTab.cpp -main.cpp +sc_WelcomeTab.cpp +sc_window.cpp +sc_Workaround.cpp +util/sc_mainwindowcommandline.cpp +util/sc_recentlyclosed.cpp +util/sc_relativepopup.cpp +util/sc_searchbox.cpp +util/sc_tabbar.cpp +util/sc_textedit.cpp ) \ No newline at end of file diff --git a/source_files/engine_main_make b/source_files/engine_main_make index f85e1abdaa6..1b4fcefb66a 100644 --- a/source_files/engine_main_make +++ b/source_files/engine_main_make @@ -1,5 +1,5 @@ # This file is automatically generated by synchronize.py -# To change the list of source files, update the QT_ files and run synchronize.py +# To change the list of source files run synchronize.py SRC += \ sc_main.cpp \ \ No newline at end of file diff --git a/source_files/engine_make b/source_files/engine_make index dee4c5039ae..95290db02ff 100644 --- a/source_files/engine_make +++ b/source_files/engine_make @@ -1,108 +1,110 @@ # This file is automatically generated by synchronize.py -# To change the list of source files, update the QT_ files and run synchronize.py +# To change the list of source files run synchronize.py SRC += \ - util$(PATHSEP)xml.cpp \ - util$(PATHSEP)stopwatch.cpp \ - util$(PATHSEP)rng.cpp \ - util$(PATHSEP)io.cpp \ - util$(PATHSEP)concurrency.cpp \ - util$(PATHSEP)git_info.cpp \ - util$(PATHSEP)fmt$(PATHSEP)format.cpp \ - util$(PATHSEP)fmt$(PATHSEP)os.cpp \ - sim$(PATHSEP)artifact_power.cpp \ - sim$(PATHSEP)event_manager.cpp \ - sim$(PATHSEP)x6_pantheon.cpp \ - sim$(PATHSEP)real_ppm.cpp \ - sim$(PATHSEP)spawner.cpp \ - sim$(PATHSEP)sc_sim.cpp \ - sim$(PATHSEP)scale_factor_control.cpp \ - sim$(PATHSEP)sc_reforge_plot.cpp \ - sim$(PATHSEP)sc_raid_event.cpp \ - sim$(PATHSEP)sc_progress_bar.cpp \ - sim$(PATHSEP)sc_profileset.cpp \ - sim$(PATHSEP)sc_plot.cpp \ - sim$(PATHSEP)sc_option.cpp \ - sim$(PATHSEP)sc_gear_stats.cpp \ - sim$(PATHSEP)sc_expressions.cpp \ - sim$(PATHSEP)sc_event.cpp \ - sim$(PATHSEP)sc_cooldown.cpp \ - report$(PATHSEP)sc_report_text.cpp \ - report$(PATHSEP)sc_report_json.cpp \ - report$(PATHSEP)sc_report_html_sim.cpp \ - report$(PATHSEP)sc_report_html_player.cpp \ - report$(PATHSEP)sc_report.cpp \ - report$(PATHSEP)sc_highchart.cpp \ - report$(PATHSEP)sc_gear_weights.cpp \ - report$(PATHSEP)sc_color.cpp \ - report$(PATHSEP)sc_chart.cpp \ - player$(PATHSEP)actor_target_data.cpp \ - player$(PATHSEP)actor.cpp \ - player$(PATHSEP)player_talent_points.cpp \ - player$(PATHSEP)sc_unique_gear_x6.cpp \ - player$(PATHSEP)sc_unique_gear_x7.cpp \ - player$(PATHSEP)sc_unique_gear.cpp \ - player$(PATHSEP)player_stat_cache.cpp \ - player$(PATHSEP)sc_set_bonus.cpp \ - player$(PATHSEP)sc_proc.cpp \ - player$(PATHSEP)sc_player.cpp \ - player$(PATHSEP)sc_pet.cpp \ - player$(PATHSEP)sc_consumable.cpp \ - player$(PATHSEP)artifact_data.cpp \ - player$(PATHSEP)azerite_data.cpp \ - interfaces$(PATHSEP)wowhead.cpp \ - interfaces$(PATHSEP)sc_js.cpp \ - interfaces$(PATHSEP)sc_http.cpp \ - interfaces$(PATHSEP)sc_http_curl.cpp \ - interfaces$(PATHSEP)sc_http_wininet.cpp \ - interfaces$(PATHSEP)sc_bcp_api.cpp \ - item$(PATHSEP)enchants.cpp \ - item$(PATHSEP)item.cpp \ - item$(PATHSEP)special_effect.cpp \ - dbc$(PATHSEP)sc_spell_info.cpp \ - dbc$(PATHSEP)sc_spell_data.cpp \ - dbc$(PATHSEP)sc_item_data_import_ptr.cpp \ - dbc$(PATHSEP)sc_item_data_import_noptr.cpp \ - dbc$(PATHSEP)sc_item_data.cpp \ - dbc$(PATHSEP)sc_data.cpp \ - dbc$(PATHSEP)sc_const_data.cpp \ - dbc$(PATHSEP)item_effect.cpp \ + sc_util.cpp \ + action$(PATHSEP)sc_action.cpp \ + action$(PATHSEP)sc_action_state.cpp \ + action$(PATHSEP)sc_attack.cpp \ + action$(PATHSEP)sc_distance_targeting.cpp \ + action$(PATHSEP)sc_dot.cpp \ + action$(PATHSEP)sc_sequence.cpp \ + action$(PATHSEP)sc_spell.cpp \ + action$(PATHSEP)sc_stats.cpp \ + buff$(PATHSEP)sc_buff.cpp \ + class_modules$(PATHSEP)sc_death_knight.cpp \ + class_modules$(PATHSEP)sc_demon_hunter.cpp \ + class_modules$(PATHSEP)sc_druid.cpp \ + class_modules$(PATHSEP)sc_enemy.cpp \ + class_modules$(PATHSEP)sc_hunter.cpp \ + class_modules$(PATHSEP)sc_mage.cpp \ + class_modules$(PATHSEP)sc_monk.cpp \ + class_modules$(PATHSEP)sc_rogue.cpp \ + class_modules$(PATHSEP)sc_shaman.cpp \ class_modules$(PATHSEP)sc_warrior.cpp \ + class_modules$(PATHSEP)paladin$(PATHSEP)sc_paladin.cpp \ + class_modules$(PATHSEP)paladin$(PATHSEP)sc_paladin_holy.cpp \ + class_modules$(PATHSEP)paladin$(PATHSEP)sc_paladin_protection.cpp \ + class_modules$(PATHSEP)paladin$(PATHSEP)sc_paladin_retribution.cpp \ + class_modules$(PATHSEP)priest$(PATHSEP)sc_priest.cpp \ + class_modules$(PATHSEP)priest$(PATHSEP)sc_priest_discipline.cpp \ + class_modules$(PATHSEP)priest$(PATHSEP)sc_priest_holy.cpp \ + class_modules$(PATHSEP)priest$(PATHSEP)sc_priest_shadow.cpp \ class_modules$(PATHSEP)warlock$(PATHSEP)sc_warlock.cpp \ class_modules$(PATHSEP)warlock$(PATHSEP)sc_warlock_affliction.cpp \ class_modules$(PATHSEP)warlock$(PATHSEP)sc_warlock_demonology.cpp \ class_modules$(PATHSEP)warlock$(PATHSEP)sc_warlock_destruction.cpp \ class_modules$(PATHSEP)warlock$(PATHSEP)sc_warlock_pets.cpp \ - class_modules$(PATHSEP)sc_shaman.cpp \ - class_modules$(PATHSEP)sc_rogue.cpp \ - class_modules$(PATHSEP)priest$(PATHSEP)sc_priest.cpp \ - class_modules$(PATHSEP)priest$(PATHSEP)sc_priest_discipline.cpp \ - class_modules$(PATHSEP)priest$(PATHSEP)sc_priest_holy.cpp \ - class_modules$(PATHSEP)priest$(PATHSEP)sc_priest_shadow.cpp \ - class_modules$(PATHSEP)paladin$(PATHSEP)sc_paladin.cpp \ - class_modules$(PATHSEP)paladin$(PATHSEP)sc_paladin_retribution.cpp \ - class_modules$(PATHSEP)paladin$(PATHSEP)sc_paladin_protection.cpp \ - class_modules$(PATHSEP)paladin$(PATHSEP)sc_paladin_holy.cpp \ - class_modules$(PATHSEP)sc_monk.cpp \ - class_modules$(PATHSEP)sc_mage.cpp \ - class_modules$(PATHSEP)sc_hunter.cpp \ - class_modules$(PATHSEP)sc_enemy.cpp \ - class_modules$(PATHSEP)sc_druid.cpp \ - class_modules$(PATHSEP)sc_demon_hunter.cpp \ - class_modules$(PATHSEP)sc_death_knight.cpp \ - buff$(PATHSEP)sc_buff.cpp \ - action$(PATHSEP)sc_stats.cpp \ - action$(PATHSEP)sc_spell.cpp \ - action$(PATHSEP)sc_sequence.cpp \ - action$(PATHSEP)sc_dot.cpp \ - action$(PATHSEP)sc_distance_targeting.cpp \ - action$(PATHSEP)sc_attack.cpp \ - action$(PATHSEP)sc_action_state.cpp \ - action$(PATHSEP)sc_action.cpp \ - sc_util.cpp \ dbc$(PATHSEP)azerite.cpp \ - dbc$(PATHSEP)rand_prop_points.cpp \ - dbc$(PATHSEP)spell_item_enchantment.cpp \ + dbc$(PATHSEP)gem_data.cpp \ dbc$(PATHSEP)item_armor.cpp \ + dbc$(PATHSEP)item_effect.cpp \ dbc$(PATHSEP)item_weapon.cpp \ - dbc$(PATHSEP)gem_data.cpp \ \ No newline at end of file + dbc$(PATHSEP)rand_prop_points.cpp \ + dbc$(PATHSEP)sc_const_data.cpp \ + dbc$(PATHSEP)sc_data.cpp \ + dbc$(PATHSEP)sc_item_data.cpp \ + dbc$(PATHSEP)sc_item_data_import_noptr.cpp \ + dbc$(PATHSEP)sc_item_data_import_ptr.cpp \ + dbc$(PATHSEP)sc_spell_data.cpp \ + dbc$(PATHSEP)sc_spell_info.cpp \ + dbc$(PATHSEP)spell_item_enchantment.cpp \ + interfaces$(PATHSEP)sc_bcp_api.cpp \ + interfaces$(PATHSEP)sc_http.cpp \ + interfaces$(PATHSEP)sc_http_curl.cpp \ + interfaces$(PATHSEP)sc_http_wininet.cpp \ + interfaces$(PATHSEP)sc_js.cpp \ + interfaces$(PATHSEP)wowhead.cpp \ + item$(PATHSEP)enchants.cpp \ + item$(PATHSEP)item.cpp \ + item$(PATHSEP)special_effect.cpp \ + lib$(PATHSEP)fmt$(PATHSEP)format.cpp \ + lib$(PATHSEP)fmt$(PATHSEP)os.cpp \ + player$(PATHSEP)actor.cpp \ + player$(PATHSEP)actor_target_data.cpp \ + player$(PATHSEP)artifact_data.cpp \ + player$(PATHSEP)azerite_data.cpp \ + player$(PATHSEP)player_stat_cache.cpp \ + player$(PATHSEP)player_talent_points.cpp \ + player$(PATHSEP)sc_consumable.cpp \ + player$(PATHSEP)sc_pet.cpp \ + player$(PATHSEP)sc_player.cpp \ + player$(PATHSEP)sc_proc.cpp \ + player$(PATHSEP)sc_set_bonus.cpp \ + player$(PATHSEP)sc_unique_gear.cpp \ + player$(PATHSEP)sc_unique_gear_x6.cpp \ + player$(PATHSEP)sc_unique_gear_x7.cpp \ + report$(PATHSEP)sc_chart.cpp \ + report$(PATHSEP)sc_color.cpp \ + report$(PATHSEP)sc_gear_weights.cpp \ + report$(PATHSEP)sc_highchart.cpp \ + report$(PATHSEP)sc_report.cpp \ + report$(PATHSEP)sc_report_html_player.cpp \ + report$(PATHSEP)sc_report_html_sim.cpp \ + report$(PATHSEP)sc_report_json.cpp \ + report$(PATHSEP)sc_report_text.cpp \ + sim$(PATHSEP)artifact_power.cpp \ + sim$(PATHSEP)event_manager.cpp \ + sim$(PATHSEP)real_ppm.cpp \ + sim$(PATHSEP)scale_factor_control.cpp \ + sim$(PATHSEP)sc_cooldown.cpp \ + sim$(PATHSEP)sc_event.cpp \ + sim$(PATHSEP)sc_expressions.cpp \ + sim$(PATHSEP)sc_gear_stats.cpp \ + sim$(PATHSEP)sc_option.cpp \ + sim$(PATHSEP)sc_plot.cpp \ + sim$(PATHSEP)sc_profileset.cpp \ + sim$(PATHSEP)sc_progress_bar.cpp \ + sim$(PATHSEP)sc_raid_event.cpp \ + sim$(PATHSEP)sc_reforge_plot.cpp \ + sim$(PATHSEP)sc_sim.cpp \ + sim$(PATHSEP)spawner.cpp \ + sim$(PATHSEP)x6_pantheon.cpp \ + util$(PATHSEP)concurrency.cpp \ + util$(PATHSEP)git_info.cpp \ + util$(PATHSEP)io.cpp \ + util$(PATHSEP)rng.cpp \ + util$(PATHSEP)sample_data.cpp \ + util$(PATHSEP)stopwatch.cpp \ + util$(PATHSEP)timeline.cpp \ + util$(PATHSEP)xml.cpp \ \ No newline at end of file diff --git a/source_files/synchronize.py b/source_files/synchronize.py index 4f405a101db..005a81825fd 100644 --- a/source_files/synchronize.py +++ b/source_files/synchronize.py @@ -13,7 +13,6 @@ import logging import pathlib - def parse_qt(filename): out = [] with open(filename, "r") as f: @@ -36,7 +35,7 @@ def header(system): h += "This file is automatically generated by " + os.path.basename(__file__) + "\n" if system != "VS": h += "# " - h += "To change the list of source files, update the QT_ files and run " + os.path.basename(sys.argv[0]) + h += "To change the list of source files run " + os.path.basename(sys.argv[0]) if system == "VS": h += "\n-->" h += "\n\n" @@ -179,7 +178,26 @@ def sort_by_name(entries): entries.sort(key=lambda entry: entry[2], reverse=True) entries.sort(key=lambda entry: entry[4], reverse=True) +def qmake_type_str(file_type, path, filters, prefix, exclude_match): + header_files_nested = [pathlib.Path(path).rglob(filter) for filter in filters] + header_files = [item for sublist in header_files_nested for item in sublist] + if exclude_match is not None: + header_files = filter(lambda x: not re.match(exclude_match, str(x)), header_files) + header_files = [p.relative_to("../") for p in header_files] + lines = ["{} += {}".format(prefix, entry) for entry in header_files] + return "\n".join(lines) + +def create_qmake_str(file_type, path, excludes): + output = header("qmake") + output += qmake_type_str(file_type, path, ["*.hpp", "*.hh"], "HEADERS", excludes) + output += "\n\n" + output += qmake_type_str(file_type, path, ["*.cpp"], "SOURCES", excludes) + + return output +def glob_files(file_type, path, excludes): + write_to_file("QT_" + file_type + ".pri", create_qmake_str(file_type, path, excludes)) + def create_file(file_type, build_systems): try: result = parse_qt("QT_" + file_type + ".pri") @@ -195,8 +213,13 @@ def create_file(file_type, build_systems): logging.error("Could not synchronize '{}' files: {}".format(file_type, e)) logging.debug(traceback.format_exc()) +# Creates source file list by looking for all .cpp, .hpp and .hh files +# Creates source file list for qmake, cmake, Visual Studio and classic engine/Makefile def main(): logging.basicConfig(level=logging.DEBUG) + glob_files("engine", "../engine", ".*sc_main.cpp") + glob_files("gui", "../qt", None) + create_file("engine", ["make", "VS", "cmake"]) create_file("engine_main", ["make", "VS", "cmake"]) create_file("gui", ["VS_GUI", "cmake"]) # TODO: finish mocing part of VS_GUI diff --git a/vs/CommonIncludeDirectories.props b/vs/CommonIncludeDirectories.props index 5306158f7cc..7808a1a8e42 100644 --- a/vs/CommonIncludeDirectories.props +++ b/vs/CommonIncludeDirectories.props @@ -3,7 +3,7 @@ - $(SolutionDir)engine;$(SolutionDir)engine/util;%(AdditionalIncludeDirectories) + $(SolutionDir)engine;$(SolutionDir)engine/include;$(SolutionDir)engine/lib;%(AdditionalIncludeDirectories)