[
  {
    "path": ".github/workflows/gtest.yml",
    "content": "name: gtest\n\non:\n  - push\n  - pull_request\n  - release\n\njobs:\n  gtest:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v4\n        with:\n          fetch-depth: 0\n      - name: Figure out version\n        id: tag\n        run: |\n          TAG=$(git describe --tags --abbrev=0)\n          COMMITS_SINCE_TAG=$(git rev-list ${TAG}..HEAD --count)\n          if [ \"${COMMITS_SINCE_TAG}\" -eq 0 ]; then\n            echo \"VERSION=${TAG}\" >> $GITHUB_ENV\n          else\n            echo \"VERSION=\"$(git describe --tags --abbrev=8) >> $GITHUB_ENV\n          fi\n      - name: Cache Conan2 dependencies\n        uses: actions/cache@v3\n        with:\n          path: ~/.conan2\n          key: ${{ runner.os }}-conan2-${{ hashFiles('**/conanfile.py') }}\n          restore-keys: |\n            ${{ runner.os }}-conan2-\n      - name: Set up Python 3.8 for gcovr\n        uses: actions/setup-python@v4\n      - name: SonarQube install\n        uses: SonarSource/sonarcloud-github-c-cpp@v3\n      - name: Install Conan\n        run: pip install conan\n      - name: Configure Conan Profile\n        run: |\n          conan profile detect -e\n          conan remote add conan-nexus https://nexus.cridland.io/repository/dwd-conan --force\n          conan remote login conan-nexus ci --password ${{ secrets.NEXUS_PASSWORD }}\n      - name: Conan Deps\n        run: conan install . --output-folder=gh-build -s build_type=Debug -s compiler.cppstd=gnu23  -b missing --version=${{ env.VERSION }}\n      - name: Create package\n        run: conan create . --version=${{ env.VERSION }}\n      - name: Conan deps for tests\n        run: cd test && conan install . --output-folder=. -s build_type=Debug -s compiler.cppstd=gnu23 -b missing --version=${{ env.VERSION }}\n      - name: CMake tests\n        run: cd test && cmake -B gh-build -DCMAKE_BUILD_TYPE=Debug\n      - name: Build Wrapper\n        run: cd test && build-wrapper-linux-x86-64 --out-dir sonar-out cmake --build gh-build\n      - name: Sonar Scanner\n        run: cd test && sonar-scanner --define sonar.cfamily.compile-commands=sonar-out/compile_commands.json\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}\n      - name: Run Tests\n        run: cd test/gh-build && ./rapidxml-test\n      - name: Upload\n        run: conan upload -r conan-nexus --confirm 'flxml/*'\n"
  },
  {
    "path": ".gitignore",
    "content": "/cmake-build-debug/\n/gtest-build/\n"
  },
  {
    "path": "README.md",
    "content": "# FLXML\n## Or -- RapidXML, Dave's Version\n\nHey! This is a fork of RapidXML, an ancient C++ library for parsing XML quickly and flexibly. To distinguish, this version is called \"FLXML\", for \"Fast/Light XML\". Hey, it's a name.\n\nThere's a lot of forks of this around, and I (Dave Cridland) didn't write the vast majority of this library - instead, it was written by someone called Marcin Kalicinski, and his copyright is dated 2009.\n\n## Version 2, Breaking Changes\n\nThis is version 2.x. You might not want this, since it introduces a number of breaking changes from rapidxml. The rapidxml-like library is available, with breaking changes, by including `rapidxml.hpp` as before, within the `rapidxml` namespace - however this is an alias to the `flxml` namespace defined in `flxml.h`.\n\nIt has breaking changes, the largest of which are:\n* No more case insensitive option. Really, nobody should be using XML case insensitively anyway, but it was too difficult to keep around, sorry.\n* Instead of passing around potentially unterminated character pointers with optional lengths, we now use std::basic_string_view\n* There is no need for string termination, now, so the parse function never terminates, and that option has vanished.\n* Return values that were previously bare pointers are now a safe wrapped pointer which ordinarily will check/throw for nullptr.\n* append/prepend/insert_node now also have an append/prepend/insert_element shorthand, which will allow an XML namespace to be included if wanted.\n* Parsing data can be done from a container as well as a NUL-terminated buffer. A NUL-terminated buffer remains slightly faster, and will be used if possible (for example, if you pass ina  std::basic_string, it'll call c_str() on it and do that).\n\nNot breaking, but kind of nice:\n* The parse buffer is now treated as const, and will never be mutated. This incurs a slight performance penalty for handling long text values that have an encoded entity late in the string.\n* The iterators library is now included by default, and updated to m_handle most idiomatic modern C++ operations.\n\nInternal changes:\n* There is no longer a internal::measure or internal::compare; these just use the std::char_traits<Ch> functions as used by the string_views.\n* Reserialization (that is, using the rapidxml::print family on a tree that is mostly or entirely from parsing) is now much faster, and will optimize itself to use simple buffer copies where the data is unchanged from parsing.\n* Alignment of the allocator uses C++11's alignof/std::align, and so should be more portable.\n\nNew features:\n* Instead of the `doc->allocate_node` / `node->append_node` dance, you can now `node->append_element(name, value)`, where `name` can be either a `string` (or `string_view`, etc) or a tuple like {xmlns, local_name}, which will set an xmlns attribute if needed.\n* There's a xpathish thing going on in `flxml/predicates.h`, which lets you search for (or iterate through) elements using a trivial subset of XPath.\n* You can get access to containerish things in rapidxml_iterators by methods on nodes/documents, as `node.children()`, `node.attributes()` and a new `node.descendants()`.\n\n### Fun\n\nThe rapidxml_iterators library is now included in `flxml.h`, and you can do amusing things like:\n\n```c++\nfor (auto & child : node.children()) {\n    if (child.name() == \"potato\") scream_for(joy);\n}\n```\n\nMore in [test/iterators.cpp](./test/iterators.cpp)\n\nOf course, in this case it might be simpler to:\n\n```c++\nauto xpath = flxml::xpath::parse(\"/potato\");\nfor (auto & child : xp->all(node)) {\n    scream_for(joy);\n}\n```\n\nMore of that in [test/xpath.cpp](./test/xpath.cpp)\n\nFor those of us who lose track of the buffer sometimes, clone_node() now takes an optional second argument of \"true\" if you want to also clone the strings. Otherwise, nodes will use string_views which reference the original parsed buffer.\n\n### Gotchas\n\nThe functions like find_node and name(...) that took a Ch * and optional length now take only a\nstd::basic_string_view<Ch>. Typical usage passed in 0, NULL, or nullptr for unwanted values; this will now segfault on C++20\nand earlier - use C++23 ideally, but you can pass in {} instead. This should probably be a\nstd::optional<std::basic_string_view<Ch>> instead.\n\n## Changes to the original\n\nI needed a library for fast XMPP processing (reading, processing, and reserializing), and this mostly fit the bill. However, not entirely, so this version adds:\n\n* XML Namespace support\n* An additional parse mode flag for doing shallow parsing.\n* An additional parse mode flag for extracting just one (child) element.\n\n## Tests\n\nThe other thing this fork added was a file of simple tests, which I've recently rewritten into GoogleTest.\n\nThe original makes reference to an expansive test suite, but this was not included in the open source release. I'll expand these tests as and when I need to.\n\nThe tests use a driver which can optionally use Sentry for performance/error tracking; to enable, use the CMake option RAPIDXML_SENTRY, and clone the [sentry-native](https://github.com/getsentry/sentry-native) repository into the root, and when running `rapidxml-test`, set SENTRY_DSN in the environment.\n\nThe tests are in a different Conan package, to keep things light and simple.\n\n## Pull Requests\n\nPull request are very welcome, but do ensure you're happy with the licensing first."
  },
  {
    "path": "conanfile.py",
    "content": "from conan import ConanFile\nfrom conan.tools.files import copy\n\nclass FLXML(ConanFile):\n    name = \"flxml\"\n    exports_sources = \"include/*\"\n    no_copy_source = True\n\n    def package(self):\n        copy(self, \"include/*.hpp\", self.source_folder, self.package_folder)\n        copy(self, \"include/*.h\", self.source_folder, self.package_folder)\n\n    def package_info(self):\n        self.cpp_info.includedirs = ['include']\n        self.cpp_info.libdirs = []\n        self.cpp_info.bindirs = []\n"
  },
  {
    "path": "include/flxml/generator.h",
    "content": "//\n// Created by dave on 29/07/2024.\n//\n\n#ifndef RAPIDXML_RAPIDXML_GENERATOR_HPP\n#define RAPIDXML_RAPIDXML_GENERATOR_HPP\n\n#include <coroutine>\n#include <iterator>\n\nnamespace flxml {\n    template<typename T>\n    class generator {\n    public:\n        using value_pointer = std::remove_reference<T>::type *;\n        struct handle_type;\n        struct promise_type {\n            value_pointer value;\n\n            std::suspend_always yield_value(T & v) {\n                value = &v;\n                return {};\n            }\n\n            std::suspend_never initial_suspend() {\n                return {};\n            }\n\n            std::suspend_always final_suspend() noexcept {\n                return {}; // Change this to std::suspend_always\n            }\n\n            void return_void() {}\n\n            void unhandled_exception() {\n                std::terminate();\n            }\n\n            generator get_return_object() {\n                return generator{handle_type{handle_type::from_promise(*this)}};\n            }\n        };\n\n        struct handle_type : std::coroutine_handle<promise_type> {\n            explicit handle_type(std::coroutine_handle<promise_type> && h) : std::coroutine_handle<promise_type>(std::move(h)) {}\n\n            T &operator*() {\n                return *(this->promise().value);\n            }\n\n            void operator++() {\n                this->resume();\n            }\n\n            bool operator!=(std::default_sentinel_t) const {\n                return !this->done();\n            }\n        };\n\n        explicit generator(handle_type h) : m_handle(h) {}\n\n        ~generator() {\n            if (m_handle)\n                m_handle.destroy();\n        }\n\n        handle_type begin() {\n            return m_handle;\n        }\n\n        std::default_sentinel_t end() {\n            return std::default_sentinel;\n        }\n\n    private:\n        handle_type m_handle{};\n    };\n}\n\n#endif //RAPIDXML_RAPIDXML_GENERATOR_HPP\n"
  },
  {
    "path": "include/flxml/iterators.h",
    "content": "#ifndef RAPIDXML_ITERATORS_HPP_INCLUDED\n#define RAPIDXML_ITERATORS_HPP_INCLUDED\n\n// Copyright (C) 2006, 2009 Marcin Kalicinski\n// Version 1.13\n// Revision $DateTime: 2009/05/13 01:46:17 $\n//! \\file rapidxml_iterators.hpp This file contains rapidxml iterators\n\n#include <flxml.h>\n\nnamespace flxml\n{\n    //! Iterator of child nodes of xml_node\n    template<typename Ch>\nclass node_iterator\n    {\n    public:\n        using value_type = xml_node<Ch>;\n        using reference = xml_node<Ch> &;\n        using pointer = xml_node<Ch> *;\n        using iterator_category = std::bidirectional_iterator_tag;\n        using difference_type = long;\n\n        node_iterator()\n            : m_node()\n        {\n        }\n\n        explicit node_iterator(xml_node<Ch> const &node)\n            : m_node(node.first_node())\n        {\n        }\n\n        node_iterator(node_iterator && other)  noexcept : m_node(other.m_node) {}\n        node_iterator(node_iterator const & other) : m_node(other.m_node) {}\n\n        reference operator *() const\n        {\n            return const_cast<reference>(*m_node);\n        }\n\n        pointer operator->() const\n        {\n            return const_cast<pointer>(m_node.get());\n        }\n\n        node_iterator& operator++()\n        {\n            m_node = m_node->next_sibling();\n            return *this;\n        }\n\n        node_iterator operator++(int)\n        {\n            node_iterator tmp = *this;\n            ++(*this);\n            return tmp;\n        }\n\n        node_iterator& operator--()\n        {\n            m_node = m_node->previous_sibling();\n            return *this;\n        }\n\n        node_iterator operator--(int)\n        {\n            node_iterator tmp = *this;\n            --(*this);\n            return tmp;\n        }\n\n        bool operator == (const node_iterator<Ch>& rhs) const\n        {\n            return m_node == rhs.m_node;\n        }\n\n        bool operator != (const node_iterator<Ch>& rhs) const\n        {\n            return m_node != rhs.m_node;\n        }\n\n        node_iterator & operator = (node_iterator && other)  noexcept {\n            m_node = other.m_node;\n            return *this;\n        }\n\n        node_iterator & operator = (node_iterator const & other) {\n            m_node = other.m_node;\n            return *this;\n        }\n\n        bool valid()\n        {\n            return m_node.has_value();\n        }\n\n    private:\n\n        optional_ptr<xml_node<Ch>> m_node;\n\n    };\n\n    //! Iterator of child nodes of xml_node\n    template<typename Ch=char>\nclass descendant_iterator\n    {\n    public:\n        using value_type = xml_node<Ch>;\n        using reference = xml_node<Ch> &;\n        using pointer = xml_node<Ch> *;\n        using iterator_category = std::bidirectional_iterator_tag;\n        using difference_type = long;\n\n        descendant_iterator()\n            : m_parent(), m_node()\n        {\n        }\n\n        explicit descendant_iterator(xml_node<Ch>::ptr node)\n            : m_parent(node), m_node(node->first_node())\n        {\n        }\n\n        descendant_iterator(descendant_iterator && other)  noexcept : m_parent(other.m_parent), m_node(other.m_node) {}\n        descendant_iterator(descendant_iterator const & other) : m_parent(other.m_parent), m_node(other.m_node) {}\n\n        reference operator *() const\n        {\n            return const_cast<reference>(*m_node);\n        }\n\n        pointer operator->() const\n        {\n            return const_cast<pointer>(m_node.get());\n        }\n\n        descendant_iterator& operator++()\n        {\n            if (m_node->first_node()) {\n                m_node = m_node->first_node();\n            } else if (m_node->next_sibling()) {\n                m_node = m_node->next_sibling();\n            } else {\n                // Run out of children, so move upward until we can find a sibling.\n                while (true) {\n                    m_node = m_node->parent();\n                    if (m_node == m_parent) {\n                        m_node = nullptr;\n                        break;\n                    }\n                    if (m_node->next_sibling()) {\n                        m_node = m_node->next_sibling();\n                        break;\n                    }\n                }\n            }\n            return *this;\n        }\n\n        descendant_iterator operator++(int)\n        {\n            node_iterator tmp = *this;\n            ++(*this);\n            return tmp;\n        }\n\n        descendant_iterator& operator--()\n        {\n            if (!m_node->previous_sibling()) {\n                m_node = m_node->parent();\n                if (m_node == m_parent) {\n                    m_node = nullptr;\n                }\n            } else {\n                m_node = m_node->previous_sibling();\n                while (m_node->last_node()) {\n                    m_node = m_node->last_node();\n                }\n            }\n            return *this;\n        }\n\n        descendant_iterator operator--(int)\n        {\n            node_iterator tmp = *this;\n            --(*this);\n            return tmp;\n        }\n\n        bool operator == (const descendant_iterator<Ch>& rhs) const\n        {\n            return m_node == rhs.m_node;\n        }\n\n        bool operator != (const descendant_iterator<Ch>& rhs) const\n        {\n            return m_node != rhs.m_node;\n        }\n\n    descendant_iterator & operator = (descendant_iterator && other)  noexcept {\n            m_parent = other.m_parent;\n            m_node = other.m_node;\n            return *this;\n        }\n\n    descendant_iterator & operator = (descendant_iterator const & other) {\n        m_parent = other.m_parent;\n        m_node = other.m_node;\n            return *this;\n        }\n\n        bool valid()\n        {\n            return m_node.has_value();\n        }\n\n    private:\n\n        optional_ptr<xml_node<Ch>> m_parent;\n        optional_ptr<xml_node<Ch>> m_node;\n    };\n\n    //! Iterator of child attributes of xml_node\n    template<class Ch>\n    class attribute_iterator\n    {\n    \n    public:\n\n        using value_type = xml_attribute<Ch>;\n        using reference = xml_attribute<Ch> &;\n        using pointer = xml_attribute<Ch> *;\n        using iterator_category = std::bidirectional_iterator_tag;\n        using difference_type = long;\n\n        attribute_iterator()\n            : m_attribute()\n        {\n        }\n\n        explicit attribute_iterator(xml_node<Ch> const &node)\n            : m_attribute(node.first_attribute())\n        {\n        }\n\n        attribute_iterator(attribute_iterator && other)  noexcept : m_attribute(other.m_attribute) {}\n        attribute_iterator(attribute_iterator const & other) : m_attribute(other.m_attribute) {}\n\n        reference operator *() const\n        {\n            return const_cast<reference>(*m_attribute);\n        }\n\n        pointer operator->() const\n        {\n            return const_cast<pointer>(m_attribute.get());\n        }\n\n        attribute_iterator& operator++()\n        {\n            m_attribute = m_attribute->next_attribute();\n            return *this;\n        }\n\n        attribute_iterator operator++(int)\n        {\n            attribute_iterator tmp = *this;\n            ++*this;\n            return tmp;\n        }\n\n        attribute_iterator& operator--()\n        {\n            m_attribute = m_attribute->previous_attribute();\n            return *this;\n        }\n\n        attribute_iterator operator--(int)\n        {\n            attribute_iterator tmp = *this;\n            --*this;\n            return tmp;\n        }\n\n        bool operator ==(const attribute_iterator<Ch> &rhs) const\n        {\n            return m_attribute == rhs.m_attribute;\n        }\n\n        bool operator !=(const attribute_iterator<Ch> &rhs) const\n        {\n            return m_attribute != rhs.m_attribute;\n        }\n\n        attribute_iterator & operator = (attribute_iterator && other)  noexcept {\n            m_attribute = other.m_attribute;\n            return *this;\n        }\n\n        attribute_iterator & operator = (attribute_iterator const & other) {\n            m_attribute = other.m_attribute;\n            return *this;\n        }\n\n    private:\n\n        optional_ptr<xml_attribute<Ch>> m_attribute;\n\n    };\n\n    //! Container adaptor for child nodes\n    template<typename Ch>\n    class children\n    {\n        xml_node<Ch> const & m_node;\n    public:\n        explicit children(xml_node<Ch> const & node) : m_node(node) {}\n        explicit children(optional_ptr<xml_node<Ch>> const ptr) : m_node(ptr.value()) {}\n        children(children && other)  noexcept : m_node(other.m_node) {}\n        children(children const & other) : m_node(other.m_node) {}\n\n        using const_iterator = node_iterator<Ch>;\n        using iterator = node_iterator<Ch>;\n\n        iterator begin() {\n            return iterator(m_node);\n        }\n        iterator end() {\n            return {};\n        }\n        const_iterator begin() const {\n            return const_iterator(m_node);\n        }\n        const_iterator end() const {\n            return {};\n        }\n    };\n\n    //! Container adaptor for child nodes\n    template<typename Ch>\n    class descendants\n    {\n        xml_node<Ch> & m_node;\n    public:\n        explicit descendants(xml_node<Ch> & node) : m_node(node) {}\n        explicit descendants(optional_ptr<xml_node<Ch>> ptr) : m_node(ptr.value()) {}\n        descendants(descendants && other)  noexcept : m_node(other.m_node) {}\n        descendants(descendants const & other) : m_node(other.m_node) {}\n\n        using const_iterator = descendant_iterator<Ch>;\n        using iterator = descendant_iterator<Ch>;\n\n        iterator begin() {\n            return iterator(&m_node);\n        }\n        iterator end() {\n            return {};\n        }\n        const_iterator begin() const {\n            return const_iterator(&m_node);\n        }\n        const_iterator end() const {\n            return {};\n        }\n    };\n\n    //! Container adaptor for attributes\n    template<typename Ch>\n    class attributes\n    {\n        xml_node<Ch> const & m_node;\n    public:\n        explicit attributes(xml_node<Ch> const & node) : m_node(node) {}\n        explicit attributes(optional_ptr<xml_node<Ch>> ptr) : m_node(ptr.value()) {}\n\n        using const_iterator = attribute_iterator<Ch>;\n        using iterator = attribute_iterator<Ch>;\n\n        iterator begin() {\n            return iterator{m_node};\n        }\n        iterator end() {\n            return {};\n        }\n        const_iterator begin() const {\n            return const_iterator{m_node};\n        }\n        const_iterator end() const {\n            return {};\n        }\n    };\n}\n\ntemplate<typename Ch>\ninline constexpr bool std::ranges::enable_borrowed_range<flxml::children<Ch>> = true;\n\ntemplate<typename Ch>\ninline constexpr bool std::ranges::enable_borrowed_range<flxml::attributes<Ch>> = true;\n\n\n#endif\n"
  },
  {
    "path": "include/flxml/predicates.h",
    "content": "//\n// Created by dave on 29/07/2024.\n//\n\n#ifndef RAPIDXML_RAPIDXML_PREDICATES_HPP\n#define RAPIDXML_RAPIDXML_PREDICATES_HPP\n\n#include <string_view>\n#include <list>\n#include <flxml/generator.h>\n#include <flxml.h>\n\nnamespace flxml {\n    template<typename Ch> class xpath;\n    namespace internal {\n        template<typename Ch>\n        class xpath_base;\n\n        template<typename Ch=char>\n        class name : public flxml::internal::xpath_base<Ch> {\n        private:\n            std::basic_string<Ch> m_name;\n            std::optional<std::basic_string<Ch>> m_xmlns;\n        public:\n            explicit name(std::basic_string_view<Ch> n)\n                    : xpath_base<Ch>(), m_name(n) {}\n\n            explicit name(std::basic_string<Ch> const & xmlns, std::basic_string_view<Ch> n)\n                    : xpath_base<Ch>(), m_name(n), m_xmlns(xmlns) {}\n\n            bool do_match(const xml_node<Ch> & t) override {\n                if (m_xmlns.has_value() && t.xmlns() != m_xmlns.value()) return false;\n                return (t.type() == node_type::node_element) && (t.name() == m_name || m_name == \"*\");\n            }\n        };\n\n        template<typename Ch=char>\n        class value : public flxml::internal::xpath_base<Ch> {\n        private:\n            std::basic_string<Ch> m_value;\n        public:\n            explicit value(std::basic_string_view<Ch> v)\n                    : xpath_base<Ch>(), m_value(v) {}\n\n            bool do_match(const xml_node<Ch> & t) override {\n                return (t.type() == node_type::node_element) && (t.value() == m_value);\n            }\n        };\n\n        template<typename Ch=char>\n        class xmlns : public flxml::internal::xpath_base<Ch> {\n        private:\n            std::basic_string<Ch> m_xmlns;\n        public:\n            explicit xmlns(std::basic_string_view<Ch> v)\n                    : xpath_base<Ch>(), m_xmlns(v) {}\n\n            bool do_match(const xml_node<Ch> & t) override {\n                return (t.type() == node_type::node_element) && (t.xmlns() == m_xmlns);\n            }\n        };\n\n        template<typename Ch=char>\n        class attr : public flxml::internal::xpath_base<Ch> {\n        private:\n            std::basic_string<Ch> m_name;\n            std::basic_string<Ch> m_value;\n            std::optional<std::basic_string<Ch>> m_xmlns;\n        public:\n            explicit attr(std::basic_string_view<Ch> n, std::basic_string_view<Ch> v)\n                    : xpath_base<Ch>(), m_name(n), m_value(v) {}\n\n            explicit attr(std::basic_string<Ch> const & x, std::basic_string_view<Ch> n, std::basic_string_view<Ch> v)\n                    : xpath_base<Ch>(), m_name(n), m_value(v), m_xmlns(x) {}\n\n            bool do_match(const xml_node<Ch> & t) override {\n                if (t.type() != node_type::node_element) return false;\n                for (auto const & attr : t.attributes()) {\n                    if (m_xmlns.has_value()) {\n                        if (m_name == \"*\" || attr.local_name() != m_name) continue;\n                        if (attr.xmlns() != m_xmlns.value()) continue;\n                    } else {\n                        if (m_name == \"*\" || attr.name() != m_name) continue;\n                    }\n                    return attr.value() == m_value;\n                }\n                return false;\n            }\n        };\n\n        template<typename Ch=char>\n        class root : public flxml::internal::xpath_base<Ch> {\n        public:\n            root() = default;\n\n            generator<xml_node<Ch> &> do_gather(xml_node<Ch> & t) override {\n                for (auto & x : t.children()) {\n                    co_yield x;\n                }\n            }\n\n            bool do_match(const xml_node<Ch> & t) override {\n                return t.type() == node_type::node_document || t.type() == node_type::node_element;\n            }\n        };\n\n        template<typename Ch=char>\n        class any : public flxml::internal::xpath_base<Ch> {\n        public:\n            any() = default;\n\n            generator<xml_node<Ch> &> do_gather(xml_node<Ch> & t) override {\n                co_yield t; // self\n                for (auto & x : t.descendants()) {\n                    co_yield x;\n                }\n            }\n\n            bool do_match(const xml_node<Ch> & t) override {\n                return t.type() == node_type::node_document || t.type() == node_type::node_element;\n            }\n        };\n\n        template<typename Ch=char>\n        class xpath_base {\n        private:\n            std::list<std::unique_ptr<xpath<Ch>>> m_contexts;\n        public:\n\n            xpath_base() = default;\n\n            virtual ~xpath_base() = default;\n\n            virtual generator<xml_node<Ch> &> do_gather(xml_node<Ch> & t) {\n                co_yield t;\n            }\n\n            generator<xml_node<Ch> &> gather(xml_node<Ch> & t) {\n                for (auto & x : do_gather(t)) {\n                    if (match(x)) co_yield x;\n                }\n            }\n\n            virtual bool do_match(const xml_node<Ch> & t) = 0;\n\n            bool match(xml_node<Ch> & t) {\n                if (!do_match(t)) {\n                    return false;\n                }\n                for(auto & context : m_contexts) {\n                    if (!context->first(t)) {\n                        return false;\n                    }\n                }\n                return true;\n            }\n\n            void context(std::unique_ptr<xpath<Ch>> && xp) {\n                m_contexts.emplace_back(std::move(xp));\n            }\n\n            auto & contexts() const {\n                return m_contexts;\n            }\n        };\n\n        std::map<std::string,std::string> xmlns_empty = {};\n    }\n\n    template<typename Ch=char>\n    class xpath : public internal::xpath_base<Ch> {\n    private:\n        std::vector<std::unique_ptr<internal::xpath_base<Ch>>> m_chain;\n        std::map<std::string,std::string> const & m_xmlns;\n\n    public:\n        bool do_match(const xml_node<Ch> & t) override {\n            return false;\n        }\n\n        auto const & chain() const {\n            return m_chain;\n        }\n        std::string const & prefix_lookup(std::basic_string_view<Ch> const & prefix) const {\n            std::basic_string<Ch> p{prefix};\n            auto it = m_xmlns.find(p);\n            if (it != m_xmlns.end()) {\n                return (*it).second;\n            }\n            throw std::runtime_error(\"XPath contains unknown prefix\");\n        }\n\n        static void parse_predicate(std::basic_string_view<Ch> const &name, xpath<Ch> &xp, bool inner) {\n            using xml_doc = xml_document<Ch>;\n            if (name.starts_with('@')) {\n                std::basic_string<Ch> text = \"<dummy \";\n                bool star = false;\n                if (name.starts_with(\"@*\")) {\n                    text += \"star \";\n                    text += name.substr(2);\n                    star = true;\n                } else {\n                    text += name.substr(1);\n                }\n                text += \"/>\";\n                xml_doc doc;\n                doc.template parse<parse_fastest>(text);\n                auto attr = doc.first_node()->first_attribute();\n                auto colon = attr->name().find(':');\n                if (colon != xml_attribute<Ch>::view_type::npos) {\n                    auto const & uri = xp.prefix_lookup(attr->name().substr(0, colon));\n                    xp.m_chain.push_back(std::make_unique<internal::attr<Ch>>(uri, attr->local_name(), attr->value()));\n                } else {\n                    xp.m_chain.push_back(std::make_unique<internal::attr<Ch>>(star ? \"*\" : attr->name(), attr->value()));\n                }\n            } else if (name.starts_with(\"text()\")) {\n                // text match\n                std::basic_string<Ch> text = \"<dummy text\";\n                text += name.substr(6);\n                text += \"/>\";\n                xml_doc doc;\n                doc.template parse<parse_fastest>(text);\n                auto attr = doc.first_node()->first_attribute();\n                xp.m_chain.push_back(std::make_unique<internal::value<Ch>>(attr->value()));\n            } else if (name.starts_with(\"namespace-uri()\")) {\n                // text match\n                std::basic_string<Ch> text = \"<dummy xmlns\";\n                text += name.substr(6);\n                text += \"/>\";\n                xml_doc doc;\n                doc.template parse<parse_fastest>(text);\n                auto attr = doc.first_node()->first_attribute();\n                xp.m_chain.push_back(std::make_unique<internal::xmlns<Ch>>(attr->value()));\n            } else {\n                if (xp.m_chain.empty() && inner) {\n                    xp.m_chain.push_back(std::make_unique<internal::root<Ch>>());\n                }\n                auto colon = name.find(':');\n                if (colon != std::basic_string_view<Ch>::npos) {\n                    auto const & uri = xp.prefix_lookup(name.substr(0, colon));\n                    xp.m_chain.push_back(std::make_unique<internal::name<Ch>>(uri, name.substr(colon + 1)));\n                } else {\n                    xp.m_chain.push_back(std::make_unique<internal::name<Ch>>(name));\n                }\n            }\n        }\n\n        static bool parse_inner(std::map<std::string,std::string> & xmlns, std::basic_string_view<Ch> &view, xpath<Ch> &xp, bool first=false, bool inner=false) {\n            if (view.starts_with(\"//\")) {\n                xp.m_chain.push_back(std::make_unique<internal::any<Ch>>());\n                view.remove_prefix(2);\n            } else if (view.starts_with('/')) {\n                xp.m_chain.push_back(std::make_unique<internal::root<Ch>>());\n                view.remove_prefix(1);\n            } else if (first && !inner) {\n                xp.m_chain.push_back(std::make_unique<internal::any<Ch>>());\n            }\n            for (typename std::basic_string_view<Ch>::size_type i = 0; i != view.size(); ++i) {\n                switch (view[i]) {\n                    case '/':\n                    case ']':\n                        if (i == 0) throw std::runtime_error(\"Empty name?\");\n                    case '[':\n                        if (i != 0) parse_predicate(view.substr(0, i), xp, inner);\n                }\n                switch (view[i]) {\n                    case ']':\n                        view.remove_prefix(i + 1);\n                        if (!inner) throw std::runtime_error(\"Unexpected ] in input\");\n                        return true;\n                    case '[':\n                        view.remove_prefix(i + 1);\n                        xp.m_chain[xp.m_chain.size() - 1]->context(parse_cont(xmlns, view));\n                        return false;\n                    case '/':\n                        view.remove_prefix(i );\n                        return false;\n                }\n            }\n            if (!view.empty()) {\n                parse_predicate(view, xp, inner);\n                view.remove_prefix(view.length());\n            }\n            return true;\n        }\n\n        static std::unique_ptr<xpath<Ch>> parse_cont(std::map<std::string,std::string> & xmlns, std::basic_string_view<Ch> &view) {\n            if (view.empty()) throw std::runtime_error(\"Context expression is empty\");\n            auto xp = std::make_unique<xpath<Ch>>(xmlns);\n            if (!parse_inner(xmlns, view, *xp, true, true)) {\n                while (!view.empty()) {\n                    if (parse_inner(xmlns, view, *xp, false, true)) break;\n                }\n            }\n            return xp;\n        }\n\n        static std::unique_ptr<xpath<Ch>> parse(std::map<std::string,std::string> & xmlns, std::basic_string_view<Ch> &view) {\n            if (view.empty()) throw std::runtime_error(\"XPath expression is empty\");\n            auto xp = std::make_unique<xpath<Ch>>(xmlns);\n            if (!parse_inner(xmlns, view, *xp, true, false)) {\n                while (!view.empty()) {\n                    if (parse_inner(xmlns, view, *xp, false, false)) break;\n                }\n            }\n            return xp;\n        }\n        static std::unique_ptr<xpath<Ch>> parse(std::map<std::string,std::string> & xmlns, std::basic_string_view<Ch> const &view) {\n            std::basic_string_view<Ch> sv(view);\n            return parse(xmlns, sv);\n        }\n        static std::unique_ptr<xpath<Ch>> parse(std::map<std::string,std::string> & xmlns, std::basic_string<Ch> const &view) {\n            std::basic_string_view<Ch> sv(view);\n            return parse(xmlns, sv);\n        }\n        static std::unique_ptr<xpath<Ch>> parse(std::map<std::string,std::string> & xmlns, const char * view) {\n            std::basic_string_view<Ch> sv(view);\n            return parse(xmlns, sv);\n        }\n        static std::unique_ptr<xpath<Ch>> parse(std::basic_string_view<Ch> &sv) {\n            return parse(internal::xmlns_empty, sv);\n        }\n        static std::unique_ptr<xpath<Ch>> parse(std::basic_string<Ch> const &view) {\n            std::basic_string_view<Ch> sv(view);\n            return parse(internal::xmlns_empty, sv);\n        }\n        static std::unique_ptr<xpath<Ch>> parse(std::basic_string_view<Ch> const &view) {\n            std::basic_string_view<Ch> sv(view);\n            return parse(internal::xmlns_empty, sv);\n        }\n        static std::unique_ptr<xpath<Ch>> parse(const char * view) {\n            std::basic_string_view<Ch> sv(view);\n            return parse(internal::xmlns_empty, sv);\n        }\n\n        explicit xpath(std::map<std::string,std::string> & xmlns) : m_xmlns(xmlns) {}\n\n        flxml::generator<xml_node<Ch> &> all(xml_node<Ch> & current, unsigned int depth = 0) {\n            if (depth >= m_chain.size()) throw std::logic_error(\"Depth exceeded\");\n            auto & xp = m_chain[depth];\n            depth++;\n            for (auto & r : xp->gather(current)) {\n                if (depth >= m_chain.size()) {\n                    co_yield r;\n                } else {\n                    for (auto & t : all(r, depth)) {\n                        co_yield t;\n                    }\n                }\n            }\n        }\n\n        xml_node<Ch>::ptr first(xml_node<Ch> & current) {\n            for (auto &r: all(current)) {\n                return &r;\n            }\n            return {};\n        }\n    };\n}\n\n#endif //RAPIDXML_RAPIDXML_PREDICATES_HPP\n"
  },
  {
    "path": "include/flxml/print.h",
    "content": "#ifndef RAPIDXML_PRINT_HPP_INCLUDED\n#define RAPIDXML_PRINT_HPP_INCLUDED\n\n// Copyright (C) 2006, 2009 Marcin Kalicinski\n// Version 1.13\n// Revision $DateTime: 2009/05/13 01:46:17 $\n//! \\file rapidxml_print.hpp This file contains rapidxml printer implementation\n\n#include <flxml.h>\n\n// Only include streams if not disabled\n#ifndef FLXML_NO_STREAMS\n    #include <ostream>\n    #include <iterator>\n#endif\n\nnamespace flxml\n{\n\n    ///////////////////////////////////////////////////////////////////////\n    // Printing flags\n\n    const int print_no_indenting = 0x1;   //!< Printer flag instructing the printer to suppress indenting of XML. See print() function.\n\n    ///////////////////////////////////////////////////////////////////////\n    // Internal\n\n    //! \\cond internal\n    namespace internal\n    {\n        \n        ///////////////////////////////////////////////////////////////////////////\n        // Internal character operations\n    \n        // Copy characters from given range to given output iterator\n        template<class OutIt, class Ch>\n        inline OutIt copy_chars(const Ch *begin, const Ch *end, OutIt out)\n        {\n            while (begin != end)\n                *out++ = *begin++;\n            return out;\n        }\n\n        template<class OutIt, class Ch>\n        inline OutIt copy_chars(std::basic_string_view<Ch> const & sv, OutIt out) {\n            return copy_chars(sv.data(), sv.data() + sv.size(), out);\n        }\n        \n        // Copy characters from given range to given output iterator and expand\n        // characters into references (&lt; &gt; &apos; &quot; &amp;)\n        template<class OutIt, class Ch>\n        inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out)\n        {\n            while (begin != end)\n            {\n                if (*begin == noexpand)\n                {\n                    *out++ = *begin;    // No expansion, copy character\n                }\n                else\n                {\n                    switch (*begin)\n                    {\n                    case Ch('<'):\n                        *out++ = Ch('&'); *out++ = Ch('l'); *out++ = Ch('t'); *out++ = Ch(';');\n                        break;\n                    case Ch('>'): \n                        *out++ = Ch('&'); *out++ = Ch('g'); *out++ = Ch('t'); *out++ = Ch(';');\n                        break;\n                    case Ch('\\''): \n                        *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('p'); *out++ = Ch('o'); *out++ = Ch('s'); *out++ = Ch(';');\n                        break;\n                    case Ch('\"'): \n                        *out++ = Ch('&'); *out++ = Ch('q'); *out++ = Ch('u'); *out++ = Ch('o'); *out++ = Ch('t'); *out++ = Ch(';');\n                        break;\n                    case Ch('&'): \n                        *out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';'); \n                        break;\n                    default:\n                        *out++ = *begin;    // No expansion, copy character\n                    }\n                }\n                ++begin;    // Step to next character\n            }\n            return out;\n        }\n\n\n        template<class OutIt, class Ch>\n        inline OutIt copy_and_expand_chars(std::basic_string_view<Ch> const & sv, Ch noexpand, OutIt out) {\n            return copy_and_expand_chars(sv.data(), sv.data() + sv.size(), noexpand, out);\n        }\n        // Fill given output iterator with repetitions of the same character\n        template<class OutIt, class Ch>\n        inline OutIt fill_chars(OutIt out, int n, Ch ch)\n        {\n            for (int i = 0; i < n; ++i)\n                *out++ = ch;\n            return out;\n        }\n\n        // Find character\n        template<class Ch, Ch ch>\n        inline bool find_char(const Ch *begin, const Ch *end)\n        {\n            while (begin != end)\n                if (*begin++ == ch)\n                    return true;\n            return false;\n        }\n\n        ///////////////////////////////////////////////////////////////////////////\n        // Internal printing operations\n\n        // Print node\n        template<class OutIt, class Ch>\n        inline OutIt print_node(OutIt out, const optional_ptr<xml_node<Ch>> node, int flags, int indent);\n    \n        // Print children of the node                               \n        template<class OutIt, class Ch>\n        inline OutIt print_children(OutIt out, const optional_ptr<xml_node<Ch>> node, int flags, int indent)\n        {\n            for (auto child = node->first_node(); child; child = child->next_sibling())\n                out = print_node(out, child, flags, indent);\n            return out;\n        }\n\n        // Print attributes of the node\n        template<class OutIt, class Ch>\n        inline OutIt print_attributes(OutIt out, const optional_ptr<xml_node<Ch>> node, int)\n        {\n            for (auto attribute = node->first_attribute(); attribute; attribute = attribute->next_attribute())\n            {\n                if (!(attribute->name().empty()) || attribute->value_raw().empty())\n                {\n                    // Print attribute name\n                    *out = Ch(' '), ++out;\n                    out = copy_chars(attribute->name(), out);\n                    *out = Ch('='), ++out;\n                    if (attribute->quote() && !attribute->value_decoded()) {\n                        // Shortcut here; just dump out the raw value.\n                        *out++ = attribute->quote();\n                        out = copy_chars(attribute->value_raw(), out);\n                        **out++ = attribute->quote();\n                    } else {\n                        // Print attribute value using appropriate quote type\n                        if (attribute->value().find('\"') != std::basic_string_view<Ch>::npos) {\n                            *out = Ch('\\''), ++out;\n                            out = copy_and_expand_chars(attribute->value(), Ch('\"'), out);\n                            *out = Ch('\\''), ++out;\n                        } else {\n                            *out = Ch('\"'), ++out;\n                            out = copy_and_expand_chars(attribute->value(), Ch('\\''), out);\n                            *out = Ch('\"'), ++out;\n                        }\n                    }\n                }\n            }\n            return out;\n        }\n\n        // Print data node\n        template<class OutIt, class Ch>\n        inline OutIt print_data_node(OutIt out, const optional_ptr<xml_node<Ch>> node, int flags, int indent)\n        {\n            assert(node->type() == node_type::node_data);\n            if (!(flags & print_no_indenting))\n                out = fill_chars(out, indent, Ch('\\t'));\n            if (!node->value_decoded()) {\n                out = copy_chars(node->value_raw(), out);\n            } else {\n                out = copy_and_expand_chars(node->value(), Ch(0), out);\n            }\n            return out;\n        }\n\n        // Print data node\n        template<class OutIt, class Ch>\n        inline OutIt print_cdata_node(OutIt out, const optional_ptr<xml_node<Ch>> node, int flags, int indent)\n        {\n            assert(node->type() == node_type::node_cdata);\n            if (!(flags & print_no_indenting))\n                out = fill_chars(out, indent, Ch('\\t'));\n            *out = Ch('<'); ++out;\n            *out = Ch('!'); ++out;\n            *out = Ch('['); ++out;\n            *out = Ch('C'); ++out;\n            *out = Ch('D'); ++out;\n            *out = Ch('A'); ++out;\n            *out = Ch('T'); ++out;\n            *out = Ch('A'); ++out;\n            *out = Ch('['); ++out;\n            out = copy_chars(node->value(), out);\n            *out = Ch(']'); ++out;\n            *out = Ch(']'); ++out;\n            *out = Ch('>'); ++out;\n            return out;\n        }\n\n        // Print element node\n        template<class OutIt, class Ch>\n        inline OutIt print_element_node(OutIt out, const optional_ptr<xml_node<Ch>> node, int flags, int indent)\n        {\n            assert(node->type() == node_type::node_element);\n\n            // Print element name and attributes, if any\n            if (!(flags & print_no_indenting))\n                out = fill_chars(out, indent, Ch('\\t'));\n            *out = Ch('<'), ++out;\n            if (!node->prefix().empty()) {\n                out = copy_chars(node->prefix(), out);\n                *out = Ch(':'); ++out;\n            }\n            out = copy_chars(node->name(), out);\n            out = print_attributes(out, node, flags);\n            \n            // If node is childless\n            if (node->value().empty() && !node->first_node())\n            {\n                // Print childless node tag ending\n                *out = Ch('/'), ++out;\n                *out = Ch('>'), ++out;\n            }\n            else\n            {\n                // Print normal node tag ending\n                *out = Ch('>'), ++out;\n\n                // If the node is clean, just output the contents and move on.\n                // Can only do this if we're not indenting, otherwise pretty-print won't work.\n                if (node->clean() && (flags & print_no_indenting)) {\n                    out = copy_chars(node->contents(), out);\n                } else {\n\n                    // Test if node contains a single data node only (and no other nodes)\n                    auto child = node->first_node();\n                    if (!child) {\n                        // If node has no children, only print its value without indenting\n                        if (!node->value_decoded()) {\n                            out = copy_chars(node->value_raw(), out);\n                        } else {\n                            out = copy_and_expand_chars(node->value(), Ch(0), out);\n                        }\n                    } else if (!child->next_sibling() && child->type() == node_type::node_data) {\n                        // If node has a sole data child, only print its value without indenting\n                        if (!child->value_decoded()) {\n                            out = copy_chars(child->value_raw(), out);\n                        } else {\n                            out = copy_and_expand_chars(child->value(), Ch(0), out);\n                        }\n                    } else {\n                        // Print all children with full indenting\n                        if (!(flags & print_no_indenting))\n                            *out = Ch('\\n'), ++out;\n                        out = print_children(out, node, flags, indent + 1);\n                        if (!(flags & print_no_indenting))\n                            out = fill_chars(out, indent, Ch('\\t'));\n                    }\n                }\n\n                // Print node end\n                *out = Ch('<'), ++out;\n                *out = Ch('/'), ++out;\n                if (!node->prefix().empty()) {\n                    out = copy_chars(node->prefix(), out);\n                    *out = Ch(':'); ++out;\n                }\n                out = copy_chars(node->name(), out);\n                *out = Ch('>'), ++out;\n            }\n            return out;\n        }\n\n        // Print declaration node\n        template<class OutIt, class Ch>\n        inline OutIt print_declaration_node(OutIt out, const optional_ptr<xml_node<Ch>> node, int flags, int indent)\n        {\n            // Print declaration start\n            if (!(flags & print_no_indenting))\n                out = fill_chars(out, indent, Ch('\\t'));\n            *out = Ch('<'), ++out;\n            *out = Ch('?'), ++out;\n            *out = Ch('x'), ++out;\n            *out = Ch('m'), ++out;\n            *out = Ch('l'), ++out;\n\n            // Print attributes\n            out = print_attributes(out, node, flags);\n            \n            // Print declaration end\n            *out = Ch('?'), ++out;\n            *out = Ch('>'), ++out;\n            \n            return out;\n        }\n\n        // Print comment node\n        template<class OutIt, class Ch>\n        inline OutIt print_comment_node(OutIt out, const optional_ptr<xml_node<Ch>> node, int flags, int indent)\n        {\n            assert(node->type() == node_type::node_comment);\n            if (!(flags & print_no_indenting))\n                out = fill_chars(out, indent, Ch('\\t'));\n            *out = Ch('<'), ++out;\n            *out = Ch('!'), ++out;\n            *out = Ch('-'), ++out;\n            *out = Ch('-'), ++out;\n            out = copy_chars(node->value(), out);\n            *out = Ch('-'), ++out;\n            *out = Ch('-'), ++out;\n            *out = Ch('>'), ++out;\n            return out;\n        }\n\n        // Print doctype node\n        template<class OutIt, class Ch>\n        inline OutIt print_doctype_node(OutIt out, const optional_ptr<xml_node<Ch>> node, int flags, int indent)\n        {\n            assert(node->type() == node_type::node_doctype);\n            if (!(flags & print_no_indenting))\n                out = fill_chars(out, indent, Ch('\\t'));\n            *out = Ch('<'), ++out;\n            *out = Ch('!'), ++out;\n            *out = Ch('D'), ++out;\n            *out = Ch('O'), ++out;\n            *out = Ch('C'), ++out;\n            *out = Ch('T'), ++out;\n            *out = Ch('Y'), ++out;\n            *out = Ch('P'), ++out;\n            *out = Ch('E'), ++out;\n            *out = Ch(' '), ++out;\n            out = copy_chars(node->value(), out);\n            *out = Ch('>'), ++out;\n            return out;\n        }\n\n        // Print pi node\n        template<class OutIt, class Ch>\n        inline OutIt print_pi_node(OutIt out, const optional_ptr<xml_node<Ch>> node, int flags, int indent)\n        {\n            assert(node->type() == node_type::node_pi);\n            if (!(flags & print_no_indenting))\n                out = fill_chars(out, indent, Ch('\\t'));\n            *out = Ch('<'), ++out;\n            *out = Ch('?'), ++out;\n            out = copy_chars(node->name(), out);\n            *out = Ch(' '), ++out;\n            out = copy_chars(node->value(), out);\n            *out = Ch('?'), ++out;\n            *out = Ch('>'), ++out;\n            return out;\n        }\n\n        // Print literal node\n        template<class OutIt, class Ch>\n        inline OutIt print_literal_node(OutIt out, const optional_ptr<xml_node<Ch>> node, int flags, int indent)\n        {\n            assert(node->type() == node_type::node_literal);\n            if (!(flags & print_no_indenting))\n                out = fill_chars(out, indent, Ch('\\t'));\n            out = copy_chars(node->value(), out);\n            return out;\n        }\n\n        // Print node\n        // Print node\n        template<class OutIt, class Ch>\n        inline OutIt print_node(OutIt out, const optional_ptr<xml_node<Ch>> node, int flags, int indent)\n        {\n            // Print proper node type\n            switch (node->type())\n            {\n            // Document\n            case node_document:\n                out = print_children(out, node, flags, indent);\n                break;\n\n            // Element\n            case node_element:\n                out = print_element_node(out, node, flags, indent);\n                break;\n            \n            // Data\n            case node_data:\n                out = print_data_node(out, node, flags, indent);\n                break;\n            \n            // CDATA\n            case node_cdata:\n                out = print_cdata_node(out, node, flags, indent);\n                break;\n\n            // Declaration\n            case node_declaration:\n                out = print_declaration_node(out, node, flags, indent);\n                break;\n\n            // Comment\n            case node_comment:\n                out = print_comment_node(out, node, flags, indent);\n                break;\n            \n            // Doctype\n            case node_doctype:\n                out = print_doctype_node(out, node, flags, indent);\n                break;\n\n            // Pi\n            case node_pi:\n                out = print_pi_node(out, node, flags, indent);\n                break;\n\n            case node_literal:\n                out = print_literal_node(out, node, flags, indent);\n                break;\n\n                // Unknown\n            default:\n                assert(0);\n                break;\n            }\n            \n            // If indenting not disabled, add line break after node\n            if (!(flags & print_no_indenting))\n                *out = Ch('\\n'), ++out;\n\n            // Return modified iterator\n            return out;\n        }\n        \n    }\n    //! \\endcond\n\n    ///////////////////////////////////////////////////////////////////////////\n    // Printing\n\n    //! Prints XML to given output iterator.\n    //! \\param out Output iterator to print to.\n    //! \\param node Node to be printed. Pass xml_document to print entire document.\n    //! \\param flags Flags controlling how XML is printed.\n    //! \\return Output iterator pointing to position immediately after last character of printed text.\n    template<class OutIt, class Ch> \n    inline OutIt print(OutIt out, const xml_node<Ch> &node, int flags = 0)\n    {\n        flxml::optional_ptr ptr(const_cast<xml_node<Ch> *>(&node));\n        return internal::print_node(out, ptr, flags, 0);\n    }\n\n#ifndef RAPIDXML_NO_STREAMS\n\n    //! Prints XML to given output stream.\n    //! \\param out Output stream to print to.\n    //! \\param node Node to be printed. Pass xml_document to print entire document.\n    //! \\param flags Flags controlling how XML is printed.\n    //! \\return Output stream.\n    template<class Ch> \n    inline std::basic_ostream<Ch> &print(std::basic_ostream<Ch> &out, const xml_node<Ch> &node, int flags = 0)\n    {\n        print(std::ostream_iterator<Ch>(out), node, flags);\n        return out;\n    }\n\n    //! Prints formatted XML to given output stream. Uses default printing flags. Use print() function to customize printing process.\n    //! \\param out Output stream to print to.\n    //! \\param node Node to be printed.\n    //! \\return Output stream.\n    template<class Ch> \n    inline std::basic_ostream<Ch> &operator <<(std::basic_ostream<Ch> &out, const xml_node<Ch> &node)\n    {\n        return print(out, node);\n    }\n\n#endif\n\n}\n\n#endif\n"
  },
  {
    "path": "include/flxml/tables.h",
    "content": "//\n// Created by dwd on 9/7/24.\n//\n\n#ifndef RAPIDXML_RAPIDXML_TABLES_HPP\n#define RAPIDXML_RAPIDXML_TABLES_HPP\n\n#include <vector>\n#include <array>\n\n///////////////////////////////////////////////////////////////////////\n// Internals\n\n//! \\cond internal\nnamespace flxml::internal {\n\n    // Struct that contains lookup tables for the parser\n    struct lookup_tables {\n        // Whitespace (space \\n \\r \\t)\n        static inline const std::vector<bool> lookup_whitespace =\n                {\n                        // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\n                        false,  false,  false,  false,  false,  false,  false,  false,  false,  true ,  true ,  false,  false,  true ,  false,  false,  // 0\n                        false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  // 1\n                        true ,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  // 2\n                        false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  // 3\n                        false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  // 4\n                        false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  // 5\n                        false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  // 6\n                        false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  // 7\n                        false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  // 8\n                        false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  // 9\n                        false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  // A\n                        false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  // B\n                        false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  // C\n                        false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  // D\n                        false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  // E\n                        false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false,  false   // F\n                };\n\n        // Element name (anything but space \\n \\r \\t / > ? \\0 and :)\n        static inline const std::vector<bool> lookup_element_name =\n                {\n                        // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\n                        false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  false,  false,  true ,  true ,  false,  true ,  true ,  // 0\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 1\n                        false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  false,  // 2\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  false,  true ,  true ,  true ,  false,  false,  // 3\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 4\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 5\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 6\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 7\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 8\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 9\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // A\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // B\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // C\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // D\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // E\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  1   // F\n                };\n\n        // Node name (anything but space \\n \\r \\t / > ? \\0)\n        static inline const std::vector<bool> lookup_node_name =\n                {\n                        // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\n                        false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  false,  false,  true ,  true ,  false,  true ,  true ,  // 0\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 1\n                        false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  false,  // 2\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  false,  false,  // 3\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 4\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 5\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 6\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 7\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 8\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 9\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // A\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // B\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // C\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // D\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // E\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  1   // F\n                };\n\n        // Text (i.e. PCDATA) (anything but < \\0)\n        static inline const std::vector<bool> lookup_text =\n                {\n                        // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\n                        false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 0\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 1\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 2\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  false,  true ,  true ,  true ,  // 3\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 4\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 5\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 6\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 7\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 8\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 9\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // A\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // B\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // C\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // D\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // E\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  1   // F\n                };\n\n        // Text (i.e. PCDATA) that does not require processing when ws normalization is disabled\n        // (anything but < \\0 &)\n        static inline const std::vector<bool> lookup_text_pure_no_ws =\n                {\n                        // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\n                        false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 0\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 1\n                        true ,  true ,  true ,  true ,  true ,  true ,  false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 2\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  false,  true ,  true ,  true ,  // 3\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 4\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 5\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 6\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 7\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 8\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 9\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // A\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // B\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // C\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // D\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // E\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  1   // F\n                };\n\n        // Text (i.e. PCDATA) that does not require processing when ws normalizationis is enabled\n        // (anything but < \\0 & space \\n \\r \\t)\n        static inline const std::vector<bool> lookup_text_pure_with_ws =\n                {\n                        // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\n                        false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  false,  false,  true ,  true ,  false,  true ,  true ,  // 0\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 1\n                        false,  true ,  true ,  true ,  true ,  true ,  false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 2\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  false,  true ,  true ,  true ,  // 3\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 4\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 5\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 6\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 7\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 8\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 9\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // A\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // B\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // C\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // D\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // E\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  1   // F\n                };\n\n        // Attribute name (anything but space \\n \\r \\t / < > = ? ! \\0)\n        static inline const std::vector<bool> lookup_attribute_name =\n                {\n                        // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\n                        false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  false,  false,  true ,  true ,  false,  true ,  true ,  // 0\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 1\n                        false,  false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  false,  // 2\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  false,  false,  false,  false,  // 3\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 4\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 5\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 6\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 7\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 8\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 9\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // A\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // B\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // C\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // D\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // E\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  1   // F\n                };\n\n        // Attribute data with single quote (anything but ' \\0)\n        static inline const std::vector<bool> lookup_attribute_data_1 =\n                {\n                        // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\n                        false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 0\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 1\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 2\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 3\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 4\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 5\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 6\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 7\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 8\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 9\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // A\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // B\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // C\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // D\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // E\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  1   // F\n                };\n\n        // Attribute data with single quote that does not require processing (anything but ' \\0 &)\n        static inline const std::vector<bool> lookup_attribute_data_1_pure =\n                {\n                        // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\n                        false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 0\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 1\n                        true ,  true ,  true ,  true ,  true ,  true ,  false,  false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 2\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 3\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 4\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 5\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 6\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 7\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 8\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 9\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // A\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // B\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // C\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // D\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // E\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  1   // F\n                };\n\n        // Attribute data with double quote (anything but \" \\0)\n        static inline const std::vector<bool> lookup_attribute_data_2 =\n                {\n                        // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\n                        false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 0\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 1\n                        true ,  true ,  false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 2\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 3\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 4\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 5\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 6\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 7\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 8\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 9\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // A\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // B\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // C\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // D\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // E\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  1   // F\n                };\n\n        // Attribute data with double quote that does not require processing (anything but \" \\0 &)\n        static inline const std::vector<bool> lookup_attribute_data_2_pure =\n                {\n                        // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\n                        false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 0\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 1\n                        true ,  true ,  false,  true ,  true ,  true ,  false,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 2\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 3\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 4\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 5\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 6\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 7\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 8\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // 9\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // A\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // B\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // C\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // D\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  // E\n                        true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true ,  true   // F\n                };\n\n        // Digits (dec and hex, 255 denotes end of numeric character reference)\n        static inline const std::array<unsigned char, 256> lookup_digits =\n                {\n                        // 0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\n                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 0\n                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 1\n                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 2\n                        0,  1,  2,  3,  4,  5,  6,  7,  8,  9,255,255,255,255,255,255,  // 3\n                        255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255,  // 4\n                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 5\n                        255, 10, 11, 12, 13, 14, 15,255,255,255,255,255,255,255,255,255,  // 6\n                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 7\n                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 8\n                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // 9\n                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // A\n                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // B\n                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // C\n                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // D\n                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,  // E\n                        255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255   // F\n                };\n    };\n}\n//! \\endcond\n\n#endif //RAPIDXML_RAPIDXML_TABLES_HPP\n"
  },
  {
    "path": "include/flxml/utils.h",
    "content": "#ifndef RAPIDXML_UTILS_HPP_INCLUDED\n#define RAPIDXML_UTILS_HPP_INCLUDED\n\n// Copyright (C) 2006, 2009 Marcin Kalicinski\n// Version 1.13\n// Revision $DateTime: 2009/05/13 01:46:17 $\n//! \\file rapidxml_utils.hpp This file contains high-level rapidxml utilities that can be useful\n//! in certain simple scenarios. They should probably not be used if maximizing performance is the main objective.\n\n#include <flxml.h>\n#include <vector>\n#include <string>\n#include <fstream>\n#include <stdexcept>\n\nnamespace flxml\n{\n\n    //! Represents data loaded from a file\n    template<class Ch = char>\n    class file\n    {\n        \n    public:\n        \n        //! Loads file into the memory. Data will be automatically destroyed by the destructor.\n        //! \\param filename Filename to load.\n        file(const char *filename)\n        {\n            using namespace std;\n\n            // Open stream\n            basic_ifstream<Ch> stream(filename, ios::binary);\n            if (!stream)\n                throw runtime_error(string(\"cannot open file \") + filename);\n            stream.unsetf(ios::skipws);\n            \n            // Determine stream size\n            stream.seekg(0, ios::end);\n            size_t size = stream.tellg();\n            stream.seekg(0);   \n            \n            // Load data and add terminating 0\n            m_data.resize(size + 1);\n            stream.read(&m_data.front(), static_cast<streamsize>(size));\n            m_data[size] = 0;\n        }\n\n        //! Loads file into the memory. Data will be automatically destroyed by the destructor\n        //! \\param stream Stream to load from\n        file(std::basic_istream<Ch> &stream)\n        {\n            using namespace std;\n\n            // Load data and add terminating 0\n            stream.unsetf(ios::skipws);\n            m_data.assign(istreambuf_iterator<Ch>(stream), istreambuf_iterator<Ch>());\n            if (stream.fail() || stream.bad())\n                throw runtime_error(\"error reading stream\");\n            m_data.push_back(0);\n        }\n        \n        //! Gets file data.\n        //! \\return Pointer to data of file.\n        Ch *data()\n        {\n            return &m_data.front();\n        }\n\n        //! Gets file data.\n        //! \\return Pointer to data of file.\n        const Ch *data() const\n        {\n            return &m_data.front();\n        }\n\n        //! Gets file data size.\n        //! \\return Size of file data, in characters.\n        std::size_t size() const\n        {\n            return m_data.size();\n        }\n\n    private:\n\n        std::vector<Ch> m_data;   // File data\n\n    };\n\n    //! Counts children of node. Time complexity is O(n).\n    //! \\return Number of children of node\n    template<class Ch>\n    inline std::size_t count_children(xml_node<Ch> *node)\n    {\n        xml_node<Ch> *child = node->first_node();\n        std::size_t count = 0;\n        while (child)\n        {\n            ++count;\n            child = child->next_sibling();\n        }\n        return count;\n    }\n\n    //! Counts attributes of node. Time complexity is O(n).\n    //! \\return Number of attributes of node\n    template<class Ch>\n    inline std::size_t count_attributes(xml_node<Ch> *node)\n    {\n        xml_attribute<Ch> *attr = node->first_attribute();\n        std::size_t count = 0;\n        while (attr)\n        {\n            ++count;\n            attr = attr->next_attribute();\n        }\n        return count;\n    }\n\n}\n\n#endif\n"
  },
  {
    "path": "include/flxml/wrappers.h",
    "content": "//\n// Created by dave on 10/07/2024.\n//\n\n#ifndef RAPIDXML_RAPIDXML_WRAPPERS_HPP\n#define RAPIDXML_RAPIDXML_WRAPPERS_HPP\n\n#include <type_traits>\n#include <numeric>\n#include <stdexcept>\n\nnamespace flxml {\n    // Most of rapidxml was written to use a NUL-terminated Ch * for parsing.\n    // This utility struct wraps a buffer to provide something that\n    // looks mostly like a pointer, deferencing to NUL when it hits the end.\n    // It's also a forward_iterator, so it'll work with the rage type constructors for string{_view} etc.\n    template<typename T>\n    struct buffer_ptr {\n        // Iterator magic typedefs\n        using iterator_category = std::contiguous_iterator_tag;\n        using difference_type = T::difference_type;\n        using value_type = T::value_type;\n        using pointer = T::const_pointer;\n        using reference = T::const_reference;\n\n        using real_it = T::const_iterator;\n        real_it it;\n        real_it end_it;\n        static constexpr value_type end_char = value_type(0);\n\n        explicit buffer_ptr(T const & buf) : it(buf.cbegin()), end_it(buf.cend()) {}\n        buffer_ptr(buffer_ptr const & other) : it(other.it), end_it(other.end_it) {}\n        buffer_ptr() = default;\n        buffer_ptr & operator = (buffer_ptr const & other) {\n            it = other.it;\n            return *this;\n        }\n        reference validated_it(typename T::const_iterator const &it) const {\n            if (it == end_it) return end_char;\n            return *it;\n        }\n        reference operator[](int i) const {\n            real_it it2 = it + i;\n            if (it2 >= end_it) return end_char;\n            return *it2;\n        }\n        pointer operator -> () const {\n            if (it >= end_it) return &end_char;\n            return &*it;\n        }\n\n        auto operator <=> (buffer_ptr other) const {\n            return it <=> other.it;\n        }\n        auto operator < (buffer_ptr other) const {\n            return it < other.it;\n        }\n        auto operator > (buffer_ptr other) const {\n            return it > other.it;\n        }\n        auto operator >= (buffer_ptr other) const {\n            return it >= other.it;\n        }\n        auto operator <= (buffer_ptr other) const {\n            return it <= other.it;\n        }\n\n        buffer_ptr & operator ++() {\n            ++it;\n            return *this;\n        }\n        buffer_ptr operator ++(int) {\n            auto old = *this;\n            ++it;\n            return old;\n        }\n\n        buffer_ptr & operator --() {\n            --it;\n            return *this;\n        }\n        buffer_ptr operator --(int) {\n            auto old = *this;\n            --it;\n            return old;\n        }\n\n        reference operator *() const {\n            return validated_it(it);\n        }\n\n        bool operator == (buffer_ptr const & other) const {\n            return it == other.it;\n        }\n\n        auto operator + (difference_type n) const {\n            buffer_ptr other(*this);\n            other.it += n;\n            return other;\n        }\n        buffer_ptr & operator += (difference_type i) {\n            it += i;\n            return *this;\n        }\n\n        auto operator - (difference_type n) const {\n            buffer_ptr other(*this);\n            other.it -= n;\n            return other;\n        }\n        buffer_ptr & operator -= (difference_type i) {\n            it -= i;\n            return *this;\n        }\n\n        difference_type operator - (buffer_ptr const & other) const {\n            return it - other.it;\n        }\n\n        pointer ptr() {\n            return &*it;\n        }\n    };\n\n    template<typename T>\n    static auto operator + (int n, buffer_ptr<T> it) {\n        it.it += n;\n        return it;\n    }\n\n    class no_such_node : std::runtime_error {\n    public:\n        no_such_node() : std::runtime_error(\"No such node\") {}\n    };\n\n    template<typename T>\n    class optional_ptr {\n        T * m_ptr;\n\n        void assert_value() const {\n            if (m_ptr == nullptr) {\n                throw no_such_node();\n            }\n        }\n    public:\n        optional_ptr(std::nullptr_t) : m_ptr(nullptr) {}\n        optional_ptr() : m_ptr(nullptr) {}\n        optional_ptr(T * ptr) : m_ptr(ptr) {}\n\n        bool has_value() const {\n            return m_ptr != nullptr;\n        }\n\n        T & value() {\n            assert_value();\n            return *m_ptr;\n        }\n        T * get() {\n            assert_value();\n            return m_ptr;\n        }\n        T * operator -> () {\n            return get();\n        }\n        T & operator * () {\n            return value();\n        }\n        T * ptr_unsafe() {\n            return m_ptr;\n        }\n\n        T const & value() const {\n            assert_value();\n            return *m_ptr;\n        }\n        T const * get() const {\n            assert_value();\n            return m_ptr;\n        }\n        T const * operator -> () const {\n            return get();\n        }\n        T const & operator * () const {\n            return value();\n        }\n        T const * ptr_unsafe() const {\n            return m_ptr;\n        }\n\n        bool operator ! () const {\n            return m_ptr == nullptr;\n        }\n        operator bool() const {\n            return m_ptr != nullptr;\n        }\n\n        bool operator == (T * t) const {\n            return m_ptr == t;\n        }\n        bool operator == (optional_ptr const & t) const {\n            return m_ptr == t.m_ptr;\n        }\n    };\n}\n\n#endif //RAPIDXML_RAPIDXML_WRAPPERS_HPP\n"
  },
  {
    "path": "include/flxml.h",
    "content": "#ifndef RAPIDXML_HPP_INCLUDED\n#define RAPIDXML_HPP_INCLUDED\n\n// Copyright (C) 2006, 2009 Marcin Kalicinski\n// Version 1.13\n// Revision $DateTime: 2009/05/13 01:46:17 $\n//! \\file rapidxml.hpp This file contains rapidxml parser and DOM implementation\n\n#include <flxml/wrappers.h>\n#include <flxml/tables.h>\n\n#include <cstdint>      // For std::size_t\n#include <cassert>      // For assert\n#include <new>          // For placement new\n#include <string>\n#include <span>\n#include <optional>\n#include <memory>\n#include <stdexcept>    // For std::runtime_error\n\n// On MSVC, disable \"conditional expression is constant\" warning (level 4).\n// This warning is almost impossible to avoid with certain types of templated code\n#ifdef _MSC_VER\n    #pragma warning(push)\n    #pragma warning(disable:4127)   // Conditional expression is constant\n#endif\n\n///////////////////////////////////////////////////////////////////////////\n// RAPIDXML_PARSE_ERROR\n\n#if defined(FLXML_NO_EXCEPTIONS)\n\n#define FLXML_PARSE_ERROR(what, where) { parse_error_handler(what, where); assert(0); }\n#define FLML_EOF_ERROR(what, where) { parse_error_handler(what, where); assert(0); }\n\nnamespace flxml\n{\n    //! When exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS,\n    //! this function is called to notify user about the error.\n    //! It must be defined by the user.\n    //! <br><br>\n    //! This function cannot return. If it does, the results are undefined.\n    //! <br><br>\n    //! A very simple definition might look like that:\n    //! <pre>\n    //! void %rapidxml::%parse_error_handler(const char *what, void *where)\n    //! {\n    //!     std::cout << \"Parse error: \" << what << \"\\n\";\n    //!     std::abort();\n    //! }\n    //! </pre>\n    //! \\param what Human readable description of the error.\n    //! \\param where Pointer to character data where error was detected.\n    void parse_error_handler(const char *what, void *where);\n}\n\n#else\n\n#define FLXML_PARSE_ERROR(what, where) {if (*where == Ch(0)) throw eof_error(what, nullptr); else throw parse_error(what, nullptr);} (void)0\n#define FLXML_EOF_ERROR(what, where) throw eof_error(what, nullptr)\n\nnamespace flxml\n{\n\n    //! Parse error exception.\n    //! This exception is thrown by the parser when an error occurs.\n    //! Use what() function to get human-readable error message.\n    //! Use where() function to get a pointer to position within source text where error was detected.\n    //! <br><br>\n    //! If throwing exceptions by the parser is undesirable,\n    //! it can be disabled by defining RAPIDXML_NO_EXCEPTIONS macro before rapidxml.hpp is included.\n    //! This will cause the parser to call rapidxml::parse_error_handler() function instead of throwing an exception.\n    //! This function must be defined by the user.\n    //! <br><br>\n    //! This class derives from <code>std::exception</code> class.\n    class parse_error: public std::runtime_error\n    {\n\n    public:\n\n        //! Constructs parse error\n        parse_error(const char *what, void *where)\n            : std::runtime_error(what)\n            , m_where(where)\n        {\n        }\n\n        //! Gets pointer to character data where error happened.\n        //! Ch should be the same as char type of xml_document that produced the error.\n        //! \\return Pointer to location within the parsed string where error occured.\n        template<class Ch>\n        Ch *where() const\n        {\n            return reinterpret_cast<Ch *>(m_where);\n        }\n\n    private:\n        void *m_where;\n    };\n\n    class eof_error : public parse_error {\n    public:\n        using parse_error::parse_error;\n    };\n\n    class validation_error : public std::runtime_error\n    {\n    public:\n        using std::runtime_error::runtime_error;\n    };\n\n    class xmlns_unbound : public validation_error {\n    public:\n        using validation_error::validation_error;\n    };\n\n    class duplicate_attribute : public validation_error {\n    public:\n        using validation_error::validation_error;\n    };\n\n    class attr_xmlns_unbound : public xmlns_unbound {\n    public:\n        using xmlns_unbound::xmlns_unbound;\n    };\n\n    class element_xmlns_unbound : public xmlns_unbound {\n    public:\n        using xmlns_unbound::xmlns_unbound;\n    };\n}\n\n#endif\n\n///////////////////////////////////////////////////////////////////////////\n// Pool sizes\n\n#ifndef FLXML_STATIC_POOL_SIZE\n    // Size of static memory block of memory_pool.\n    // Define RAPIDXML_STATIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.\n    // No dynamic memory allocations are performed by memory_pool until static memory is exhausted.\n    #define FLXML_STATIC_POOL_SIZE (64 * 1024)\n#endif\n\n#ifndef FLXML_DYNAMIC_POOL_SIZE\n    // Size of dynamic memory block of memory_pool.\n    // Define RAPIDXML_DYNAMIC_POOL_SIZE before including rapidxml.hpp if you want to override the default value.\n    // After the static block is exhausted, dynamic blocks with approximately this size are allocated by memory_pool.\n    #define FLXML_DYNAMIC_POOL_SIZE (64 * 1024)\n#endif\n\nnamespace flxml\n{\n    // Forward declarations\n    template<typename Ch> class xml_node;\n    template<typename Ch> class xml_attribute;\n    template<typename Ch> class xml_document;\n    template<typename Ch> class children;\n    template<typename Ch> class descendants;\n    template<typename Ch> class attributes;\n\n    //! Enumeration listing all node types produced by the parser.\n    //! Use xml_node::type() function to query node type.\n    enum class node_type\n    {\n        node_document,      //!< A document node. Name and value are empty.\n        node_element,       //!< An element node. Name contains element name. Value contains text of first data node.\n        node_data,          //!< A data node. Name is empty. Value contains data text.\n        node_cdata,         //!< A CDATA node. Name is empty. Value contains data text.\n        node_comment,       //!< A comment node. Name is empty. Value contains comment text.\n        node_declaration,   //!< A declaration node. Name and value are empty. Declaration parameters (version, encoding and standalone) are in node attributes.\n        node_doctype,       //!< A DOCTYPE node. Name is empty. Value contains DOCTYPE text.\n        node_pi,            //!< A PI node. Name contains target. Value contains instructions.\n\t    node_literal        //!< Value is unencoded text (used for inserting pre-rendered XML).\n    };\n    using enum node_type; // Import this into the rapidxml namespace as before.\n\n    ///////////////////////////////////////////////////////////////////////\n    // Parsing flags\n\n    //! Parse flag instructing the parser to not create data nodes.\n    //! Text of first data node will still be placed in value of parent element, unless rapidxml::parse_no_element_values flag is also specified.\n    //! Can be combined with other flags by use of | operator.\n    //! <br><br>\n    //! See xml_document::parse() function.\n    const int parse_no_data_nodes = 0x1;\n\n    //! Parse flag instructing the parser to not use text of first data node as a value of parent element.\n    //! Can be combined with other flags by use of | operator.\n    //! Note that child data nodes of element node take precendence over its value when printing.\n    //! That is, if element has one or more child data nodes <em>and</em> a value, the value will be ignored.\n    //! Use rapidxml::parse_no_data_nodes flag to prevent creation of data nodes if you want to manipulate data using values of elements.\n    //! <br><br>\n    //! See xml_document::parse() function.\n    const int parse_no_element_values = 0x2;\n\n    //! Parse flag instructing the parser to not translate entities in the source text.\n    //! By default entities are translated, modifying source text.\n    //! Can be combined with other flags by use of | operator.\n    //! <br><br>\n    //! See xml_document::parse() function.\n    const int parse_no_entity_translation = 0x8;\n\n    //! Parse flag instructing the parser to disable UTF-8 handling and assume plain 8 bit characters.\n    //! By default, UTF-8 handling is enabled.\n    //! Can be combined with other flags by use of | operator.\n    //! <br><br>\n    //! See xml_document::parse() function.\n    const int parse_no_utf8 = 0x10;\n\n    //! Parse flag instructing the parser to create XML declaration node.\n    //! By default, declaration node is not created.\n    //! Can be combined with other flags by use of | operator.\n    //! <br><br>\n    //! See xml_document::parse() function.\n    const int parse_declaration_node = 0x20;\n\n    //! Parse flag instructing the parser to create comments nodes.\n    //! By default, comment nodes are not created.\n    //! Can be combined with other flags by use of | operator.\n    //! <br><br>\n    //! See xml_document::parse() function.\n    const int parse_comment_nodes = 0x40;\n\n    //! Parse flag instructing the parser to create DOCTYPE node.\n    //! By default, doctype node is not created.\n    //! Although W3C specification allows at most one DOCTYPE node, RapidXml will silently accept documents with more than one.\n    //! Can be combined with other flags by use of | operator.\n    //! <br><br>\n    //! See xml_document::parse() function.\n    const int parse_doctype_node = 0x80;\n\n    //! Parse flag instructing the parser to create PI nodes.\n    //! By default, PI nodes are not created.\n    //! Can be combined with other flags by use of | operator.\n    //! <br><br>\n    //! See xml_document::parse() function.\n    const int parse_pi_nodes = 0x100;\n\n    //! Parse flag instructing the parser to validate closing tag names.\n    //! If not set, name inside closing tag is irrelevant to the parser.\n    //! By default, closing tags are not validated.\n    //! Can be combined with other flags by use of | operator.\n    //! <br><br>\n    //! See xml_document::parse() function.\n    const int parse_validate_closing_tags = 0x200;\n\n    //! Parse flag instructing the parser to trim all leading and trailing whitespace of data nodes.\n    //! By default, whitespace is not trimmed.\n    //! This flag does not cause the parser to modify source text.\n    //! Can be combined with other flags by use of | operator.\n    //! <br><br>\n    //! See xml_document::parse() function.\n    const int parse_trim_whitespace = 0x400;\n\n    //! Parse flag instructing the parser to condense all whitespace runs of data nodes to a single space character.\n    //! Trimming of leading and trailing whitespace of data is controlled by rapidxml::parse_trim_whitespace flag.\n    //! By default, whitespace is not normalized.\n    //! If this flag is specified, source text will be modified.\n    //! Can be combined with other flags by use of | operator.\n    //! <br><br>\n    //! See xml_document::parse() function.\n    const int parse_normalize_whitespace = 0x800;\n\n    //! Parse flag to say \"Parse only the initial element opening.\"\n    //! Useful for XMLstreams used in XMPP.\n    const int parse_open_only = 0x1000;\n\n    //! Parse flag to say \"Toss the children of the top node and parse off\n    //! one element.\n    //! Useful for parsing off XMPP top-level elements.\n    const int parse_parse_one = 0x2000;\n\n    //! Parse flag to say \"Validate XML namespaces fully.\"\n    //! This will generate additional errors, including unbound prefixes\n    //! and duplicate attributes (with different prefices)\n    const int parse_validate_xmlns = 0x4000;\n\n    // Compound flags\n\n    //! Parse flags which represent default behaviour of the parser.\n    //! This is always equal to 0, so that all other flags can be simply ored together.\n    //! Normally there is no need to inconveniently disable flags by anding with their negated (~) values.\n    //! This also means that meaning of each flag is a <i>negation</i> of the default setting.\n    //! For example, if flag name is rapidxml::parse_no_utf8, it means that utf-8 is <i>enabled</i> by default,\n    //! and using the flag will disable it.\n    //! <br><br>\n    //! See xml_document::parse() function.\n    [[maybe_unused]] const int parse_default = 0;\n\n    //! A combination of parse flags resulting in fastest possible parsing, without sacrificing important data.\n    //! <br><br>\n    //! See xml_document::parse() function.\n    const int parse_fastest = parse_no_data_nodes;\n\n    //! A combination of parse flags resulting in largest amount of data being extracted.\n    //! This usually results in slowest parsing.\n    //! <br><br>\n    //! See xml_document::parse() function.\n    const int parse_full = parse_declaration_node | parse_comment_nodes | parse_doctype_node | parse_pi_nodes | parse_validate_closing_tags | parse_validate_xmlns;\n\n\n    ///////////////////////////////////////////////////////////////////////\n    // Memory pool\n\n    //! This class is used by the parser to create new nodes and attributes, without overheads of dynamic memory allocation.\n    //! In most cases, you will not need to use this class directly.\n    //! However, if you need to create nodes manually or modify names/values of nodes,\n    //! you are encouraged to use memory_pool of relevant xml_document to allocate the memory.\n    //! Not only is this faster than allocating them by using <code>new</code> operator,\n    //! but also their lifetime will be tied to the lifetime of document,\n    //! possibly simplyfing memory management.\n    //! <br><br>\n    //! Call allocate_node() or allocate_attribute() functions to obtain new nodes or attributes from the pool.\n    //! You can also call allocate_string() function to allocate strings.\n    //! Such strings can then be used as names or values of nodes without worrying about their lifetime.\n    //! Note that there is no <code>free()</code> function -- all allocations are freed at once when clear() function is called,\n    //! or when the pool is destroyed.\n    //! <br><br>\n    //! It is also possible to create a standalone memory_pool, and use it\n    //! to allocate nodes, whose lifetime will not be tied to any document.\n    //! <br><br>\n    //! Pool maintains <code>RAPIDXML_STATIC_POOL_SIZE</code> bytes of statically allocated memory.\n    //! Until static memory is exhausted, no dynamic memory allocations are done.\n    //! When static memory is exhausted, pool allocates additional blocks of memory of size <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> each,\n    //! by using global <code>new[]</code> and <code>delete[]</code> operators.\n    //! This behaviour can be changed by setting custom allocation routines.\n    //! Use set_allocator() function to set them.\n    //! <br><br>\n    //! Allocations for nodes, attributes and strings are aligned at <code>RAPIDXML_ALIGNMENT</code> bytes.\n    //! This value defaults to the size of pointer on target architecture.\n    //! <br><br>\n    //! To obtain absolutely top performance from the parser,\n    //! it is important that all nodes are allocated from a single, contiguous block of memory.\n    //! Otherwise, cache misses when jumping between two (or more) disjoint blocks of memory can slow down parsing quite considerably.\n    //! If required, you can tweak <code>RAPIDXML_STATIC_POOL_SIZE</code>, <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> and <code>RAPIDXML_ALIGNMENT</code>\n    //! to obtain best wasted memory to performance compromise.\n    //! To do it, define their values before rapidxml.hpp file is included.\n    //! \\param Ch Character type of created nodes.\n    template<typename Ch = char>\n    class memory_pool\n    {\n\n    public:\n\n        //! \\cond internal\n        using alloc_func = void * (*)(std::size_t);       // Type of user-defined function used to allocate memory\n        using free_func = void (*)(void *);              // Type of user-defined function used to free memory\n        //! \\endcond\n\n        //! Constructs empty pool with default allocator functions.\n        memory_pool() {\n            init();\n        }\n        memory_pool(memory_pool const &) = delete;\n        memory_pool(memory_pool &&) = delete;\n\n        //! Destroys pool and frees all the memory.\n        //! This causes memory occupied by nodes allocated by the pool to be freed.\n        //! Nodes allocated from the pool are no longer valid.\n        ~memory_pool()\n        {\n            clear();\n        }\n\n        using view_type = std::basic_string_view<Ch>;\n\n        //! Allocates a new node from the pool, and optionally assigns name and value to it.\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\n        //! will call rapidxml::parse_error_handler() function.\n        //! \\param type Type of node to create.\n        //! \\param name Name to assign to the node, or 0 to assign no name.\n        //! \\param value Value to assign to the node, or 0 to assign no value.\n        //! \\param name_size Size of name to assign, or 0 to automatically calculate size from name string.\n        //! \\param value_size Size of value to assign, or 0 to automatically calculate size from value string.\n        //! \\return Pointer to allocated node. This pointer will never be NULL.\n        template<typename... Args>\n        xml_node<Ch> * allocate_node_low(Args... args) {\n            void *memory = allocate_aligned<xml_node<Ch>>();\n            auto *node = new(memory) xml_node<Ch>(args...);\n            return node;\n        }\n        xml_node<Ch> * allocate_node(node_type type, view_type const & name, view_type const & value) {\n            auto * node = this->allocate_node_low(type, name);\n            node->value(value);\n            return node;\n        }\n        xml_node<Ch> * allocate_node(node_type type, view_type const & name) {\n            return this->allocate_node_low(type, name);\n        }\n        xml_node<Ch> * allocate_node(node_type type) {\n            return this->allocate_node_low(type);\n        }\n\n        //! Allocates a new attribute from the pool, and optionally assigns name and value to it.\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\n        //! will call rapidxml::parse_error_handler() function.\n        //! \\param name Name to assign to the attribute, or 0 to assign no name.\n        //! \\param value Value to assign to the attribute, or 0 to assign no value.\n        //! \\param name_size Size of name to assign, or 0 to automatically calculate size from name string.\n        //! \\param value_size Size of value to assign, or 0 to automatically calculate size from value string.\n        //! \\return Pointer to allocated attribute. This pointer will never be NULL.\n        template<typename... Args>\n        xml_attribute<Ch> *allocate_attribute_low(Args... args) {\n            void *memory = allocate_aligned<xml_attribute<Ch>>();\n            auto *attribute = new(memory) xml_attribute<Ch>(args...);\n            return attribute;\n        }\n        xml_attribute<Ch> * allocate_attribute(view_type const & name, view_type const & value) {\n            auto * attr = this->allocate_attribute_low(name);\n            attr->value(value);\n            return attr;\n        }\n        xml_attribute<Ch> * allocate_attribute(view_type const & name) {\n            return this->allocate_attribute_low(name);\n        }\n        xml_attribute<Ch> * allocate_attribute() {\n            return this->allocate_attribute_low();\n        }\n\n        //! Allocates a char array of given size from the pool, and optionally copies a given string to it.\n        //! If the allocation request cannot be accomodated, this function will throw <code>std::bad_alloc</code>.\n        //! If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function\n        //! will call rapidxml::parse_error_handler() function.\n        //! \\param source String to initialize the allocated memory with, or 0 to not initialize it.\n        //! \\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.\n        //! \\return Pointer to allocated char array. This pointer will never be NULL.\n        template<typename Sch>\n        std::span<Ch> allocate_span(std::basic_string_view<Sch> const & source)\n        {\n            if (source.size() == 0) return {}; // No need to allocate.\n            Ch *result = allocate_aligned<Ch>(source.size());\n            for (std::size_t i = 0; i < source.size(); ++i)\n                result[i] = source[i];\n            return {result, source.size()};\n        }\n\n        template<typename Sch>\n        view_type allocate_string(std::basic_string_view<Sch> const & source) {\n            auto span = allocate_span(source);\n            return {span.data(), span.size()};\n        }\n\n        template<typename Sch>\n        view_type allocate_string(std::basic_string<Sch> const & source) {\n            return allocate_string(std::basic_string_view{source.data(), source.size()});\n        }\n\n        template<typename Sch>\n        view_type allocate_string(const Sch * source) {\n            return allocate_string(std::basic_string_view<Sch>(source));\n        }\n\n        view_type const & nullstr()\n        {\n            return m_nullstr;\n        }\n        view_type const & xmlns_xml()\n        {\n            if (m_xmlns_xml.empty())\n                m_xmlns_xml = allocate_string(\"http://www.w3.org/XML/1998/namespace\");\n            return m_xmlns_xml;\n        }\n        view_type const & xmlns_xmlns()\n        {\n            if (m_xmlns_xmlns.empty())\n                m_xmlns_xmlns = allocate_string(\"http://www.w3.org/2000/xmlns/\");\n            return m_xmlns_xmlns;\n        }\n\n\n        //! Clones an xml_node and its hierarchy of child nodes and attributes.\n        //! Nodes and attributes are allocated from this memory pool.\n        //! Names and values are not cloned, they are shared between the clone and the source.\n        //! Result node can be optionally specified as a second parameter,\n        //! in which case its contents will be replaced with cloned source node.\n        //! This is useful when you want to clone entire document.\n        //! \\param source Node to clone.\n        //! \\param result Node to put results in, or 0 to automatically allocate result node\n        //! \\return Pointer to cloned node. This pointer will never be NULL.\n        optional_ptr<xml_node<Ch>> clone_node(const optional_ptr<xml_node<Ch>> source, bool strings=false)\n        {\n            // Prepare result node\n            auto result = allocate_node(source->type());\n            auto s = [this, strings](view_type const & sv) { return strings ? this->allocate_string(sv) : sv; };\n\n            // Clone name and value\n            result->name(s(source->name()));\n            result->value(s(source->value()));\n            result->prefix(s(source->prefix()));\n\n            // Clone child nodes and attributes\n            for (auto child = source->first_node(); child; child = child->next_sibling())\n                result->append_node(clone_node(child, strings));\n            for (auto attr = source->first_attribute(); attr; attr = attr->next_attribute())\n                result->append_attribute(allocate_attribute(s(attr->name()), s(attr->value())));\n\n            return result;\n        }\n\n        //! Clears the pool.\n        //! This causes memory occupied by nodes allocated by the pool to be freed.\n        //! Any nodes or strings allocated from the pool will no longer be valid.\n        void clear()\n        {\n            while (m_begin != m_static_memory.data())\n            {\n                std::size_t s = sizeof(header) * 2;\n                void * h = m_begin;\n                std::align(alignof(header), sizeof(header), h, s);\n                void *previous_begin = reinterpret_cast<header *>(h)->previous_begin;\n                if (m_free_func)\n                    m_free_func(m_begin);\n                else\n                    delete[] reinterpret_cast<char *>(m_begin);\n                m_begin = previous_begin;\n            }\n            init();\n        }\n\n        //! Sets or resets the user-defined memory allocation functions for the pool.\n        //! This can only be called when no memory is allocated from the pool yet, otherwise results are undefined.\n        //! Allocation function must not return invalid pointer on failure. It should either throw,\n        //! stop the program, or use <code>longjmp()</code> function to pass control to other place of program.\n        //! If it returns invalid pointer, results are undefined.\n        //! <br><br>\n        //! User defined allocation functions must have the following forms:\n        //! <br><code>\n        //! <br>void *allocate(std::size_t size);\n        //! <br>void free(void *pointer);\n        //! </code><br>\n        //! \\param af Allocation function, or 0 to restore default function\n        //! \\param ff Free function, or 0 to restore default function\n        [[maybe_unused]] void set_allocator(alloc_func af, free_func ff)\n        {\n            assert(m_begin == m_static_memory.data() && m_ptr == m_begin);    // Verify that no memory is allocated yet\n            m_alloc_func = af;\n            m_free_func = ff;\n        }\n\n    private:\n\n        struct header\n        {\n            void *previous_begin;\n        };\n\n        void init()\n        {\n            m_begin = m_static_memory.data();\n            m_ptr = m_begin;\n            m_space = m_static_memory.size();\n        }\n\n        void *allocate_raw(std::size_t size)\n        {\n            // Allocate\n            void *memory;\n            if (m_alloc_func)   // Allocate memory using either user-specified allocation function or global operator new[]\n            {\n                memory = m_alloc_func(size);\n                assert(memory); // Allocator is not allowed to return 0, on failure it must either throw, stop the program or use longjmp\n            }\n            else\n            {\n                memory = new char[size];\n#ifdef FLXML_NO_EXCEPTIONS\n                if (!memory)            // If exceptions are disabled, verify memory allocation, because new will not be able to throw bad_alloc\n                    FLXML_PARSE_ERROR(\"out of memory\", 0);\n#endif\n            }\n            return memory;\n        }\n\n        template<typename T>\n        T *allocate_aligned(std::size_t n = 1)\n        {\n            auto size = n * sizeof(T);\n            // Calculate aligned pointer\n            if (!std::align(alignof(T), sizeof(T) * n, m_ptr, m_space)) {\n                // If not enough memory left in current pool, allocate a new pool\n                // Calculate required pool size (may be bigger than RAPIDXML_DYNAMIC_POOL_SIZE)\n                std::size_t pool_size = FLXML_DYNAMIC_POOL_SIZE;\n                if (pool_size < size)\n                    pool_size = size;\n\n                // Allocate\n                std::size_t alloc_size = sizeof(header) + (2 * alignof(header) - 2) + pool_size;     // 2 alignments required in worst case: one for header, one for actual allocation\n                void *raw_memory = allocate_raw(alloc_size);\n\n                // Setup new pool in allocated memory\n                void *new_header = raw_memory;\n                std::align(alignof(header), sizeof(header), new_header, alloc_size);\n                auto * h = reinterpret_cast<header *>(new_header);\n                h->previous_begin = m_begin;\n                m_begin = raw_memory;\n                m_ptr = (h + 1);\n                m_space = alloc_size - sizeof(header);\n\n                // Calculate aligned pointer again using new pool\n                return allocate_aligned<T>(n);\n            }\n            auto * result = reinterpret_cast<T *>(m_ptr);\n            m_ptr = (result + n);\n            m_space -= size;\n            auto blank = reinterpret_cast<char *>(result);\n            auto end = blank + size;\n            while (blank != end) *blank++ = 'X';\n            return result;\n        }\n\n        void *m_begin = nullptr;                                      // Start of raw memory making up current pool\n        void *m_ptr = nullptr;                                        // First free byte in current pool\n        std::size_t m_space = FLXML_STATIC_POOL_SIZE;                                        // Available space remaining\n        std::array<char, FLXML_STATIC_POOL_SIZE> m_static_memory = {};    // Static raw memory\n        alloc_func m_alloc_func = nullptr;                           // Allocator function, or 0 if default is to be used\n        free_func m_free_func = nullptr;                             // Free function, or 0 if default is to be used\n        view_type m_nullstr;\n        view_type m_xmlns_xml;\n        view_type m_xmlns_xmlns;\n    };\n\n    ///////////////////////////////////////////////////////////////////////////\n    // XML base\n\n    //! Base class for xml_node and xml_attribute implementing common functions:\n    //! name(), name_size(), value(), value_size() and parent().\n    //! \\param Ch Character type to use\n    template<typename Ch = char>\n    class xml_base\n    {\n\n    public:\n        using view_type = std::basic_string_view<Ch>;\n\n        ///////////////////////////////////////////////////////////////////////////\n        // Construction & destruction\n\n        // Construct a base with empty name, value and parent\n        xml_base() = default;\n        explicit xml_base(view_type const & name) : m_name(name) {}\n        xml_base(view_type const & name, view_type const & value) : m_name(name), m_value(value) {}\n\n        ///////////////////////////////////////////////////////////////////////////\n        // Node data access\n\n        //! Gets name of the node.\n        //! Interpretation of name depends on type of node.\n        //! Note that name will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse.\n        //! <br><br>\n        //! Use name_size() function to determine length of the name.\n        //! \\return Name of node, or empty string if node has no name.\n        view_type const & name() const\n        {\n            return m_name;\n        }\n\n        //! Gets value of node.\n        //! Interpretation of value depends on type of node.\n        //! Note that value will not be zero-terminated if rapidxml::parse_no_string_terminators option was selected during parse.\n        //! <br><br>\n        //! Use value_size() function to determine length of the value.\n        //! \\return Value of node, or empty string if node has no value.\n        view_type const & value_raw() const\n        {\n            return m_value;\n        }\n\n        ///////////////////////////////////////////////////////////////////////////\n        // Node modification\n\n        //! Sets name of node to a non zero-terminated string.\n        //! See \\ref ownership_of_strings.\n        //! <br><br>\n        //! Note that node does not own its name or value, it only stores a pointer to it.\n        //! It will not delete or otherwise free the pointer on destruction.\n        //! It is reponsibility of the user to properly manage lifetime of the string.\n        //! The easiest way to achieve it is to use memory_pool of the document to allocate the string -\n        //! on destruction of the document the string will be automatically freed.\n        //! <br><br>\n        //! Size of name must be specified separately, because name does not have to be zero terminated.\n        //! Use name(const Ch *) function to have the length automatically calculated (string must be zero terminated).\n        //! \\param name Name of node to set. Does not have to be zero terminated.\n        //! \\param size Size of name, in characters. This does not include zero terminator, if one is present.\n        void name(view_type const & name) {\n            m_name = name;\n        }\n\n        //! Sets value of node to a non zero-terminated string.\n        //! See \\ref ownership_of_strings.\n        //! <br><br>\n        //! Note that node does not own its name or value, it only stores a pointer to it.\n        //! It will not delete or otherwise free the pointer on destruction.\n        //! It is reponsibility of the user to properly manage lifetime of the string.\n        //! The easiest way to achieve it is to use memory_pool of the document to allocate the string -\n        //! on destruction of the document the string will be automatically freed.\n        //! <br><br>\n        //! Size of value must be specified separately, because it does not have to be zero terminated.\n        //! Use value(const Ch *) function to have the length automatically calculated (string must be zero terminated).\n        //! <br><br>\n        //! If an element has a child node of type node_data, it will take precedence over element value when printing.\n        //! 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.\n        //! \\param value value of node to set. Does not have to be zero terminated.\n        //! \\param size Size of value, in characters. This does not include zero terminator, if one is present.\n        void value_raw(view_type const & value)\n        {\n            m_value = value;\n        }\n\n        ///////////////////////////////////////////////////////////////////////////\n        // Related nodes access\n\n        //! Gets node parent.\n        //! \\return Pointer to parent node, or 0 if there is no parent.\n        optional_ptr<xml_node<Ch>> parent() const\n        {\n            return m_parent;\n        }\n\n    protected:\n        view_type m_name;                         // Name of node, or 0 if no name\n        view_type m_value;                        // Value of node, or 0 if no value\n        xml_node<Ch> *m_parent = nullptr;             // Pointer to parent node, or 0 if none\n    };\n\n    //! Class representing attribute node of XML document.\n    //! Each attribute has name and value strings, which are available through name() and value() functions (inherited from xml_base).\n    //! Note that after parse, both name and value of attribute will point to interior of source text used for parsing.\n    //! Thus, this text must persist in memory for the lifetime of attribute.\n    //! \\param Ch Character type to use.\n    template<typename Ch = char>\n    class xml_attribute: public xml_base<Ch>\n    {\n\n        friend class xml_node<Ch>;\n\n    public:\n        using view_type = std::basic_string_view<Ch>;\n        using ptr = optional_ptr<xml_attribute<Ch>>;\n\n        ///////////////////////////////////////////////////////////////////////////\n        // Construction & destruction\n\n        //! Constructs an empty attribute with the specified type.\n        //! Consider using memory_pool of appropriate xml_document if allocating attributes manually.\n        xml_attribute() = default;\n        xml_attribute(view_type const & name) : xml_base<Ch>(name) {}\n        xml_attribute(view_type const & name, view_type const & value) : xml_base<Ch>(name, value) {}\n\n        void quote(Ch q) {\n            m_quote = q;\n        }\n        Ch quote() const {\n            return m_quote;\n        }\n\n        view_type const & value() const {\n            if (m_value.has_value()) return m_value.value();\n            m_value = document()->decode_attr_value(this);\n            return m_value.value();\n        }\n        void value(view_type const & v) {\n            m_value = v;\n            this->value_raw(\"\");\n            if (this->m_parent) this->m_parent->dirty_parent();\n        }\n        // Return true if the value has been decoded.\n        bool value_decoded() const {\n            // Either we don't have a decoded value, or we do but it's identical.\n            return !m_value.has_value() || m_value.value().data() != this->value_raw().data();\n        }\n\n        ///////////////////////////////////////////////////////////////////////////\n        // Related nodes access\n\n        //! Gets document of which attribute is a child.\n        //! \\return Pointer to document that contains this attribute, or 0 if there is no parent document.\n        optional_ptr<xml_document<Ch>> document() const {\n            if (auto node = this->parent()) {\n                return node->document();\n            } else {\n                return nullptr;\n            }\n        }\n\n        view_type const & xmlns() const {\n            if (m_xmlns.has_value()) return m_xmlns.value();\n            auto const & name = this->name();\n            auto colon = name.find(':');\n            if (colon != view_type::npos) {\n                auto element = this->parent();\n                if (element) m_xmlns = element->xmlns_lookup(name.substr(0, colon), true);\n            } else {\n                m_xmlns = document()->nullstr();\n            }\n            return m_xmlns.value();\n        }\n        //! Gets previous attribute, optionally matching attribute name.\n        //! \\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\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\n        //! \\return Pointer to found attribute, or 0 if not found.\n        optional_ptr<xml_attribute<Ch>> previous_attribute(view_type const & name = {}) const\n        {\n            if (name)\n            {\n                for (xml_attribute<Ch> *attribute = m_prev_attribute; attribute; attribute = attribute->m_prev_attribute)\n                    if (name == attribute->name())\n                        return attribute;\n                return 0;\n            }\n            else\n                return this->m_parent ? m_prev_attribute : 0;\n        }\n\n        //! Gets next attribute, optionally matching attribute name.\n        //! \\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\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\n        //! \\return Pointer to found attribute, or 0 if not found.\n        optional_ptr<xml_attribute<Ch>> next_attribute(view_type const & name = {}) const\n        {\n            if (!name.empty())\n            {\n                for (xml_attribute<Ch> *attribute = m_next_attribute; attribute; attribute = attribute->m_next_attribute)\n                    if (attribute->name() == name)\n                        return attribute;\n                return nullptr;\n            }\n            else\n                return this->m_parent ? m_next_attribute : nullptr;\n        }\n\n        view_type const & local_name() const\n        {\n            if (!m_local_name.empty()) return m_local_name;\n            auto colon = this->name().find(':');\n            if (colon == view_type::npos) {\n                m_local_name = this->name();\n            } else {\n                m_local_name = this->name().substr(colon + 1);\n            }\n            return m_local_name;\n        }\n\n    private:\n\n        xml_attribute<Ch> *m_prev_attribute = nullptr;        // Pointer to previous sibling of attribute, or 0 if none; only valid if parent is non-zero\n        xml_attribute<Ch> *m_next_attribute = nullptr;        // Pointer to next sibling of attribute, or 0 if none; only valid if parent is non-zero\n        Ch m_quote = 0; // When parsing, this should be set to the containing quote for the value.\n        mutable std::optional<view_type> m_xmlns;\n        mutable std::optional<view_type> m_value; // This is the decoded, not raw, value.\n        mutable view_type m_local_name; // ATTN: points inside m_name.\n    };\n\n    ///////////////////////////////////////////////////////////////////////////\n    // XML node\n\n    //! Class representing a node of XML document.\n    //! Each node may have associated name and value strings, which are available through name() and value() functions.\n    //! Interpretation of name and value depends on type of the node.\n    //! Type of node can be determined by using type() function.\n    //! <br><br>\n    //! Note that after parse, both name and value of node, if any, will point interior of source text used for parsing.\n    //! Thus, this text must persist in the memory for the lifetime of node.\n    //! \\param Ch Character type to use.\n    template<typename Ch = char>\n    class xml_node: public xml_base<Ch>\n    {\n    public:\n        using view_type = std::basic_string_view<Ch>;\n        using ptr = optional_ptr<xml_node<Ch>>;\n\n        ///////////////////////////////////////////////////////////////////////////\n        // Construction & destruction\n\n        //! Constructs an empty node with the specified type.\n        //! Consider using memory_pool of appropriate document to allocate nodes manually.\n        //! \\param type Type of node to construct.\n        explicit xml_node(node_type type)\n            : m_type(type)\n        {\n        }\n        xml_node(node_type type, view_type const & name) : xml_base<Ch>(name), m_type(type) {}\n        xml_node(node_type type, view_type const & name, view_type const & value) : xml_base<Ch>(name, value), m_type(type) {}\n\n        ///////////////////////////////////////////////////////////////////////////\n        // Node data access\n        view_type const & value() const {\n            if (m_value.has_value()) return m_value.value();\n            if (m_type == node_element || m_type == node_data) {\n                m_value = document()->decode_data_value(this);\n            } else {\n                m_value = this->value_raw();\n            }\n            return m_value.value();\n        }\n\n        void dirty() {\n            m_clean = false;\n            dirty_parent();\n        }\n        void dirty_parent() {\n            if (this->m_parent) this->m_parent->dirty();\n        }\n        bool clean() const {\n            return m_clean;\n        }\n\n        void value(view_type const & v) {\n            if (this->m_type == node_element) {\n                // Set the first data node to the value, if one exists.\n                for (auto node = m_first_node; node; node = node->m_next_sibling) {\n                    if (node->type() == node_data) {\n                        node->value(v);\n                        break;\n                    }\n                }\n            }\n            m_value = v;\n            this->value_raw(\"\");\n            dirty();\n        }\n\n        bool value_decoded() const {\n            return !m_value.has_value() || m_value.value().data() != this->value_raw().data();\n        }\n\n        //! Gets type of node.\n        //! \\return Type of node.\n        node_type type() const {\n            return m_type;\n        }\n\n        void prefix(view_type const & prefix) {\n            m_prefix = prefix;\n            dirty_parent();\n        }\n\n        view_type const & prefix() const {\n            return m_prefix;\n        }\n\n        void contents(view_type const & contents) {\n            m_contents = contents;\n            // Reset to clean here.\n            m_clean = true;\n        }\n        view_type const & contents() const\n        {\n            return m_contents;\n        }\n\n        view_type const & xmlns() const {\n            if (m_xmlns.has_value()) return m_xmlns.value();\n            m_xmlns = xmlns_lookup(m_prefix, false);\n            return m_xmlns.value();\n        }\n\n        view_type const & xmlns_lookup(view_type const & prefix, bool attribute) const\n        {\n            std::basic_string<Ch> attrname{\"xmlns\"};\n            if (!prefix.empty()) {\n                // Check if the prefix begins \"xml\".\n                if (prefix.size() >= 3 && prefix.starts_with(\"xml\")) {\n                    if (prefix.size() == 3) {\n                        return this->document()->xmlns_xml();\n                    } else if (prefix.size() == 5\n                               && prefix[3] == Ch('n')\n                               && prefix[4] == Ch('s')) {\n                        return this->document()->xmlns_xmlns();\n                    }\n                }\n                attrname += ':';\n                attrname += prefix;\n            }\n            for (const xml_node<Ch> * node = this;\n                 node;\n                 node = node->m_parent) {\n                auto attr = node->first_attribute(attrname);\n                if (attr) {\n                   return attr->value();\n                }\n            }\n            if (!prefix.empty()) {\n                if (attribute) {\n                    throw attr_xmlns_unbound(attrname.c_str());\n                } else {\n                    throw element_xmlns_unbound(attrname.c_str());\n                }\n            }\n            return document()->nullstr();\n        }\n\n        ///////////////////////////////////////////////////////////////////////////\n        // Related nodes access\n\n        //! Gets document of which node is a child.\n        //! \\return Pointer to document that contains this node, or 0 if there is no parent document.\n        optional_ptr<xml_document<Ch>> document() const\n        {\n            auto *node = this;\n            while (node) {\n                if (node->type() == node_document) {\n                    return static_cast<xml_document<Ch> *>(const_cast<xml_node<Ch> *>(node));\n                }\n                node = node->parent().ptr_unsafe();\n            }\n            return nullptr;\n        }\n\n        flxml::children<Ch> children() const {\n            return flxml::children<Ch>{*this};\n        }\n\n        flxml::descendants<Ch> descendants() const {\n            return flxml::descendants<Ch>{optional_ptr<xml_node<Ch>>{const_cast<xml_node<Ch> *>(this)}};\n        }\n\n        flxml::attributes<Ch> attributes() const {\n            return flxml::attributes<Ch>{*this};\n        }\n\n        //! Gets first child node, optionally matching node name.\n        //! \\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\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\n        //! \\return Pointer to found child, or 0 if not found.\n        optional_ptr<xml_node<Ch>> first_node(view_type const & name = {}, view_type const & asked_xmlns = {}) const\n        {\n            view_type xmlns = asked_xmlns;\n            if (asked_xmlns.empty() && !name.empty()) {\n                // No XMLNS asked for, but a name is present.\n                // Assume \"same XMLNS\".\n                xmlns = this->xmlns();\n            }\n            for (xml_node<Ch> *child = m_first_node; child; child = child->m_next_sibling) {\n                if ((name.empty() || child->name() == name)\n                    && (xmlns.empty() || child->xmlns() == xmlns)) {\n                    return child;\n                }\n            }\n            return nullptr;\n        }\n\n        //! Gets last child node, optionally matching node name.\n        //! Behaviour is undefined if node has no children.\n        //! Use first_node() to test if node has children.\n        //! \\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\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\n        //! \\return Pointer to found child, or 0 if not found.\n        optional_ptr<xml_node<Ch>> last_node(view_type const & name = {}, view_type const & asked_xmlns = {}) const\n        {\n            view_type xmlns = asked_xmlns;\n            if (asked_xmlns.empty() && !name.empty()) {\n                // No XMLNS asked for, but a name is present.\n                // Assume \"same XMLNS\".\n                xmlns = this->xmlns();\n            }\n            for (xml_node<Ch> *child = m_last_node; child; child = child->m_prev_sibling) {\n                if ((name.empty() || child->name() == name)\n                    && (xmlns.empty() || child->xmlns() == xmlns)) {\n                    return child;\n                }\n            }\n            return nullptr;\n        }\n\n        //! Gets previous sibling node, optionally matching node name.\n        //! Behaviour is undefined if node has no parent.\n        //! Use parent() to test if node has a parent.\n        //! \\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\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\n        //! \\return Pointer to found sibling, or 0 if not found.\n        optional_ptr<xml_node<Ch>> previous_sibling(view_type const & name = {}, view_type const & asked_xmlns = {}) const\n        {\n            assert(this->m_parent);     // Cannot query for siblings if node has no parent\n            if (!name.empty())\n            {\n                view_type xmlns = asked_xmlns;\n                if (xmlns.empty() && !name.empty()) {\n                    // No XMLNS asked for, but a name is present.\n                    // Assume \"same XMLNS\".\n                    xmlns = this->xmlns();\n                }\n                for (xml_node<Ch> *sibling = m_prev_sibling; sibling; sibling = sibling->m_prev_sibling)\n                    if ((name.empty() || sibling->name() == name)\n                        && (xmlns.empty() || sibling->xmlns() == xmlns))\n                        return sibling;\n                return nullptr;\n            }\n            else\n                return m_prev_sibling;\n        }\n\n        //! Gets next sibling node, optionally matching node name.\n        //! Behaviour is undefined if node has no parent.\n        //! Use parent() to test if node has a parent.\n        //! \\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\n        //! \\param xmlns Namespace 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\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\n        //! \\return Pointer to found sibling, or 0 if not found.\n        optional_ptr<xml_node<Ch>> next_sibling(view_type const & name = {}, view_type const & asked_xmlns = {}) const\n        {\n            assert(this->m_parent);     // Cannot query for siblings if node has no parent\n            view_type xmlns = asked_xmlns;\n            if (xmlns.empty() && !name.empty()) {\n                // No XMLNS asked for, but a name is present.\n                // Assume \"same XMLNS\".\n                xmlns = this->xmlns();\n            }\n            for (xml_node<Ch> *sibling = m_next_sibling; sibling; sibling = sibling->m_next_sibling)\n                if ((name.empty() || sibling->name() == name)\n                    && (xmlns.empty() || sibling->xmlns() == xmlns))\n                    return sibling;\n            return nullptr;\n        }\n\n        //! Gets first attribute of node, optionally matching attribute name.\n        //! \\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\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\n        //! \\return Pointer to found attribute, or 0 if not found.\n        optional_ptr<xml_attribute<Ch>> first_attribute(view_type const & name = {}, view_type const & xmlns = {}) const\n        {\n            for (xml_attribute<Ch> *attribute = m_first_attribute; attribute; attribute = attribute->m_next_attribute)\n                if ((name.empty() || attribute->name() == name) && (xmlns.empty() || attribute->xmlns() == xmlns))\n                    return attribute;\n            return nullptr;\n        }\n\n        //! Gets last attribute of node, optionally matching attribute name.\n        //! \\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\n        //! \\param name_size Size of name, in characters, or 0 to have size calculated automatically from string\n        //! \\param case_sensitive Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters\n        //! \\return Pointer to found attribute, or 0 if not found.\n        optional_ptr<xml_attribute<Ch>> last_attribute(view_type const & name = {}, view_type const & xmlns = {}) const\n        {\n            for (xml_attribute<Ch> *attribute = m_last_attribute; attribute; attribute = attribute->m_prev_attribute)\n                if ((name.empty() || attribute->name() == name) && (xmlns.empty() || attribute->xmlns() == xmlns))\n                    return attribute;\n            return nullptr;\n        }\n\n        ///////////////////////////////////////////////////////////////////////////\n        // Node modification\n\n        //! Sets type of node.\n        //! \\param type Type of node to set.\n        void type(node_type type) {\n            m_type = type;\n            dirty();\n        }\n\n        ///////////////////////////////////////////////////////////////////////////\n        // Node manipulation\n\n        //! Allocate a new element to be added as a child at this node.\n        //! If an XMLNS is specified via the clarke notation syntax, then the prefix will match the parent element (if any),\n        //! and any needed xmlns attributes will be added for you.\n        //! Strings are assumed to remain in scope - you should document()->allocate_string() any that might not.\n        //! \\param name Name of the element, either string view, string, or clarke notation\n    protected: // These are too easy to accidentally forget to append, prepend, or insert.\n        optional_ptr<xml_node<Ch>> allocate_element(view_type const & name) {\n            return document()->allocate_node(node_element, name);\n        }\n        optional_ptr<xml_node<Ch>> allocate_element(std::tuple<view_type,view_type> const & clark_name) {\n            auto [xmlns, name] = clark_name;\n            xml_node<Ch> * child;\n            if (xmlns != this->xmlns()) {\n                child = document()->allocate_node(node_element, name);\n                child->append_attribute(document()->allocate_attribute(\"xmlns\", xmlns));\n            } else if (!this->prefix().empty()) {\n                std::basic_string<Ch> pname = std::string(this->prefix()) + ':';\n                pname += name;\n                child = document()->allocate_node(node_element, document()->allocate_string(pname));\n            } else {\n                child = document()->allocate_node(node_element, name);\n            }\n            return child;\n        }\n        optional_ptr<xml_node<Ch>> allocate_element(view_type const & name, view_type const & value) {\n            auto child = allocate_element(name);\n            child->value(value);\n            return child;\n        }\n        optional_ptr<xml_node<Ch>> allocate_element(std::tuple<view_type,view_type> const & clark_name, view_type const & value) {\n            auto child = allocate_element(clark_name);\n            child->value(value);\n            return child;\n        }\n        optional_ptr<xml_node<Ch>> allocate_element(std::initializer_list<const Ch *> const & clark_name) {\n            auto it = clark_name.begin();\n            auto a = *it;\n            auto b = *++it;\n            return allocate_element({view_type(a), view_type(b)});\n        }\n        optional_ptr<xml_node<Ch>> allocate_element(std::initializer_list<const Ch *> const & clark_name, view_type const & value) {\n            auto child = allocate_element(clark_name);\n            if (!value.empty()) child->value(value);\n            return child;\n        }\n    public:\n\n        //! Prepends a new child node.\n        //! The prepended child becomes the first child, and all existing children are moved one position back.\n        //! \\param child Node to prepend.\n        optional_ptr<xml_node<Ch>> prepend_node(xml_node<Ch> *child)\n        {\n            assert(child && !child->parent() && child->type() != node_document);\n            dirty();\n            if (first_node())\n            {\n                child->m_next_sibling = m_first_node;\n                m_first_node->m_prev_sibling = child;\n            }\n            else\n            {\n                child->m_next_sibling = 0;\n                m_last_node = child;\n            }\n            m_first_node = child;\n            child->m_parent = this;\n            child->m_prev_sibling = 0;\n            return child;\n        }\n        auto prepend_node(optional_ptr<xml_node<Ch>> ptr) {\n            return prepend_node(ptr.get());\n        }\n        auto prepend_element(view_type const & v, view_type const & value = {}) {\n            auto child = allocate_element(v, value);\n            return prepend_node(child);\n        }\n        auto prepend_element(std::tuple<view_type, view_type> const & il, view_type const & value = {}) {\n            auto child = allocate_element(il, value);\n            return prepend_node(child);\n        }\n        auto prepend_element(std::initializer_list<const Ch *> const & il, view_type const & value = {}) {\n            auto child = allocate_element(il, value);\n            return prepend_node(child);\n        }\n\n        //! Appends a new child node.\n        //! The appended child becomes the last child.\n        //! \\param child Node to append.\n        optional_ptr<xml_node<Ch>> append_node(xml_node<Ch> *child)\n        {\n            assert(child && !child->parent() && child->type() != node_document);\n            dirty();\n            if (first_node())\n            {\n                child->m_prev_sibling = m_last_node;\n                m_last_node->m_next_sibling = child;\n            }\n            else\n            {\n                child->m_prev_sibling = nullptr;\n                m_first_node = child;\n            }\n            m_last_node = child;\n            child->m_parent = this;\n            child->m_next_sibling = nullptr;\n            return child;\n        }\n        optional_ptr<xml_node<Ch>> append_node(optional_ptr<xml_node<Ch>> ptr) {\n            return append_node(ptr.get());\n        }\n        auto append_element(view_type const & v, view_type const & value = {}) {\n            auto child = allocate_element(v, value);\n            return append_node(child);\n        }\n        auto append_element(std::tuple<view_type, view_type> const & il, view_type const & value = {}) {\n            auto child = allocate_element(il, value);\n            return append_node(child);\n        }\n        auto append_element(std::initializer_list<const Ch *> const & il, view_type const & value = {}) {\n            auto child = allocate_element(il, value);\n            return append_node(child);\n        }\n\n        //! Inserts a new child node at specified place inside the node.\n        //! All children after and including the specified node are moved one position back.\n        //! \\param where Place where to insert the child, or 0 to insert at the back.\n        //! \\param child Node to insert.\n        optional_ptr<xml_node<Ch>> insert_node(xml_node<Ch> *where, xml_node<Ch> *child)\n        {\n            assert(!where || where->parent() == this);\n            assert(child && !child->parent() && child->type() != node_document);\n            dirty();\n            if (where == m_first_node)\n                prepend_node(child);\n            else if (!where)\n                append_node(child);\n            else\n            {\n                child->m_prev_sibling = where->m_prev_sibling;\n                child->m_next_sibling = where;\n                where->m_prev_sibling->m_next_sibling = child;\n                where->m_prev_sibling = child;\n                child->m_parent = this;\n            }\n            return child;\n        }\n        auto insert_node(optional_ptr<xml_node<Ch>> where, optional_ptr<xml_node<Ch>> ptr) {\n            return insert_node(where.ptr(), ptr.ptr());\n        }\n        auto insert_element(optional_ptr<xml_node<Ch>> where, view_type const & v, view_type const & value = {}) {\n            auto child = allocate_element(v, value);\n            return insert_node(where, child);\n        }\n        auto insert_element(optional_ptr<xml_node<Ch>> where, std::tuple<view_type, view_type> const & il, view_type const & value = {}) {\n            auto child = allocate_element(il, value);\n            return insert_node(where, child);\n        }\n        auto insert_element(optional_ptr<xml_node<Ch>> where, std::initializer_list<const Ch *> const & il, view_type const & value = {}) {\n            auto child = allocate_element(il, value);\n            return insert_node(where, child);\n        }\n\n        //! Removes first child node.\n        //! If node has no children, behaviour is undefined.\n        //! Use first_node() to test if node has children.\n        void remove_first_node()\n        {\n            assert(first_node());\n            dirty();\n            xml_node<Ch> *child = m_first_node;\n            m_first_node = child->m_next_sibling;\n            if (child->m_next_sibling)\n                child->m_next_sibling->m_prev_sibling = nullptr;\n            else\n                m_last_node = nullptr;\n            child->m_parent = nullptr;\n        }\n\n        //! Removes last child of the node.\n        //! If node has no children, behaviour is undefined.\n        //! Use first_node() to test if node has children.\n        void remove_last_node()\n        {\n            assert(first_node());\n            dirty();\n            xml_node<Ch> *child = m_last_node;\n            if (child->m_prev_sibling)\n            {\n                m_last_node = child->m_prev_sibling;\n                child->m_prev_sibling->m_next_sibling = nullptr;\n            }\n            else\n                m_first_node = nullptr;\n            child->m_parent = nullptr;\n        }\n\n        //! Removes specified child from the node\n        // \\param where Pointer to child to be removed.\n        void remove_node(optional_ptr<xml_node<Ch>> where)\n        {\n            assert(where->parent() == this);\n            assert(first_node());\n            dirty();\n            if (where == m_first_node)\n                remove_first_node();\n            else if (where == m_last_node)\n                remove_last_node();\n            else\n            {\n                where->m_prev_sibling->m_next_sibling = where->m_next_sibling;\n                where->m_next_sibling->m_prev_sibling = where->m_prev_sibling;\n                where->m_parent = nullptr;\n            }\n        }\n\n        //! Removes all child nodes (but not attributes).\n        void remove_all_nodes()\n        {\n            if (!m_first_node) return;\n            dirty();\n            for (xml_node<Ch> *node = m_first_node; node; node = node->m_next_sibling) {\n                node->m_parent = nullptr;\n            }\n            m_first_node = nullptr;\n            m_last_node = nullptr;\n        }\n\n        //! Prepends a new attribute to the node.\n        //! \\param attribute Attribute to prepend.\n        void prepend_attribute(xml_attribute<Ch> *attribute)\n        {\n            assert(attribute && !attribute->parent());\n            dirty_parent();\n            if (first_attribute())\n            {\n                attribute->m_next_attribute = m_first_attribute;\n                m_first_attribute->m_prev_attribute = attribute;\n            }\n            else\n            {\n                attribute->m_next_attribute = nullptr;\n                m_last_attribute = attribute;\n            }\n            m_first_attribute = attribute;\n            attribute->m_parent = this;\n            attribute->m_prev_attribute = nullptr;\n        }\n\n        //! Appends a new attribute to the node.\n        //! \\param attribute Attribute to append.\n        void append_attribute(xml_attribute<Ch> *attribute)\n        {\n            assert(attribute && !attribute->parent());\n            dirty_parent();\n            if (first_attribute())\n            {\n                attribute->m_prev_attribute = m_last_attribute;\n                m_last_attribute->m_next_attribute = attribute;\n            }\n            else\n            {\n                attribute->m_prev_attribute = nullptr;\n                m_first_attribute = attribute;\n            }\n            m_last_attribute = attribute;\n            attribute->m_parent = this;\n            attribute->m_next_attribute = nullptr;\n        }\n\n        //! Inserts a new attribute at specified place inside the node.\n        //! All attributes after and including the specified attribute are moved one position back.\n        //! \\param where Place where to insert the attribute, or 0 to insert at the back.\n        //! \\param attribute Attribute to insert.\n        void insert_attribute(xml_attribute<Ch> *where, xml_attribute<Ch> *attribute)\n        {\n            assert(!where || where->parent() == this);\n            assert(attribute && !attribute->parent());\n            dirty_parent();\n            if (where == m_first_attribute)\n                prepend_attribute(attribute);\n            else if (!where)\n                append_attribute(attribute);\n            else\n            {\n                attribute->m_prev_attribute = where->m_prev_attribute;\n                attribute->m_next_attribute = where;\n                where->m_prev_attribute->m_next_attribute = attribute;\n                where->m_prev_attribute = attribute;\n                attribute->m_parent = this;\n            }\n        }\n\n        //! Removes first attribute of the node.\n        //! If node has no attributes, behaviour is undefined.\n        //! Use first_attribute() to test if node has attributes.\n        void remove_first_attribute()\n        {\n            assert(first_attribute());\n            dirty_parent();\n            xml_attribute<Ch> *attribute = m_first_attribute;\n            if (attribute->m_next_attribute)\n            {\n                attribute->m_next_attribute->m_prev_attribute = 0;\n            }\n            else\n                m_last_attribute = nullptr;\n            attribute->m_parent = nullptr;\n            m_first_attribute = attribute->m_next_attribute;\n        }\n\n        //! Removes last attribute of the node.\n        //! If node has no attributes, behaviour is undefined.\n        //! Use first_attribute() to test if node has attributes.\n        void remove_last_attribute()\n        {\n            assert(first_attribute());\n            dirty_parent();\n            xml_attribute<Ch> *attribute = m_last_attribute;\n            if (attribute->m_prev_attribute)\n            {\n                attribute->m_prev_attribute->m_next_attribute = 0;\n                m_last_attribute = attribute->m_prev_attribute;\n            }\n            else\n                m_first_attribute = nullptr;\n            attribute->m_parent = nullptr;\n        }\n\n        //! Removes specified attribute from node.\n        //! \\param where Pointer to attribute to be removed.\n        void remove_attribute(optional_ptr<xml_attribute<Ch>> where)\n        {\n            assert(first_attribute() && where->parent() == this);\n            dirty_parent();\n            if (where == m_first_attribute)\n                remove_first_attribute();\n            else if (where == m_last_attribute)\n                remove_last_attribute();\n            else\n            {\n                where->m_prev_attribute->m_next_attribute = where->m_next_attribute;\n                where->m_next_attribute->m_prev_attribute = where->m_prev_attribute;\n                where->m_parent = nullptr;\n            }\n        }\n\n        //! Removes all attributes of node.\n        void remove_all_attributes()\n        {\n            if (!m_first_attribute) return;\n            dirty_parent();\n            for (xml_attribute<Ch> *attribute = m_first_attribute; attribute; attribute = attribute->m_next_attribute) {\n                attribute->m_parent = nullptr;\n            }\n            m_first_attribute = nullptr;\n        }\n\n        void validate() const\n        {\n            this->xmlns();\n            for (auto child = this->first_node();\n                 child;\n                 child = child->next_sibling()) {\n                child->validate();\n            }\n            for (auto attribute = first_attribute();\n                 attribute;\n                 attribute = attribute->m_next_attribute) {\n                attribute->xmlns();\n                for (auto otherattr = first_attribute();\n                     otherattr != attribute;\n                     otherattr = otherattr->m_next_attribute) {\n                    if (attribute->name() == otherattr->name()) {\n                        throw duplicate_attribute(\"Attribute doubled\");\n                    }\n                    if ((attribute->local_name() == otherattr->local_name())\n                        && (attribute->xmlns() == otherattr->xmlns()))\n                        throw duplicate_attribute(\"Attribute XMLNS doubled\");\n                }\n            }\n        }\n\n    private:\n\n        ///////////////////////////////////////////////////////////////////////////\n        // Restrictions\n\n        // No copying\n        xml_node(const xml_node &) = delete;\n        void operator =(const xml_node &) = delete;\n\n        ///////////////////////////////////////////////////////////////////////////\n        // Data members\n\n        // Note that some of the pointers below have UNDEFINED values if certain other pointers are 0.\n        // This is required for maximum performance, as it allows the parser to omit initialization of\n        // unneded/redundant values.\n        //\n        // The rules are as follows:\n        // 1. first_node and first_attribute contain valid pointers, or 0 if node has no children/attributes respectively\n        // 2. last_node and last_attribute are valid only if node has at least one child/attribute respectively, otherwise they contain garbage\n        // 3. prev_sibling and next_sibling are valid only if node has a parent, otherwise they contain garbage\n\n        view_type m_prefix;\n        mutable std::optional<view_type> m_xmlns; // Cache\n        node_type m_type;                       // Type of node; always valid\n        xml_node<Ch> *m_first_node = nullptr;             // Pointer to first child node, or 0 if none; always valid\n        xml_node<Ch> *m_last_node = nullptr;              // Pointer to last child node, or 0 if none; this value is only valid if m_first_node is non-zero\n        xml_attribute<Ch> *m_first_attribute = nullptr;   // Pointer to first attribute of node, or 0 if none; always valid\n        xml_attribute<Ch> *m_last_attribute = nullptr;    // Pointer to last attribute of node, or 0 if none; this value is only valid if m_first_attribute is non-zero\n        xml_node<Ch> *m_prev_sibling = nullptr;           // Pointer to previous sibling of node, or 0 if none; this value is only valid if m_parent is non-zero\n        xml_node<Ch> *m_next_sibling = nullptr;           // Pointer to next sibling of node, or 0 if none; this value is only valid if m_parent is non-zero\n        view_type m_contents;                   // Pointer to original contents in buffer.\n        bool m_clean = false; // Unchanged since parsing (ie, contents are good).\n        mutable std::optional<view_type> m_value;\n    };\n\n    ///////////////////////////////////////////////////////////////////////////\n    // XML document\n\n    //! This class represents root of the DOM hierarchy.\n    //! It is also an xml_node and a memory_pool through public inheritance.\n    //! Use parse() function to build a DOM tree from a zero-terminated XML text string.\n    //! parse() function allocates memory for nodes and attributes by using functions of xml_document,\n    //! which are inherited from memory_pool.\n    //! To access root node of the document, use the document itself, as if it was an xml_node.\n    //! \\param Ch Character type to use.\n    template<class Ch = char>\n    class xml_document: public xml_node<Ch>, public memory_pool<Ch>\n    {\n    public:\n        using view_type = std::basic_string_view<Ch>;\n        using ptr = optional_ptr<xml_document<Ch>>;\n\n        //! Constructs empty XML document\n        xml_document()\n            : xml_node<Ch>(node_document)\n        {\n        }\n\n        //! Parses zero-terminated XML string according to given flags.\n        //! Passed string will be modified by the parser, unless rapidxml::parse_non_destructive flag is used.\n        //! The string must persist for the lifetime of the document.\n        //! In case of error, rapidxml::parse_error exception will be thrown.\n        //! <br><br>\n        //! If you want to parse contents of a file, you must first load the file into the memory, and pass pointer to its beginning.\n        //! Make sure that data is zero-terminated.\n        //! <br><br>\n        //! Document can be parsed into multiple times.\n        //! Each new call to parse removes previous nodes and attributes (if any), but does not clear memory pool.\n        //! \\param text XML data to parse; pointer is non-const to denote fact that this data may be modified by the parser.\n        template<int Flags>\n        auto parse(const Ch * text, xml_document<Ch> * parent = nullptr) {\n            return this->parse_low<Flags>(text, parent);\n        }\n\n        template<int Flags>\n        auto parse(std::basic_string<Ch> const & str, xml_document<Ch> * parent = nullptr) {\n            return this->parse_low<Flags>(str.c_str(), parent);\n        }\n\n        template<int Flags, typename C>\n        requires std::is_same_v<Ch, typename C::value_type>\n        auto parse(C const & container, xml_document<Ch> * parent = nullptr) {\n            return this->parse_low<Flags>(buffer_ptr<C>(container), parent);\n        }\n\n        template<int Flags, typename T>\n        T parse_low(T text, xml_document<Ch> * parent) {\n            this->m_parse_flags = Flags;\n\n            // Remove current contents\n            this->remove_all_nodes();\n            this->remove_all_attributes();\n            this->m_parent = parent ? parent->first_node().get() : nullptr;\n\n            // Parse BOM, if any\n            parse_bom<Flags>(text);\n\n            // Parse children\n            while (true)\n            {\n                // Skip whitespace before node\n                skip<whitespace_pred, Flags>(text);\n                if (*text == 0)\n                    break;\n\n                // Parse and append new child\n                if (*text == Ch('<'))\n                {\n                    ++text;     // Skip '<'\n                    if (xml_node<Ch> *node = parse_node<Flags>(text)) {\n                        this->append_node(node);\n                        if (Flags & (parse_open_only|parse_parse_one) && node->type() == node_element) {\n                            break;\n                        }\n                    }\n                }\n                else\n                    FLXML_PARSE_ERROR(\"expected <\", text);\n            }\n            if (!this->first_node()) FLXML_PARSE_ERROR(\"no root element\", text);\n            return text;\n        }\n\n        //! Clears the document by deleting all nodes and clearing the memory pool.\n        //! All nodes owned by document pool are destroyed.\n        void clear()\n        {\n            this->remove_all_nodes();\n            this->remove_all_attributes();\n            memory_pool<Ch>::clear();\n        }\n\n        template<int Flags>\n        view_type decode_data_value_low(view_type const & v) {\n            buffer_ptr first{v};\n            if (Flags & parse_normalize_whitespace) {\n                skip<text_pure_with_ws_pred,0>(first);\n            } else {\n                skip<text_pure_no_ws_pred,0>(first);\n            }\n            if (!*first) return v;\n            auto buf = this->allocate_string(v);\n            auto * start = buf.data();\n            buffer_ptr tmp{buf};\n            auto end = (Flags & parse_normalize_whitespace) ?\n                    skip_and_expand_character_refs<text_pred,text_pure_with_ws_pred,Flags>(tmp) :\n                    skip_and_expand_character_refs<text_pred,text_pure_no_ws_pred,Flags>(tmp);\n            // Trim trailing whitespace if flag is set; leading was already trimmed by whitespace skip after >\n            if (Flags & parse_trim_whitespace)\n            {\n                if (Flags & parse_normalize_whitespace)\n                {\n                    // Whitespace is already condensed to single space characters by skipping function, so just trim 1 char off the end\n                    if (*(end - 1) == Ch(' '))\n                        --end;\n                }\n                else\n                {\n                    // Backup until non-whitespace character is found\n                    while (whitespace_pred::test(*(end - 1)))\n                        --end;\n                }\n            }\n\n            return {start, end};\n        }\n\n        template<Ch Q>\n        view_type decode_attr_value_low(view_type const & v) {\n            buffer_ptr first{v};\n            skip<attribute_value_pure_pred<Q>,0>(first);\n            if (!*first || *first == Q) return v;\n            auto buf = this->allocate_string(v);\n            const Ch * start = buf.data();\n            buffer_ptr tmp{buf};\n            const Ch * end = skip_and_expand_character_refs<attribute_value_pred<Q>,attribute_value_pure_pred<Q>,0>(tmp);\n            return {start, end};\n        }\n\n        view_type decode_attr_value(const xml_attribute<Ch> * attr) {\n            if (attr->quote() == Ch('\"')) {\n                return decode_attr_value_low<'\"'>(attr->value_raw());\n            } else if (attr->quote() == Ch('\\'')){\n                return decode_attr_value_low<'\\''>(attr->value_raw());\n            } else {\n                return attr->value_raw();\n            }\n        }\n\n        view_type decode_data_value(const xml_node<Ch> * node) {\n            if (node->value_raw().empty()) return node->value_raw();\n            if (m_parse_flags & parse_normalize_whitespace) {\n                if (m_parse_flags & parse_trim_whitespace) {\n                    const int Flags = parse_normalize_whitespace | parse_trim_whitespace;\n                    return decode_data_value_low<Flags>(node->value_raw());\n                } else {\n                    const int Flags = parse_normalize_whitespace;\n                    return decode_data_value_low<Flags>(node->value_raw());\n                }\n            } else {\n                if (m_parse_flags & parse_trim_whitespace) {\n                    const int Flags = parse_trim_whitespace;\n                    return decode_data_value_low<Flags>(node->value_raw());\n                } else {\n                    const int Flags = 0;\n                    return decode_data_value_low<Flags>(node->value_raw());\n                }\n            }\n        }\n\n        void validate() const\n        {\n            for (auto child = this->first_node();\n                 child;\n                 child = child->next_sibling()) {\n                child->validate();\n            }\n        }\n\n#ifndef RAPIDXML_TESTING\n    private:\n#endif\n\n        ///////////////////////////////////////////////////////////////////////\n        // Internal character utility functions\n\n        // Detect whitespace character\n        struct whitespace_pred\n        {\n            static unsigned char test(Ch ch)\n            {\n                return internal::lookup_tables::lookup_whitespace[static_cast<unsigned char>(ch)];\n            }\n        };\n\n        // Detect node name character\n        struct node_name_pred\n        {\n            static unsigned char test(Ch ch)\n            {\n                return internal::lookup_tables::lookup_node_name[static_cast<unsigned char>(ch)];\n            }\n        };\n\n        // Detect element name character\n        struct element_name_pred\n        {\n            static unsigned char test(Ch ch)\n            {\n                return internal::lookup_tables::lookup_element_name[static_cast<unsigned char>(ch)];\n            }\n        };\n\n        // Detect attribute name character\n        struct attribute_name_pred\n        {\n            static unsigned char test(Ch ch)\n            {\n                return internal::lookup_tables::lookup_attribute_name[static_cast<unsigned char>(ch)];\n            }\n        };\n\n        // Detect text character (PCDATA)\n        struct text_pred\n        {\n            static unsigned char test(Ch ch)\n            {\n                return internal::lookup_tables::lookup_text[static_cast<unsigned char>(ch)];\n            }\n        };\n\n        // Detect text character (PCDATA) that does not require processing\n        struct text_pure_no_ws_pred\n        {\n            static unsigned char test(Ch ch)\n            {\n                return internal::lookup_tables::lookup_text_pure_no_ws[static_cast<unsigned char>(ch)];\n            }\n        };\n\n        // Detect text character (PCDATA) that does not require processing\n        struct text_pure_with_ws_pred\n        {\n            static unsigned char test(Ch ch)\n            {\n                return internal::lookup_tables::lookup_text_pure_with_ws[static_cast<unsigned char>(ch)];\n            }\n        };\n\n        // Detect attribute value character\n        template<Ch Quote>\n        struct attribute_value_pred\n        {\n            static unsigned char test(Ch ch)\n            {\n                if (Quote == Ch('\\''))\n                    return internal::lookup_tables::lookup_attribute_data_1[static_cast<unsigned char>(ch)];\n                if (Quote == Ch('\\\"'))\n                    return internal::lookup_tables::lookup_attribute_data_2[static_cast<unsigned char>(ch)];\n                return 0;       // Should never be executed, to avoid warnings on Comeau\n            }\n        };\n\n        // Detect attribute value character\n        template<Ch Quote>\n        struct attribute_value_pure_pred\n        {\n            static unsigned char test(Ch ch)\n            {\n                if (Quote == Ch('\\''))\n                    return internal::lookup_tables::lookup_attribute_data_1_pure[static_cast<unsigned char>(ch)];\n                if (Quote == Ch('\\\"'))\n                    return internal::lookup_tables::lookup_attribute_data_2_pure[static_cast<unsigned char>(ch)];\n                return 0;       // Should never be executed, to avoid warnings on Comeau\n            }\n        };\n\n        // Insert coded character, using UTF8 or 8-bit ASCII\n        template<int Flags>\n        static void insert_coded_character(Ch *&text, unsigned long code)\n        {\n            if (Flags & parse_no_utf8)\n            {\n                // Insert 8-bit ASCII character\n                // Todo: possibly verify that code is less than 256 and use replacement char otherwise?\n                text[0] = static_cast<unsigned char>(code);\n                text += 1;\n            }\n            else\n            {\n                // Insert UTF8 sequence\n                if (code < 0x80)    // 1 byte sequence\n                {\n\t                text[0] = static_cast<unsigned char>(code);\n                    text += 1;\n                }\n                else if (code < 0x800)  // 2 byte sequence\n                {\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\n\t                text[0] = static_cast<unsigned char>(code | 0xC0);\n                    text += 2;\n                }\n\t            else if (code < 0x10000)    // 3 byte sequence\n                {\n\t                text[2] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\n\t                text[0] = static_cast<unsigned char>(code | 0xE0);\n                    text += 3;\n                }\n\t            else if (code < 0x110000)   // 4 byte sequence\n                {\n\t                text[3] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\n\t                text[2] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\n\t                text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;\n\t                text[0] = static_cast<unsigned char>(code | 0xF0);\n                    text += 4;\n                }\n                else    // Invalid, only codes up to 0x10FFFF are allowed in Unicode\n                {\n                    FLXML_PARSE_ERROR(\"invalid numeric character entity\", text);\n                }\n            }\n        }\n\n        // Skip characters until predicate evaluates to true\n        template<class StopPred, int Flags,  typename Chp>\n        static void skip(Chp & b)\n        {\n            while (StopPred::test(*b))\n                ++b;\n        }\n\n        // Skip characters until predicate evaluates to true while doing the following:\n        // - replacing XML character entity references with proper characters (&apos; &amp; &quot; &lt; &gt; &#...;)\n        // - condensing whitespace sequences to single space character\n        template<class StopPred, class StopPredPure, int Flags, typename Chp>\n        static const Ch *skip_and_expand_character_refs(Chp text)\n        {\n            // If entity translation, whitespace condense and whitespace trimming is disabled, use plain skip\n            if (Flags & parse_no_entity_translation &&\n                !(Flags & parse_normalize_whitespace) &&\n                !(Flags & parse_trim_whitespace))\n            {\n                skip<StopPred, Flags>(text);\n                return &*text;\n            }\n\n            // Use simple skip until first modification is detected\n            skip<StopPredPure, Flags>(text);\n\n            // Use translation skip\n            Chp src = text;\n            Ch * dest = const_cast<Ch *>(&*src);\n            while (StopPred::test(*src))\n            {\n                // If entity translation is enabled\n                if (!(Flags & parse_no_entity_translation))\n                {\n                    // Test if replacement is needed\n                    if (src[0] == Ch('&'))\n                    {\n                        switch (src[1])\n                        {\n\n                        // &amp; &apos;\n                        case Ch('a'):\n                            if (src[2] == Ch('m') && src[3] == Ch('p') && src[4] == Ch(';'))\n                            {\n                                *dest = Ch('&');\n                                ++dest;\n                                src += 5;\n                                continue;\n                            }\n                            if (src[2] == Ch('p') && src[3] == Ch('o') && src[4] == Ch('s') && src[5] == Ch(';'))\n                            {\n                                *dest = Ch('\\'');\n                                ++dest;\n                                src += 6;\n                                continue;\n                            }\n                            break;\n\n                        // &quot;\n                        case Ch('q'):\n                            if (src[2] == Ch('u') && src[3] == Ch('o') && src[4] == Ch('t') && src[5] == Ch(';'))\n                            {\n                                *dest = Ch('\"');\n                                ++dest;\n                                src += 6;\n                                continue;\n                            }\n                            break;\n\n                        // &gt;\n                        case Ch('g'):\n                            if (src[2] == Ch('t') && src[3] == Ch(';'))\n                            {\n                                *dest = Ch('>');\n                                ++dest;\n                                src += 4;\n                                continue;\n                            }\n                            break;\n\n                        // &lt;\n                        case Ch('l'):\n                            if (src[2] == Ch('t') && src[3] == Ch(';'))\n                            {\n                                *dest = Ch('<');\n                                ++dest;\n                                src += 4;\n                                continue;\n                            }\n                            break;\n\n                        // &#...; - assumes ASCII\n                        case Ch('#'):\n                            if (src[2] == Ch('x'))\n                            {\n                                unsigned long code = 0;\n                                src += 3;   // Skip &#x\n                                while (true)\n                                {\n                                    unsigned char digit = internal::lookup_tables::lookup_digits[static_cast<unsigned char>(*src)];\n                                    if (digit == 0xFF)\n                                        break;\n                                    code = code * 16 + digit;\n                                    ++src;\n                                }\n                                insert_coded_character<Flags>(dest, code);    // Put character in output\n                            }\n                            else\n                            {\n                                unsigned long code = 0;\n                                src += 2;   // Skip &#\n                                while (true)\n                                {\n                                    unsigned char digit = internal::lookup_tables::lookup_digits[static_cast<unsigned char>(*src)];\n                                    if (digit == 0xFF)\n                                        break;\n                                    code = code * 10 + digit;\n                                    ++src;\n                                }\n                                insert_coded_character<Flags>(dest, code);    // Put character in output\n                            }\n                            if (*src == Ch(';'))\n                                ++src;\n                            else\n                                FLXML_PARSE_ERROR(\"expected ;\", src);\n                            continue;\n\n                        // Something else\n                        default:\n                            // Ignore, just copy '&' verbatim\n                            break;\n\n                        }\n                    }\n                }\n\n                // If whitespace condensing is enabled\n                if (Flags & parse_normalize_whitespace && whitespace_pred::test(*src)) {\n                    *dest = Ch(' '); ++dest;    // Put single space in dest\n                    ++src;                      // Skip first whitespace char\n                    // Skip remaining whitespace chars\n                    while (whitespace_pred::test(*src))\n                        ++src;\n                    continue;\n                }\n\n                // No replacement, only copy character\n                *dest++ = *src++;\n\n            }\n\n            // Return new end\n            return dest;\n        }\n\n        ///////////////////////////////////////////////////////////////////////\n        // Internal parsing functions\n\n        // Parse BOM, if any\n        template<int Flags, typename Chp>\n        void parse_bom(Chp &texta)\n        {\n            Chp text = texta;\n            // UTF-8?\n            if (static_cast<unsigned char>(*text++) == 0xEF &&\n                static_cast<unsigned char>(*text++) == 0xBB &&\n                static_cast<unsigned char>(*text++) == 0xBF)\n            {\n                texta = text;      // Skup utf-8 bom\n            }\n        }\n\n        // Parse XML declaration (<?xml...)\n        template<int Flags, typename Chp>\n        xml_node<Ch> *parse_xml_declaration(Chp &text)\n        {\n            // If parsing of declaration is disabled\n            if (!(Flags & parse_declaration_node))\n            {\n                // Skip until end of declaration\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\n                {\n                    if (!text[0]) FLXML_PARSE_ERROR(\"unexpected end of data\", text);\n                    ++text;\n                }\n                text += 2;    // Skip '?>'\n                return 0;\n            }\n\n            // Create declaration\n            xml_node<Ch> *declaration = this->allocate_node(node_declaration);\n\n            // Skip whitespace before attributes or ?>\n            skip<whitespace_pred, Flags>(text);\n\n            // Parse declaration attributes\n            parse_node_attributes<Flags>(text, declaration);\n\n            // Skip ?>\n            if (text[0] != Ch('?') || text[1] != Ch('>')) FLXML_PARSE_ERROR(\"expected ?>\", text);\n            text += 2;\n\n            return declaration;\n        }\n\n        // Parse XML comment (<!--...)\n        template<int Flags, typename Chp>\n        xml_node<Ch> *parse_comment(Chp &text)\n        {\n            // If parsing of comments is disabled\n            if (!(Flags & parse_comment_nodes))\n            {\n                // Skip until end of comment\n                while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))\n                {\n                    if (!text[0]) FLXML_PARSE_ERROR(\"unexpected end of data\", text);\n                    ++text;\n                }\n                text += 3;     // Skip '-->'\n                return 0;      // Do not produce comment node\n            }\n\n            // Remember value start\n            Chp value = text;\n\n            // Skip until end of comment\n            while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))\n            {\n                if (!text[0]) FLXML_PARSE_ERROR(\"unexpected end of data\", text);\n                ++text;\n            }\n\n            // Create comment node\n            xml_node<Ch> *comment = this->allocate_node(node_comment);\n            comment->value({value, text});\n\n            text += 3;     // Skip '-->'\n            return comment;\n        }\n\n        // Parse DOCTYPE\n        template<int Flags, typename Chp>\n        xml_node<Ch> *parse_doctype(Chp &text)\n        {\n            // Remember value start\n            Chp value = text;\n\n            // Skip to >\n            while (*text != Ch('>'))\n            {\n                // Determine character type\n                switch (*text)\n                {\n\n                // If '[' encountered, scan for matching ending ']' using naive algorithm with depth\n                // This works for all W3C test files except for 2 most wicked\n                case Ch('['):\n                {\n                    ++text;     // Skip '['\n                    int depth = 1;\n                    while (depth > 0)\n                    {\n                        switch (*text)\n                        {\n                            case Ch('['): ++depth; break;\n                            case Ch(']'): --depth; break;\n                            case 0: FLXML_PARSE_ERROR(\"unexpected end of data\", text);\n                            default: break;\n                        }\n                        ++text;\n                    }\n                    break;\n                }\n\n                // Error on end of text\n                case Ch('\\0'):\n                    FLXML_PARSE_ERROR(\"unexpected end of data\", text);\n\n                // Other character, skip it\n                default:\n                    ++text;\n\n                }\n            }\n\n            // If DOCTYPE nodes enabled\n            if (Flags & parse_doctype_node)\n            {\n                // Create a new doctype node\n                xml_node<Ch> *doctype = this->allocate_node(node_doctype);\n                doctype->value({value, text});\n\n                text += 1;      // skip '>'\n                return doctype;\n            }\n            else\n            {\n                text += 1;      // skip '>'\n                return 0;\n            }\n\n        }\n\n        // Parse PI\n        template<int Flags, typename Chp>\n        xml_node<Ch> *parse_pi(Chp &text)\n        {\n            // If creation of PI nodes is enabled\n            if (Flags & parse_pi_nodes)\n            {\n                // Create pi node\n                xml_node<Ch> *pi = this->allocate_node(node_pi);\n\n                // Extract PI target name\n                Chp name = text;\n                skip<node_name_pred, Flags>(text);\n                if (text == name) FLXML_PARSE_ERROR(\"expected PI target\", text);\n                pi->name({name, text});\n\n                // Skip whitespace between pi target and pi\n                skip<whitespace_pred, Flags>(text);\n\n                // Remember start of pi\n                Chp value = text;\n\n                // Skip to '?>'\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\n                {\n                    if (*text == Ch('\\0'))\n                        FLXML_PARSE_ERROR(\"unexpected end of data\", text);\n                    ++text;\n                }\n\n                // Set pi value (verbatim, no entity expansion or whitespace normalization)\n                pi->value({value, text});\n\n                text += 2;                          // Skip '?>'\n                return pi;\n            }\n            else\n            {\n                // Skip to '?>'\n                while (text[0] != Ch('?') || text[1] != Ch('>'))\n                {\n                    if (*text == Ch('\\0'))\n                        FLXML_PARSE_ERROR(\"unexpected end of data\", text);\n                    ++text;\n                }\n                text += 2;    // Skip '?>'\n                return 0;\n            }\n        }\n\n        // Parse and append data\n        // Return character that ends data.\n        // This is necessary because this character might have been overwritten by a terminating 0\n        template<int Flags, typename Chp>\n        Ch parse_and_append_data(xml_node<Ch> *node, Chp &text, Chp contents_start)\n        {\n            // Backup to contents start if whitespace trimming is disabled\n            if (!(Flags & parse_trim_whitespace))\n                text = contents_start;\n\n            // Skip until end of data. We should check if the contents will need decoding.\n            Chp value = text;\n            bool encoded = false;\n            skip<text_pure_no_ws_pred,0>(text);\n            if (text_pred::test(*text)) {\n                encoded = true;\n                skip<text_pred,0>(text);\n            }\n\n            // If characters are still left between end and value (this test is only necessary if normalization is enabled)\n            // Create new data node\n            if (!(Flags & parse_no_data_nodes))\n            {\n                xml_node<Ch> *data = this->allocate_node(node_data);\n                data->value_raw({value, text});\n                if (!encoded) data->value(data->value_raw());\n                node->append_node(data);\n            }\n\n            // Add data to parent node if no data exists yet\n            if (!(Flags & parse_no_element_values)) {\n                if (node->value_raw().empty()) {\n                    node->value_raw({value, text});\n                    if (!encoded) node->value(node->value_raw());\n                }\n            }\n\n            // Return character that ends data\n            return *text;\n        }\n\n        // Parse CDATA\n        template<int Flags, typename Chp>\n        xml_node<Ch> *parse_cdata(Chp &text)\n        {\n            // If CDATA is disabled\n            if (Flags & parse_no_data_nodes)\n            {\n                // Skip until end of cdata\n                while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))\n                {\n                    if (!text[0])\n                        FLXML_PARSE_ERROR(\"unexpected end of data\", text);\n                    ++text;\n                }\n                text += 3;      // Skip ]]>\n                return 0;       // Do not produce CDATA node\n            }\n\n            // Skip until end of cdata\n            Chp value = text;\n            while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))\n            {\n                if (!text[0])\n                    FLXML_PARSE_ERROR(\"unexpected end of data\", text);\n                ++text;\n            }\n\n            // Create new cdata node\n            xml_node<Ch> *cdata = this->allocate_node(node_cdata);\n            cdata->value({value, text});\n\n            text += 3;      // Skip ]]>\n            return cdata;\n        }\n\n        // Parse element node\n        template<int Flags, typename Chp>\n        xml_node<Ch> *parse_element(Chp &text)\n        {\n            // Create element node\n            xml_node<Ch> *element = this->allocate_node(node_element);\n\n            // Extract element name\n            Chp prefix = text;\n            view_type qname;\n            skip<element_name_pred, Flags>(text);\n            if (text == prefix)\n                FLXML_PARSE_ERROR(\"expected element name or prefix\", text);\n            if (*text == Ch(':')) {\n                element->prefix({prefix, text});\n                ++text;\n                Chp name = text;\n                skip<node_name_pred, Flags>(text);\n                if (text == name)\n                    FLXML_PARSE_ERROR(\"expected element local name\", text);\n                element->name({name, text});\n            } else {\n                element->name({prefix, text});\n            }\n            qname = {prefix, text};\n\n            // Skip whitespace between element name and attributes or >\n            skip<whitespace_pred, Flags>(text);\n\n            // Parse attributes, if any\n            parse_node_attributes<Flags>(text, element);\n            // Once we have all the attributes, we should be able to fully validate:\n            if (Flags & parse_validate_xmlns) this->validate();\n\n            // Determine ending type\n            if (*text == Ch('>'))\n            {\n                Chp contents = ++text;\n                Chp contents_end = contents;\n                if (!(Flags & parse_open_only))\n                    contents_end = parse_node_contents<Flags>(text, element, qname);\n                if (contents != contents_end) element->contents({contents, contents_end});\n            }\n            else if (*text == Ch('/'))\n            {\n                ++text;\n                if (*text != Ch('>'))\n                    FLXML_PARSE_ERROR(\"expected >\", text);\n                ++text;\n                if (Flags & parse_open_only)\n                    FLXML_PARSE_ERROR(\"open_only, but closed\", text);\n            }\n            else\n                FLXML_PARSE_ERROR(\"expected >\", text);\n\n            // Return parsed element\n            return element;\n        }\n\n        // Determine node type, and parse it\n        template<int Flags, typename Chp>\n        xml_node<Ch> *parse_node(Chp &text)\n        {\n            // Parse proper node type\n            switch (text[0])\n            {\n\n            // <...\n            default:\n                // Parse and append element node\n                return parse_element<Flags>(text);\n\n            // <?...\n            case Ch('?'):\n                ++text;     // Skip ?\n                if ((text[0] == Ch('x') || text[0] == Ch('X')) &&\n                    (text[1] == Ch('m') || text[1] == Ch('M')) &&\n                    (text[2] == Ch('l') || text[2] == Ch('L')) &&\n                    whitespace_pred::test(text[3]))\n                {\n                    // '<?xml ' - xml declaration\n                    text += 4;      // Skip 'xml '\n                    return parse_xml_declaration<Flags>(text);\n                }\n                else\n                {\n                    // Parse PI\n                    return parse_pi<Flags>(text);\n                }\n\n            // <!...\n            case Ch('!'):\n\n                // Parse proper subset of <! node\n                switch (text[1])\n                {\n\n                // <!-\n                case Ch('-'):\n                    if (text[2] == Ch('-'))\n                    {\n                        // '<!--' - xml comment\n                        text += 3;     // Skip '!--'\n                        return parse_comment<Flags>(text);\n                    }\n                    break;\n\n                // <![\n                case Ch('['):\n                    if (text[2] == Ch('C') && text[3] == Ch('D') && text[4] == Ch('A') &&\n                        text[5] == Ch('T') && text[6] == Ch('A') && text[7] == Ch('['))\n                    {\n                        // '<![CDATA[' - cdata\n                        text += 8;     // Skip '![CDATA['\n                        return parse_cdata<Flags>(text);\n                    }\n                    break;\n\n                // <!D\n                case Ch('D'):\n                    if (text[2] == Ch('O') && text[3] == Ch('C') && text[4] == Ch('T') &&\n                        text[5] == Ch('Y') && text[6] == Ch('P') && text[7] == Ch('E') &&\n                        whitespace_pred::test(text[8]))\n                    {\n                        // '<!DOCTYPE ' - doctype\n                        text += 9;      // skip '!DOCTYPE '\n                        return parse_doctype<Flags>(text);\n                    }\n\n                    default:\n                        break;\n                }   // switch\n\n                // Attempt to skip other, unrecognized node types starting with <!\n                ++text;     // Skip !\n                while (*text != Ch('>'))\n                {\n                    if (*text == 0)\n                        FLXML_PARSE_ERROR(\"unexpected end of data\", text);\n                    ++text;\n                }\n                ++text;     // Skip '>'\n                return 0;   // No node recognized\n\n            }\n        }\n\n        // Parse contents of the node - children, data etc.\n        // Return end pointer.\n        template<int Flags, typename Chp>\n        Chp parse_node_contents(Chp &text, xml_node<Ch> *node, view_type const & qname)\n        {\n            Chp retval;\n            // For all children and text\n            while (true)\n            {\n                // Skip whitespace between > and node contents\n                Chp contents_start = text;      // Store start of node contents before whitespace is skipped\n                skip<whitespace_pred, Flags>(text);\n                Ch next_char = *text;\n\n            // After data nodes, instead of continuing the loop, control jumps here.\n            // This is because zero termination inside parse_and_append_data() function\n            // would wreak havoc with the above code.\n            // Also, skipping whitespace after data nodes is unnecessary.\n            after_data_node:\n\n                // Determine what comes next: node closing, child node, data node, or 0?\n                switch (next_char)\n                {\n\n                // Node closing or child node\n                case Ch('<'):\n                    if (text[1] == Ch('/'))\n                    {\n                        // Node closing\n                        retval = text;\n                        text += 2;      // Skip '</'\n                        if (Flags & parse_validate_closing_tags)\n                        {\n                            // Skip and validate closing tag name\n                            Chp closing_name = text;\n                            skip<node_name_pred, Flags>(text);\n                            if (qname != view_type{closing_name, text})\n                                FLXML_PARSE_ERROR(\"invalid closing tag name\", text);\n                        }\n                        else\n                        {\n                            // No validation, just skip name\n                            skip<node_name_pred, Flags>(text);\n                        }\n                        // Skip remaining whitespace after node name\n                        skip<whitespace_pred, Flags>(text);\n                        if (*text != Ch('>'))\n                            FLXML_PARSE_ERROR(\"expected >\", text);\n                        ++text;     // Skip '>'\n                        if (Flags & parse_open_only)\n                            FLXML_PARSE_ERROR(\"Unclosed element actually closed.\", text);\n                        return retval;     // Node closed, finished parsing contents\n                    }\n                    else\n                    {\n                        // Child node\n                        ++text;     // Skip '<'\n                        if (xml_node<Ch> *child = parse_node<Flags & ~parse_open_only>(text))\n                            node->append_node(child);\n                    }\n                    break;\n\n                // End of data - error unless we expected this.\n                case Ch('\\0'):\n                    if (Flags & parse_open_only) {\n                        return Chp();\n                    } else {\n                        FLXML_PARSE_ERROR(\"unexpected end of data\", text);\n                    }\n\n                // Data node\n                default:\n                    next_char = parse_and_append_data<Flags>(node, text, contents_start);\n                    goto after_data_node;   // Bypass regular processing after data nodes\n\n                }\n            }\n        }\n\n        // Parse XML attributes of the node\n        template<int Flags, typename Chp>\n        void parse_node_attributes(Chp &text, xml_node<Ch> *node)\n        {\n            // For all attributes\n            while (attribute_name_pred::test(*text))\n            {\n                // Extract attribute name\n                Chp name = text;\n                ++text;     // Skip first character of attribute name\n                skip<attribute_name_pred, Flags>(text);\n                if (text == name)\n                    FLXML_PARSE_ERROR(\"expected attribute name\", name);\n\n                // Create new attribute\n                xml_attribute<Ch> *attribute = this->allocate_attribute(view_type{name, text});\n                node->append_attribute(attribute);\n\n                // Skip whitespace after attribute name\n                skip<whitespace_pred, Flags>(text);\n\n                // Skip =\n                if (*text != Ch('='))\n                    FLXML_PARSE_ERROR(\"expected =\", text);\n                ++text;\n\n                // Skip whitespace after =\n                skip<whitespace_pred, Flags>(text);\n\n                // Skip quote and remember if it was ' or \"\n                Ch quote = *text;\n                if (quote != Ch('\\'') && quote != Ch('\"'))\n                    FLXML_PARSE_ERROR(\"expected ' or \\\"\", text);\n                attribute->quote(quote);\n                ++text;\n\n                // Extract attribute value and expand char refs in it\n                Chp value = text;\n                Chp end;\n                const int AttFlags = Flags & ~parse_normalize_whitespace;   // No whitespace normalization in attributes\n                if (quote == Ch('\\''))\n                    skip<attribute_value_pred<Ch('\\'')>, AttFlags>(text);\n                else\n                    skip<attribute_value_pred<Ch('\"')>, AttFlags>(text);\n                end = text;\n\n                // Set attribute value\n                attribute->value_raw({value, end});\n\n                // Make sure that end quote is present\n                if (*text != quote)\n                    FLXML_PARSE_ERROR(\"expected ' or \\\"\", text);\n                ++text;     // Skip quote\n\n                // Skip whitespace after attribute value\n                skip<whitespace_pred, Flags>(text);\n            }\n        }\n    private:\n        int m_parse_flags = 0;\n    };\n\n\n}\n\n// Also include this now.\n#include <flxml/iterators.h>\n\n// Undefine internal macros\n#undef FLXML_PARSE_ERROR\n\n// On MSVC, restore warnings state\n#ifdef _MSC_VER\n    #pragma warning(pop)\n#endif\n\n#endif\n"
  },
  {
    "path": "include/rapidxml.hpp",
    "content": "//\n// Created by dwd on 4/19/25.\n//\n\n#ifndef RAPIDXML_HPP\n#define RAPIDXML_HPP\n\n#include <flxml.h>\n\nnamespace rapidxml = flxml;\n\n#endif //RAPIDXML_HPP\n"
  },
  {
    "path": "include/rapidxml_print.hpp",
    "content": "//\n// Created by dwd on 4/19/25.\n//\n\n#ifndef RAPIDXML_PRINT_HPP\n#define RAPIDXML_PRINT_HPP\n\n#include <flxml/print.h>\n\nnamespace rapidxml = flxml;\n\n#endif //RAPIDXML_PRINT_HPP\n"
  },
  {
    "path": "license.txt",
    "content": "Use of this software is granted under one of the following two licenses,\r\nto be chosen freely by the user.\r\n\r\n1. Boost Software License - Version 1.0 - August 17th, 2003\r\n===============================================================================\r\n\r\nCopyright (c) 2006, 2007 Marcin Kalicinski\r\n\r\nPermission is hereby granted, free of charge, to any person or organization\r\nobtaining a copy of the software and accompanying documentation covered by\r\nthis license (the \"Software\") to use, reproduce, display, distribute,\r\nexecute, and transmit the Software, and to prepare derivative works of the\r\nSoftware, and to permit third-parties to whom the Software is furnished to\r\ndo so, all subject to the following:\r\n\r\nThe copyright notices in the Software and this entire statement, including\r\nthe above license grant, this restriction and the following disclaimer,\r\nmust be included in all copies of the Software, in whole or in part, and\r\nall derivative works of the Software, unless such copies or derivative\r\nworks are solely in the form of machine-executable object code generated by\r\na source language processor.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT\r\nSHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE\r\nFOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,\r\nARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\r\nDEALINGS IN THE SOFTWARE.\r\n\r\n2. The MIT License\r\n===============================================================================\r\n\r\nCopyright (c) 2006, 2007 Marcin Kalicinski\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy \r\nof this software and associated documentation files (the \"Software\"), to deal \r\nin the Software without restriction, including without limitation the rights \r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies \r\nof the Software, and to permit persons to whom the Software is furnished to do so, \r\nsubject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all \r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR \r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, \r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL \r\nTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER \r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, \r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS \r\nIN THE SOFTWARE.\r\n"
  },
  {
    "path": "manual.html",
    "content": "<html><head><style type=\"text/css\">\r\n\r\n          body\r\n          {\r\n          font-family: sans-serif;\r\n          font-size: 90%;\r\n          margin: 8pt 8pt 8pt 8pt;\r\n          text-align: justify;\r\n          background-color: White;\r\n          }\r\n\r\n          h1 { font-weight: bold; text-align: left;  }\r\n          h2 { font: 140% sans-serif; font-weight: bold; text-align: left;  }\r\n          h3 { font: 120% sans-serif; font-weight: bold; text-align: left;  }\r\n          h4 { font: bold 100% sans-serif; font-weight: bold; text-align: left;  }\r\n          h5 { font: italic 100% sans-serif; font-weight: bold; text-align: left;  }\r\n          h6 { font: small-caps 100% sans-serif; font-weight: bold; text-align: left;  }\r\n\r\n          code\r\n          {\r\n          font-family: &quot;Courier New&quot;, Courier, mono;\r\n          }\r\n\r\n          pre\r\n          {\r\n          border-top: gray 0.5pt solid;\r\n          border-right: gray 0.5pt solid;\r\n          border-left: gray 0.5pt solid;\r\n          border-bottom: gray 0.5pt solid;\r\n          padding-top: 2pt;\r\n          padding-right: 2pt;\r\n          padding-left: 2pt;\r\n          padding-bottom: 2pt;\r\n          display: block;\r\n          font-family: &quot;courier new&quot;, courier, mono;\r\n          background-color: #eeeeee;\r\n          }\r\n\r\n          a\r\n          {\r\n          color: #000080;\r\n          text-decoration: none;\r\n          }\r\n\r\n          a:hover\r\n          {\r\n          text-decoration: underline;\r\n          }\r\n\r\n          .reference-header\r\n          {\r\n          border-top: gray 0.5pt solid;\r\n          border-right: gray 0.5pt solid;\r\n          border-left: gray 0.5pt solid;\r\n          border-bottom: gray 0.5pt solid;\r\n          padding-top: 2pt;\r\n          padding-right: 2pt;\r\n          padding-left: 2pt;\r\n          padding-bottom: 2pt;\r\n          background-color: #dedede;\r\n          }\r\n\r\n          .parameter-name\r\n          {\r\n          font-style: italic;\r\n          }\r\n\r\n          .indented\r\n          {\r\n          margin-left: 0.5cm;\r\n          }\r\n\r\n          a.toc1\r\n          {\r\n          margin-left: 0.0cm;\r\n          }\r\n\r\n          a.toc2\r\n          {\r\n          margin-left: 0.75cm;\r\n          }\r\n\r\n          a.toc3\r\n          {\r\n          margin-left: 1.5cm;\r\n          }\r\n\r\n        </style></head><body><h1>RAPIDXML Manual</h1><h3>Version 1.13</h3><detaileddescription xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><para><i>Copyright (C) 2006, 2009 Marcin Kalicinski</i><br/><i>See accompanying file <a href=\"license.txt\">license.txt</a> for license information.</i><hr/><h2 level=\"2\">Table of Contents</h2></para><para><toc><toc-contents><a href=\"#namespacerapidxml_1what_is_rapidxml\" class=\"toc1\">1. What is RapidXml?</a><br/><a href=\"#namespacerapidxml_1dependencies_and_compatibility\" class=\"toc2\">1.1 Dependencies And Compatibility</a><br/><a href=\"#namespacerapidxml_1character_types_and_encodings\" class=\"toc2\">1.2 Character Types And Encodings</a><br/><a href=\"#namespacerapidxml_1error_handling\" class=\"toc2\">1.3 Error Handling</a><br/><a href=\"#namespacerapidxml_1memory_allocation\" class=\"toc2\">1.4 Memory Allocation</a><br/><a href=\"#namespacerapidxml_1w3c_compliance\" class=\"toc2\">1.5 W3C Compliance</a><br/><a href=\"#namespacerapidxml_1api_design\" class=\"toc2\">1.6 API Design</a><br/><a href=\"#namespacerapidxml_1reliability\" class=\"toc2\">1.7 Reliability</a><br/><a href=\"#namespacerapidxml_1acknowledgements\" class=\"toc2\">1.8 Acknowledgements</a><br/><a href=\"#namespacerapidxml_1two_minute_tutorial\" class=\"toc1\">2. Two Minute Tutorial</a><br/><a href=\"#namespacerapidxml_1parsing\" class=\"toc2\">2.1 Parsing</a><br/><a href=\"#namespacerapidxml_1accessing_dom_tree\" class=\"toc2\">2.2 Accessing The DOM Tree</a><br/><a href=\"#namespacerapidxml_1modifying_dom_tree\" class=\"toc2\">2.3 Modifying The DOM Tree</a><br/><a href=\"#namespacerapidxml_1printing\" class=\"toc2\">2.4 Printing XML</a><br/><a href=\"#namespacerapidxml_1differences\" class=\"toc1\">3. Differences From Regular XML Parsers</a><br/><a href=\"#namespacerapidxml_1lifetime_of_source_text\" class=\"toc2\">3.1 Lifetime Of Source Text</a><br/><a href=\"#namespacerapidxml_1ownership_of_strings\" class=\"toc2\">3.2 Ownership Of Strings</a><br/><a href=\"#namespacerapidxml_1destructive_non_destructive\" class=\"toc2\">3.3 Destructive Vs Non-Destructive Mode</a><br/><a href=\"#namespacerapidxml_1performance\" class=\"toc1\">4. Performance</a><br/><a href=\"#namespacerapidxml_1performance_charts\" class=\"toc2\">4.1 Comparison With Other Parsers</a><br/><a href=\"#namespacerapidxml_1reference\" class=\"toc1\">5. Reference</a><br/></toc-contents></toc><br/></para><sect1><h2 id=\"namespacerapidxml_1what_is_rapidxml\">1. What is RapidXml?</h2><para><a href=\"http://rapidxml.sourceforge.net\">RapidXml</a> is an attempt to create the fastest XML DOM parser possible, while retaining useability, portability and reasonable W3C compatibility. It is an in-situ parser written in C++, with parsing speed approaching that of <code>strlen()</code> function executed on the same data. <br/><br/>\r\n Entire parser is contained in a single header file, so no building or linking is neccesary. To use it you just need to copy <code>rapidxml.hpp</code> file to a convenient place (such as your project directory), and include it where needed. You may also want to use printing functions contained in header <code>rapidxml_print.hpp</code>.</para><sect2><h3 id=\"namespacerapidxml_1dependencies_and_compatibility\">1.1 Dependencies And Compatibility</h3><para>RapidXml has <i>no dependencies</i> other than a very small subset of standard C++ library (<code>&lt;cassert&gt;</code>, <code>&lt;cstdlib&gt;</code>, <code>&lt;new&gt;</code> and <code>&lt;exception&gt;</code>, unless exceptions are disabled). It should compile on any reasonably conformant compiler, and was tested on Visual C++ 2003, Visual C++ 2005, Visual C++ 2008, gcc 3, gcc 4, and Comeau 4.3.3. Care was taken that no warnings are produced on these compilers, even with highest warning levels enabled.</para></sect2><sect2><h3 id=\"namespacerapidxml_1character_types_and_encodings\">1.2 Character Types And Encodings</h3><para>RapidXml is character type agnostic, and can work both with narrow and wide characters. Current version does not fully support UTF-16 or UTF-32, so use of wide characters is somewhat incapacitated. However, it should succesfully parse <code>wchar_t</code> strings containing UTF-16 or UTF-32 if endianness of the data matches that of the machine. UTF-8 is fully supported, including all numeric character references, which are expanded into appropriate UTF-8 byte sequences (unless you enable parse_no_utf8 flag). <br/><br/>\r\n Note that RapidXml performs no decoding - strings returned by name() and value() functions will contain text encoded using the same encoding as source file. Rapidxml understands and expands the following character references: <code>&amp;apos; &amp;amp; &amp;quot; &amp;lt; &amp;gt; &amp;#...;</code> Other character references are not expanded.</para></sect2><sect2><h3 id=\"namespacerapidxml_1error_handling\">1.3 Error Handling</h3><para>By default, RapidXml uses C++ exceptions to report errors. If this behaviour is undesirable, RAPIDXML_NO_EXCEPTIONS can be defined to suppress exception code. See <a href=\"#classrapidxml_1_1parse__error\" kindref=\"compound\">parse_error</a> class and <a href=\"#namespacerapidxml_ff5d67f74437199d316d2b2660653ae1_1ff5d67f74437199d316d2b2660653ae1\" kindref=\"member\">parse_error_handler()</a> function for more information.</para></sect2><sect2><h3 id=\"namespacerapidxml_1memory_allocation\">1.4 Memory Allocation</h3><para>RapidXml uses a special memory pool object to allocate nodes and attributes, because direct allocation using <code>new</code> operator would be far too slow. Underlying memory allocations performed by the pool can be customized by use of <a href=\"#classrapidxml_1_1memory__pool_c0a55a6ef0837dca67572e357100d78a_1c0a55a6ef0837dca67572e357100d78a\" kindref=\"member\">memory_pool::set_allocator()</a> function. See class <a href=\"#classrapidxml_1_1memory__pool\" kindref=\"compound\">memory_pool</a> for more information.</para></sect2><sect2><h3 id=\"namespacerapidxml_1w3c_compliance\">1.5 W3C Compliance</h3><para>RapidXml is not a W3C compliant parser, primarily because it ignores DOCTYPE declarations. There is a number of other, minor incompatibilities as well. Still, it can successfully parse and produce complete trees of all valid XML files in W3C conformance suite (over 1000 files specially designed to find flaws in XML processors). In destructive mode it performs whitespace normalization and character entity substitution for a small set of built-in entities.</para></sect2><sect2><h3 id=\"namespacerapidxml_1api_design\">1.6 API Design</h3><para>RapidXml API is minimalistic, to reduce code size as much as possible, and facilitate use in embedded environments. Additional convenience functions are provided in separate headers: <code>rapidxml_utils.hpp</code> and <code><a href=\"#rapidxml__print_8hpp\" kindref=\"compound\">rapidxml_print.hpp</a></code>. Contents of these headers is not an essential part of the library, and is currently not documented (otherwise than with comments in code).</para></sect2><sect2><h3 id=\"namespacerapidxml_1reliability\">1.7 Reliability</h3><para>RapidXml is very robust and comes with a large harness of unit tests. Special care has been taken to ensure stability of the parser no matter what source text is thrown at it. One of the unit tests produces 100,000 randomly corrupted variants of XML document, which (when uncorrupted) contains all constructs recognized by RapidXml. RapidXml passes this test when it correctly recognizes that errors have been introduced, and does not crash or loop indefinitely. <br/><br/>\r\n Another unit test puts RapidXml head-to-head with another, well estabilished XML parser, and verifies that their outputs match across a wide variety of small and large documents. <br/><br/>\r\n Yet another test feeds RapidXml with over 1000 test files from W3C compliance suite, and verifies that correct results are obtained. There are also additional tests that verify each API function separately, and test that various parsing modes work as expected.</para></sect2><sect2><h3 id=\"namespacerapidxml_1acknowledgements\">1.8 Acknowledgements</h3><para>I would like to thank Arseny Kapoulkine for his work on <a href=\"http://code.google.com/p/pugixml\">pugixml</a>, which was an inspiration for this project. Additional thanks go to Kristen Wegner for creating <a href=\"http://www.codeproject.com/soap/pugxml.asp\">pugxml</a>, from which pugixml was derived. Janusz Wohlfeil kindly ran RapidXml speed tests on hardware that I did not have access to, allowing me to expand performance comparison table.</para></sect2></sect1><sect1><h2 id=\"namespacerapidxml_1two_minute_tutorial\">2. Two Minute Tutorial</h2><sect2><h3 id=\"namespacerapidxml_1parsing\">2.1 Parsing</h3><para>The following code causes RapidXml to parse a zero-terminated string named <code>text</code>: <pre>using namespace rapidxml;\r\nxml_document&lt;&gt; doc;    // character type defaults to char\r\ndoc.parse&lt;0&gt;(text);    // 0 means default parse flags\r\n</pre><code>doc</code> object is now a root of DOM tree containing representation of the parsed XML. Because all RapidXml interface is contained inside namespace <code>rapidxml</code>, users must either bring contents of this namespace into scope, or fully qualify all the names. Class <a href=\"#classrapidxml_1_1xml__document\" kindref=\"compound\">xml_document</a> represents a root of the DOM hierarchy. By means of public inheritance, it is also an <a href=\"#classrapidxml_1_1xml__node\" kindref=\"compound\">xml_node</a> and a <a href=\"#classrapidxml_1_1memory__pool\" kindref=\"compound\">memory_pool</a>. Template parameter of <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function is used to specify parsing flags, with which you can fine-tune behaviour of the parser. Note that flags must be a compile-time constant.</para></sect2><sect2><h3 id=\"namespacerapidxml_1accessing_dom_tree\">2.2 Accessing The DOM Tree</h3><para>To access the DOM tree, use methods of <a href=\"#classrapidxml_1_1xml__node\" kindref=\"compound\">xml_node</a> and <a href=\"#classrapidxml_1_1xml__attribute\" kindref=\"compound\">xml_attribute</a> classes: <pre>cout &lt;&lt; &quot;Name of my first node is: &quot; &lt;&lt; doc.first_node()-&gt;name() &lt;&lt; &quot;\\n&quot;;\r\nxml_node&lt;&gt; *node = doc.first_node(&quot;foobar&quot;);\r\ncout &lt;&lt; &quot;Node foobar has value &quot; &lt;&lt; node-&gt;value() &lt;&lt; &quot;\\n&quot;;\r\nfor (xml_attribute&lt;&gt; *attr = node-&gt;first_attribute();\r\n     attr; attr = attr-&gt;next_attribute())\r\n{\r\n    cout &lt;&lt; &quot;Node foobar has attribute &quot; &lt;&lt; attr-&gt;name() &lt;&lt; &quot; &quot;;\r\n    cout &lt;&lt; &quot;with value &quot; &lt;&lt; attr-&gt;value() &lt;&lt; &quot;\\n&quot;;\r\n}\r\n</pre></para></sect2><sect2><h3 id=\"namespacerapidxml_1modifying_dom_tree\">2.3 Modifying The DOM Tree</h3><para>DOM tree produced by the parser is fully modifiable. Nodes and attributes can be added/removed, and their contents changed. The below example creates a HTML document, whose sole contents is a link to google.com website: <pre>xml_document&lt;&gt; doc;\r\nxml_node&lt;&gt; *node = doc.allocate_node(node_element, &quot;a&quot;, &quot;Google&quot;);\r\ndoc.append_node(node);\r\nxml_attribute&lt;&gt; *attr = doc.allocate_attribute(&quot;href&quot;, &quot;google.com&quot;);\r\nnode-&gt;append_attribute(attr);\r\n</pre> One quirk is that nodes and attributes <i>do not own</i> the text of their names and values. This is because normally they only store pointers to the source text. So, when assigning a new name or value to the node, care must be taken to ensure proper lifetime of the string. The easiest way to achieve it is to allocate the string from the <a href=\"#classrapidxml_1_1xml__document\" kindref=\"compound\">xml_document</a> memory pool. In the above example this is not necessary, because we are only assigning character constants. But the code below uses <a href=\"#classrapidxml_1_1memory__pool_69729185bc59b0875192d667c47b8859_169729185bc59b0875192d667c47b8859\" kindref=\"member\">memory_pool::allocate_string()</a> function to allocate node name (which will have the same lifetime as the document), and assigns it to a new node: <pre>xml_document&lt;&gt; doc;\r\nchar *node_name = doc.allocate_string(name);        // Allocate string and copy name into it\r\nxml_node&lt;&gt; *node = doc.allocate_node(node_element, node_name);  // Set node name to node_name\r\n</pre> Check <a href=\"#namespacerapidxml_1reference\" kindref=\"member\">Reference</a>  section for description of the entire interface.</para></sect2><sect2><h3 id=\"namespacerapidxml_1printing\">2.4 Printing XML</h3><para>You can print <code><a href=\"#classrapidxml_1_1xml__document\" kindref=\"compound\">xml_document</a></code> and <code><a href=\"#classrapidxml_1_1xml__node\" kindref=\"compound\">xml_node</a></code> objects into an XML string. Use <a href=\"#namespacerapidxml_b94d570fc4c4ab2423813cd0243326b1_1b94d570fc4c4ab2423813cd0243326b1\" kindref=\"member\">print()</a> function or operator &lt;&lt;, which are defined in <code><a href=\"#rapidxml__print_8hpp\" kindref=\"compound\">rapidxml_print.hpp</a></code> header. <pre>using namespace rapidxml;\r\nxml_document&lt;&gt; doc;    // character type defaults to char\r\n// ... some code to fill the document\r\n\r\n// Print to stream using operator &lt;&lt;\r\nstd::cout &lt;&lt; doc;   \r\n\r\n// Print to stream using print function, specifying printing flags\r\nprint(std::cout, doc, 0);   // 0 means default printing flags\r\n\r\n// Print to string using output iterator\r\nstd::string s;\r\nprint(std::back_inserter(s), doc, 0);\r\n\r\n// Print to memory buffer using output iterator\r\nchar buffer[4096];                      // You are responsible for making the buffer large enough!\r\nchar *end = print(buffer, doc, 0);      // end contains pointer to character after last printed character\r\n*end = 0;                               // Add string terminator after XML\r\n</pre></para></sect2></sect1><sect1><h2 id=\"namespacerapidxml_1differences\">3. Differences From Regular XML Parsers</h2><para>RapidXml is an <i>in-situ parser</i>, which allows it to achieve very high parsing speed. In-situ means that parser does not make copies of strings. Instead, it places pointers to the <i>source text</i> in the DOM hierarchy.</para><sect2><h3 id=\"namespacerapidxml_1lifetime_of_source_text\">3.1 Lifetime Of Source Text</h3><para>In-situ parsing requires that source text lives at least as long as the document object. If source text is destroyed, names and values of nodes in DOM tree will become destroyed as well. Additionally, whitespace processing, character entity translation, and zero-termination of strings require that source text be modified during parsing (but see non-destructive mode). This makes the text useless for further processing once it was parsed by RapidXml. <br/><br/>\r\n In many cases however, these are not serious issues.</para></sect2><sect2><h3 id=\"namespacerapidxml_1ownership_of_strings\">3.2 Ownership Of Strings</h3><para>Nodes and attributes produced by RapidXml do not own their name and value strings. They merely hold the pointers to them. This means you have to be careful when setting these values manually, by using <a href=\"#classrapidxml_1_1xml__base_e099c291e104a0d277307fe71f5e0f9e_1e099c291e104a0d277307fe71f5e0f9e\" kindref=\"member\">xml_base::name(const Ch *)</a> or <a href=\"#classrapidxml_1_1xml__base_18c7469acdca771de9b4f3054053029c_118c7469acdca771de9b4f3054053029c\" kindref=\"member\">xml_base::value(const Ch *)</a> functions. Care must be taken to ensure that lifetime of the string passed is at least as long as lifetime of the node/attribute. The easiest way to achieve it is to allocate the string from <a href=\"#classrapidxml_1_1memory__pool\" kindref=\"compound\">memory_pool</a> owned by the document. Use <a href=\"#classrapidxml_1_1memory__pool_69729185bc59b0875192d667c47b8859_169729185bc59b0875192d667c47b8859\" kindref=\"member\">memory_pool::allocate_string()</a> function for this purpose.</para></sect2><sect2><h3 id=\"namespacerapidxml_1destructive_non_destructive\">3.3 Destructive Vs Non-Destructive Mode</h3><para>By default, the parser modifies source text during the parsing process. This is required to achieve character entity translation, whitespace normalization, and zero-termination of strings. <br/><br/>\r\n In some cases this behaviour may be undesirable, for example if source text resides in read only memory, or is mapped to memory directly from file. By using appropriate parser flags (parse_non_destructive), source text modifications can be disabled. However, because RapidXml does in-situ parsing, it obviously has the following side-effects:<ul><li><para>no whitespace normalization is done</para></li><li><para>no entity reference translation is done</para></li><li><para>names and values are not zero-terminated, you must use <a href=\"#classrapidxml_1_1xml__base_0dae694c8f7e4d89f1003e2f3a15a43c_10dae694c8f7e4d89f1003e2f3a15a43c\" kindref=\"member\">xml_base::name_size()</a> and <a href=\"#classrapidxml_1_1xml__base_aed5ae791b7164c1ee5e649198cbb3db_1aed5ae791b7164c1ee5e649198cbb3db\" kindref=\"member\">xml_base::value_size()</a> functions to tell where they end</para></li></ul></para></sect2></sect1><sect1><h2 id=\"namespacerapidxml_1performance\">4. Performance</h2><para>RapidXml achieves its speed through use of several techniques:<ul><li><para>In-situ parsing. When building DOM tree, RapidXml does not make copies of string data, such as node names and values. Instead, it stores pointers to interior of the source text.</para></li><li><para>Use of template metaprogramming techniques. This allows it to move much of the work to compile time. Through magic of the templates, C++ compiler generates a separate copy of parsing code for any combination of parser flags you use. In each copy, all possible decisions are made at compile time and all unused code is omitted.</para></li><li><para>Extensive use of lookup tables for parsing.</para></li><li><para>Hand-tuned C++ with profiling done on several most popular CPUs.</para></li></ul></para><para>This results in a very small and fast code: a parser which is custom tailored to exact needs with each invocation.</para><sect2><h3 id=\"namespacerapidxml_1performance_charts\">4.1 Comparison With Other Parsers</h3><para>The table below compares speed of RapidXml to some other parsers, and to <code>strlen()</code> function executed on the same data. On a modern CPU (as of 2007), you can expect parsing throughput to be close to 1 GB/s. As a rule of thumb, parsing speed is about 50-100x faster than Xerces DOM, 30-60x faster than TinyXml, 3-12x faster than pugxml, and about 5% - 30% faster than pugixml, the fastest XML parser I know of.</para><para><ul><li><para>The test file is a real-world, 50kB large, moderately dense XML file. </para></li><li><para>All timing is done by using RDTSC instruction present in Pentium-compatible CPUs. </para></li><li><para>No profile-guided optimizations are used. </para></li><li><para>All parsers are running in their fastest modes. </para></li><li><para>The results are given in CPU cycles per character, so frequency of CPUs is irrelevant. </para></li><li><para>The results are minimum values from a large number of runs, to minimize effects of operating system activity, task switching, interrupt handling etc. </para></li><li><para>A single parse of the test file takes about 1/10th of a millisecond, so with large number of runs there is a good chance of hitting at least one no-interrupt streak, and obtaining undisturbed results. </para></li></ul><table rows=\"9\" cols=\"7\" border=\"1\" cellpadding=\"3pt\"><tr><th thead=\"yes\"><para><center>Platform</center></para></th><th thead=\"yes\"><para><center>Compiler</center></para></th><th thead=\"yes\"><para>strlen() </para></th><th thead=\"yes\"><para>RapidXml </para></th><th thead=\"yes\"><para>pugixml 0.3 </para></th><th thead=\"yes\"><para>pugxml </para></th><th thead=\"yes\"><para>TinyXml  </para></th></tr><tr><td thead=\"no\"><para><center>Pentium 4</center></para></td><td thead=\"no\"><para><center>MSVC 8.0</center></para></td><td thead=\"no\"><para><center>2.5</center></para></td><td thead=\"no\"><para><center>5.4</center></para></td><td thead=\"no\"><para><center>7.0</center></para></td><td thead=\"no\"><para><center>61.7</center></para></td><td thead=\"no\"><para><center>298.8</center></para></td></tr><tr><td thead=\"no\"><para><center>Pentium 4</center></para></td><td thead=\"no\"><para><center>gcc 4.1.1</center></para></td><td thead=\"no\"><para><center>0.8</center></para></td><td thead=\"no\"><para><center>6.1</center></para></td><td thead=\"no\"><para><center>9.5</center></para></td><td thead=\"no\"><para><center>67.0</center></para></td><td thead=\"no\"><para><center>413.2</center></para></td></tr><tr><td thead=\"no\"><para><center>Core 2</center></para></td><td thead=\"no\"><para><center>MSVC 8.0</center></para></td><td thead=\"no\"><para><center>1.0</center></para></td><td thead=\"no\"><para><center>4.5</center></para></td><td thead=\"no\"><para><center>5.0</center></para></td><td thead=\"no\"><para><center>24.6</center></para></td><td thead=\"no\"><para><center>154.8</center></para></td></tr><tr><td thead=\"no\"><para><center>Core 2</center></para></td><td thead=\"no\"><para><center>gcc 4.1.1</center></para></td><td thead=\"no\"><para><center>0.6</center></para></td><td thead=\"no\"><para><center>4.6</center></para></td><td thead=\"no\"><para><center>5.4</center></para></td><td thead=\"no\"><para><center>28.3</center></para></td><td thead=\"no\"><para><center>229.3</center></para></td></tr><tr><td thead=\"no\"><para><center>Athlon XP</center></para></td><td thead=\"no\"><para><center>MSVC 8.0</center></para></td><td thead=\"no\"><para><center>3.1</center></para></td><td thead=\"no\"><para><center>7.7</center></para></td><td thead=\"no\"><para><center>8.0</center></para></td><td thead=\"no\"><para><center>25.5</center></para></td><td thead=\"no\"><para><center>182.6</center></para></td></tr><tr><td thead=\"no\"><para><center>Athlon XP</center></para></td><td thead=\"no\"><para><center>gcc 4.1.1</center></para></td><td thead=\"no\"><para><center>0.9</center></para></td><td thead=\"no\"><para><center>8.2</center></para></td><td thead=\"no\"><para><center>9.2</center></para></td><td thead=\"no\"><para><center>33.7</center></para></td><td thead=\"no\"><para><center>265.2</center></para></td></tr><tr><td thead=\"no\"><para><center>Pentium 3</center></para></td><td thead=\"no\"><para><center>MSVC 8.0</center></para></td><td thead=\"no\"><para><center>2.0</center></para></td><td thead=\"no\"><para><center>6.3</center></para></td><td thead=\"no\"><para><center>7.0</center></para></td><td thead=\"no\"><para><center>30.9</center></para></td><td thead=\"no\"><para><center>211.9</center></para></td></tr><tr><td thead=\"no\"><para><center>Pentium 3</center></para></td><td thead=\"no\"><para><center>gcc 4.1.1</center></para></td><td thead=\"no\"><para><center>1.0</center></para></td><td thead=\"no\"><para><center>6.7</center></para></td><td thead=\"no\"><para><center>8.9</center></para></td><td thead=\"no\"><para><center>35.3</center></para></td><td thead=\"no\"><para><center>316.0</center></para></td></tr></table><i>(*) All results are in CPU cycles per character of source text</i></para></sect2></sect1><sect1><h2 id=\"namespacerapidxml_1reference\">5. Reference</h2><para>This section lists all classes, functions, constants etc. and describes them in detail. </para></sect1></detaileddescription><dl><dt>class\r\n\t\t\t\t\t\t\t\t  template\r\n\t\t\t\t\t\t\t   <a href=\"#classrapidxml_1_1memory__pool\">rapidxml::memory_pool</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstructor\r\n\t\t\t <a href=\"#classrapidxml_1_1memory__pool_f8fb3c8f1a564f8045c40bcd07a89866_1f8fb3c8f1a564f8045c40bcd07a89866\">memory_pool()</a></dt><dt class=\"indented\">\r\n\t\t\t\tdestructor\r\n\t\t\t <a href=\"#classrapidxml_1_1memory__pool_6f8c7990d9ec1ed2acf6558b238570eb_16f8c7990d9ec1ed2acf6558b238570eb\">~memory_pool()</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1memory__pool_750ba3c610b129ac057d817509d08f41_1750ba3c610b129ac057d817509d08f41\">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)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1memory__pool_462de142669e0ff649e8e615b82bf457_1462de142669e0ff649e8e615b82bf457\">allocate_attribute(const Ch *name=0, const Ch *value=0, std::size_t name_size=0, std::size_t value_size=0)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1memory__pool_69729185bc59b0875192d667c47b8859_169729185bc59b0875192d667c47b8859\">allocate_string(const Ch *source=0, std::size_t size=0)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1memory__pool_95c49fcb056e9103ec906a59e3e01d76_195c49fcb056e9103ec906a59e3e01d76\">clone_node(const xml_node&lt; Ch &gt; *source, xml_node&lt; Ch &gt; *result=0)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1memory__pool_c8bb3912a3ce86b15842e79d0b421204_1c8bb3912a3ce86b15842e79d0b421204\">clear()</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1memory__pool_c0a55a6ef0837dca67572e357100d78a_1c0a55a6ef0837dca67572e357100d78a\">set_allocator(alloc_func *af, free_func *ff)</a></dt><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><p/><p/><dt>class <a href=\"#classrapidxml_1_1parse__error\">rapidxml::parse_error</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstructor\r\n\t\t\t <a href=\"#classrapidxml_1_1parse__error_4dd8d1bdbd9221df4dcb90cafaee3332_14dd8d1bdbd9221df4dcb90cafaee3332\">parse_error(const char *what, void *where)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1parse__error_ff06f49065b54a8a86e02e9a2441a8ba_1ff06f49065b54a8a86e02e9a2441a8ba\">what() const </a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1parse__error_377be7d201d95221c318682c35377aca_1377be7d201d95221c318682c35377aca\">where() const </a></dt><dt class=\"indented\"/><dt class=\"indented\"/><p/><dt>class\r\n\t\t\t\t\t\t\t\t  template\r\n\t\t\t\t\t\t\t   <a href=\"#classrapidxml_1_1xml__attribute\">rapidxml::xml_attribute</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstructor\r\n\t\t\t <a href=\"#classrapidxml_1_1xml__attribute_d5464aadf08269a886b730993525db34_1d5464aadf08269a886b730993525db34\">xml_attribute()</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__attribute_77aea7d8d996ba4f6bd61cc478a4e72d_177aea7d8d996ba4f6bd61cc478a4e72d\">document() const </a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__attribute_5c4a98d2b75f9b41b12c110108fd55ab_15c4a98d2b75f9b41b12c110108fd55ab\">previous_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const </a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__attribute_1b8a814d0d3a7165396b08433eee8a91_11b8a814d0d3a7165396b08433eee8a91\">next_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const </a></dt><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><p/><dt>class\r\n\t\t\t\t\t\t\t\t  template\r\n\t\t\t\t\t\t\t   <a href=\"#classrapidxml_1_1xml__base\">rapidxml::xml_base</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstructor\r\n\t\t\t <a href=\"#classrapidxml_1_1xml__base_23630d2c130a9e0e3f3afa7584a9b218_123630d2c130a9e0e3f3afa7584a9b218\">xml_base()</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__base_622eade29fdf7806d3ef93ac4d90e707_1622eade29fdf7806d3ef93ac4d90e707\">name() const </a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__base_0dae694c8f7e4d89f1003e2f3a15a43c_10dae694c8f7e4d89f1003e2f3a15a43c\">name_size() const </a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__base_c54fa4987fb503916a7b541eb15c9c7f_1c54fa4987fb503916a7b541eb15c9c7f\">value() const </a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__base_aed5ae791b7164c1ee5e649198cbb3db_1aed5ae791b7164c1ee5e649198cbb3db\">value_size() const </a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__base_4e7e23d06d48126c65b1f6266acfba5c_14e7e23d06d48126c65b1f6266acfba5c\">name(const Ch *name, std::size_t size)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__base_e099c291e104a0d277307fe71f5e0f9e_1e099c291e104a0d277307fe71f5e0f9e\">name(const Ch *name)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__base_d9640aa3f5374673cb72a5289b6c91eb_1d9640aa3f5374673cb72a5289b6c91eb\">value(const Ch *value, std::size_t size)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__base_18c7469acdca771de9b4f3054053029c_118c7469acdca771de9b4f3054053029c\">value(const Ch *value)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__base_798e8df7ea53ade4d9f0701017dce80e_1798e8df7ea53ade4d9f0701017dce80e\">parent() const </a></dt><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><p/><dt>class\r\n\t\t\t\t\t\t\t\t  template\r\n\t\t\t\t\t\t\t   <a href=\"#classrapidxml_1_1xml__document\">rapidxml::xml_document</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstructor\r\n\t\t\t <a href=\"#classrapidxml_1_1xml__document_6ce266cc52d549c42abe3a3d5e8af9ba_16ce266cc52d549c42abe3a3d5e8af9ba\">xml_document()</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\">parse(Ch *text)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__document_c8bb3912a3ce86b15842e79d0b421204_1c8bb3912a3ce86b15842e79d0b421204\">clear()</a></dt><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><p/><p/><p/><p/><p/><p/><p/><p/><p/><dt>class\r\n\t\t\t\t\t\t\t\t  template\r\n\t\t\t\t\t\t\t   <a href=\"#classrapidxml_1_1xml__node\">rapidxml::xml_node</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstructor\r\n\t\t\t <a href=\"#classrapidxml_1_1xml__node_34c55af3504549a475e5b9dfcaa6adf5_134c55af3504549a475e5b9dfcaa6adf5\">xml_node(node_type type)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_975e86937621ae4afe6a423219de30d0_1975e86937621ae4afe6a423219de30d0\">type() const </a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_77aea7d8d996ba4f6bd61cc478a4e72d_177aea7d8d996ba4f6bd61cc478a4e72d\">document() const </a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_7823e36687669e59c2afdf66334ef35a_17823e36687669e59c2afdf66334ef35a\">first_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const </a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_fcb6e2209b591a36d2dadba20d2bc7cc_1fcb6e2209b591a36d2dadba20d2bc7cc\">last_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const </a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_ac2f6886c0107e9d5f156e9542546df6_1ac2f6886c0107e9d5f156e9542546df6\">previous_sibling(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const </a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_b3ead2cefecc03a813836203e3f6f38f_1b3ead2cefecc03a813836203e3f6f38f\">next_sibling(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const </a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_5810a09f82f8d53efbe9456286dcec83_15810a09f82f8d53efbe9456286dcec83\">first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const </a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_16953d66751b5b949ee4ee2d9c0bc63a_116953d66751b5b949ee4ee2d9c0bc63a\">last_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const </a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_a78759bfa429fa2ab6bc5fe617cfa3cf_1a78759bfa429fa2ab6bc5fe617cfa3cf\">type(node_type type)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_0c39df6617e709eb2fba11300dea63f2_10c39df6617e709eb2fba11300dea63f2\">prepend_node(xml_node&lt; Ch &gt; *child)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_86de2e22276826089b7baed2599f8dee_186de2e22276826089b7baed2599f8dee\">append_node(xml_node&lt; Ch &gt; *child)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_780972a57fc447250ab47cc8f421b65e_1780972a57fc447250ab47cc8f421b65e\">insert_node(xml_node&lt; Ch &gt; *where, xml_node&lt; Ch &gt; *child)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_9a31d861e1bddc710839c551a5d2b3a4_19a31d861e1bddc710839c551a5d2b3a4\">remove_first_node()</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_87addf2bc127ee31aa4b5295d3c9b530_187addf2bc127ee31aa4b5295d3c9b530\">remove_last_node()</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_9316463a2201631e7e2062b17729f9cd_19316463a2201631e7e2062b17729f9cd\">remove_node(xml_node&lt; Ch &gt; *where)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_0218147d13e41d5fa60ced4e7a7e9726_10218147d13e41d5fa60ced4e7a7e9726\">remove_all_nodes()</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_f6dffa513da74cc0be71a7ba84f8265e_1f6dffa513da74cc0be71a7ba84f8265e\">prepend_attribute(xml_attribute&lt; Ch &gt; *attribute)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_8fbd4f5ef7169d493da9f8d87ac04b77_18fbd4f5ef7169d493da9f8d87ac04b77\">append_attribute(xml_attribute&lt; Ch &gt; *attribute)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_070d5888b0557fe06a5b24961de1b988_1070d5888b0557fe06a5b24961de1b988\">insert_attribute(xml_attribute&lt; Ch &gt; *where, xml_attribute&lt; Ch &gt; *attribute)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_4eea4a7f6cb484ca9944f7eafe6e1843_14eea4a7f6cb484ca9944f7eafe6e1843\">remove_first_attribute()</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_37d87c4d5d89fa0cf05b72ee8d4cba3b_137d87c4d5d89fa0cf05b72ee8d4cba3b\">remove_last_attribute()</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_c75154db2e768c0e5b541fc8cd0775ab_1c75154db2e768c0e5b541fc8cd0775ab\">remove_attribute(xml_attribute&lt; Ch &gt; *where)</a></dt><dt class=\"indented\">function <a href=\"#classrapidxml_1_1xml__node_59e6ad4cfd5e8096c052e71d79561eda_159e6ad4cfd5e8096c052e71d79561eda\">remove_all_attributes()</a></dt><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><p/><dt>namespace <a href=\"#namespacerapidxml\">rapidxml</a></dt><dt class=\"indented\">enum <a href=\"#namespacerapidxml_6a276b85e2da28c5f9c3dbce61c55682_16a276b85e2da28c5f9c3dbce61c55682\">node_type</a></dt><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\"/><dt class=\"indented\">function <a href=\"#namespacerapidxml_ff5d67f74437199d316d2b2660653ae1_1ff5d67f74437199d316d2b2660653ae1\">parse_error_handler(const char *what, void *where)</a></dt><dt class=\"indented\">function <a href=\"#namespacerapidxml_b94d570fc4c4ab2423813cd0243326b1_1b94d570fc4c4ab2423813cd0243326b1\">print(OutIt out, const xml_node&lt; Ch &gt; &amp;node, int flags=0)</a></dt><dt class=\"indented\">function <a href=\"#namespacerapidxml_13bc37d6d1047acb0efdbc1689221a5e_113bc37d6d1047acb0efdbc1689221a5e\">print(std::basic_ostream&lt; Ch &gt; &amp;out, const xml_node&lt; Ch &gt; &amp;node, int flags=0)</a></dt><dt class=\"indented\">function <a href=\"#namespacerapidxml_5619b38000d967fb223b2b0a8c17463a_15619b38000d967fb223b2b0a8c17463a\">operator&lt;&lt;(std::basic_ostream&lt; Ch &gt; &amp;out, const xml_node&lt; Ch &gt; &amp;node)</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_87e8bbab53702cf3b438bd553c10b6b9_187e8bbab53702cf3b438bd553c10b6b9\">parse_no_data_nodes</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_97e2c4fdc04fae17126f9971a4fc993e_197e2c4fdc04fae17126f9971a4fc993e\">parse_no_element_values</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_9cae3801e70437cbc410c24bf6be691c_19cae3801e70437cbc410c24bf6be691c\">parse_no_string_terminators</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_7223b7815c4fb8b42e6e4e77e1ea6b97_17223b7815c4fb8b42e6e4e77e1ea6b97\">parse_no_entity_translation</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_ccde57f6054857ee4042a1b4d98c83b9_1ccde57f6054857ee4042a1b4d98c83b9\">parse_no_utf8</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_52e2c934ad9c845a5f4cc49570470556_152e2c934ad9c845a5f4cc49570470556\">parse_declaration_node</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_0f7479dacbc868456d07897a8c072784_10f7479dacbc868456d07897a8c072784\">parse_comment_nodes</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_8e187746ba1ca04f107951ad32df962e_18e187746ba1ca04f107951ad32df962e\">parse_doctype_node</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_1c20b2b2b75711cd76423e119c49f830_11c20b2b2b75711cd76423e119c49f830\">parse_pi_nodes</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_a5daff9d61c7d4eaf98e4d42efe628ee_1a5daff9d61c7d4eaf98e4d42efe628ee\">parse_validate_closing_tags</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_ac1f06b1afd47b812732fb521b146fd9_1ac1f06b1afd47b812732fb521b146fd9\">parse_trim_whitespace</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_88f95d4e275ba01408fefde83078651b_188f95d4e275ba01408fefde83078651b\">parse_normalize_whitespace</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_45751cf2f38fd6915f35b3122b46d5b6_145751cf2f38fd6915f35b3122b46d5b6\">parse_default</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_a97ba1a0a79a6d66f4eef3612508d943_1a97ba1a0a79a6d66f4eef3612508d943\">parse_non_destructive</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_398c5476e76102f8bd76c10bb0abbe10_1398c5476e76102f8bd76c10bb0abbe10\">parse_fastest</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_b4f2515265facb42291570307924bd57_1b4f2515265facb42291570307924bd57\">parse_full</a></dt><dt class=\"indented\">\r\n\t\t\t\tconstant\r\n\t\t\t <a href=\"#namespacerapidxml_b08b8d4293c203b69ed6c5ae77ac1907_1b08b8d4293c203b69ed6c5ae77ac1907\">print_no_indenting</a></dt><p/><p/><p/><p/></dl><hr/><h3 class=\"reference-header\" id=\"classrapidxml_1_1memory__pool\">class\r\n\t\t\t\t\t\t\t\t\t  template\r\n\t\t\t\t\t\t\t\t   rapidxml::memory_pool</h3>\r\n\r\n\t\t\t\t\t\t\t  Defined in <a href=\"rapidxml.hpp\">rapidxml.hpp</a><br/>\r\n\t\t\t\t\t\t\t\t  Base class for\r\n\t\t\t\t\t\t\t\t  <a href=\"#classrapidxml_1_1xml__document\">xml_document</a> <h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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 <a href=\"#classrapidxml_1_1memory__pool\" kindref=\"compound\">memory_pool</a> of relevant <a href=\"#classrapidxml_1_1xml__document\" kindref=\"compound\">xml_document</a> to allocate the memory. Not only is this faster than allocating them by using <code>new</code> operator, but also their lifetime will be tied to the lifetime of document, possibly simplyfing memory management. <br/><br/>\r\n Call <a href=\"#classrapidxml_1_1memory__pool_750ba3c610b129ac057d817509d08f41_1750ba3c610b129ac057d817509d08f41\" kindref=\"member\">allocate_node()</a> or <a href=\"#classrapidxml_1_1memory__pool_462de142669e0ff649e8e615b82bf457_1462de142669e0ff649e8e615b82bf457\" kindref=\"member\">allocate_attribute()</a> functions to obtain new nodes or attributes from the pool. You can also call <a href=\"#classrapidxml_1_1memory__pool_69729185bc59b0875192d667c47b8859_169729185bc59b0875192d667c47b8859\" kindref=\"member\">allocate_string()</a> 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 <code>free()</code> function -- all allocations are freed at once when <a href=\"#classrapidxml_1_1memory__pool_c8bb3912a3ce86b15842e79d0b421204_1c8bb3912a3ce86b15842e79d0b421204\" kindref=\"member\">clear()</a> function is called, or when the pool is destroyed. <br/><br/>\r\n It is also possible to create a standalone <a href=\"#classrapidxml_1_1memory__pool\" kindref=\"compound\">memory_pool</a>, and use it to allocate nodes, whose lifetime will not be tied to any document. <br/><br/>\r\n Pool maintains <code>RAPIDXML_STATIC_POOL_SIZE</code> 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 <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> each, by using global <code>new[]</code> and <code>delete[]</code> operators. This behaviour can be changed by setting custom allocation routines. Use <a href=\"#classrapidxml_1_1memory__pool_c0a55a6ef0837dca67572e357100d78a_1c0a55a6ef0837dca67572e357100d78a\" kindref=\"member\">set_allocator()</a> function to set them. <br/><br/>\r\n Allocations for nodes, attributes and strings are aligned at <code>RAPIDXML_ALIGNMENT</code> bytes. This value defaults to the size of pointer on target architecture. <br/><br/>\r\n 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 <code>RAPIDXML_STATIC_POOL_SIZE</code>, <code>RAPIDXML_DYNAMIC_POOL_SIZE</code> and <code>RAPIDXML_ALIGNMENT</code> to obtain best wasted memory to performance compromise. To do it, define their values before <a href=\"#rapidxml_8hpp\" kindref=\"compound\">rapidxml.hpp</a> file is included. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">Ch</dt><dd>Character type of created nodes. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1memory__pool_f8fb3c8f1a564f8045c40bcd07a89866_1f8fb3c8f1a564f8045c40bcd07a89866\">\r\n\t\t\t\tconstructor\r\n\t\t\t memory_pool::memory_pool</h3><h4>Synopsis</h4><code class=\"synopsis\">memory_pool();\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Constructs empty pool with default allocator functions. </para><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1memory__pool_6f8c7990d9ec1ed2acf6558b238570eb_16f8c7990d9ec1ed2acf6558b238570eb\">\r\n\t\t\t\tdestructor\r\n\t\t\t memory_pool::~memory_pool</h3><h4>Synopsis</h4><code class=\"synopsis\">~memory_pool();\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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. </para><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1memory__pool_750ba3c610b129ac057d817509d08f41_1750ba3c610b129ac057d817509d08f41\">function memory_pool::allocate_node</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_node&lt;Ch&gt;* 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);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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 <code>std::bad_alloc</code>. If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function will call <a href=\"#namespacerapidxml_ff5d67f74437199d316d2b2660653ae1_1ff5d67f74437199d316d2b2660653ae1\" kindref=\"member\">rapidxml::parse_error_handler()</a> function. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">type</dt><dd class=\"parameter-def\">Type of node to create. </dd></dl><dl><dt class=\"parameter-name\">name</dt><dd class=\"parameter-def\">Name to assign to the node, or 0 to assign no name. </dd></dl><dl><dt class=\"parameter-name\">value</dt><dd class=\"parameter-def\">Value to assign to the node, or 0 to assign no value. </dd></dl><dl><dt class=\"parameter-name\">name_size</dt><dd class=\"parameter-def\">Size of name to assign, or 0 to automatically calculate size from name string. </dd></dl><dl><dt class=\"parameter-name\">value_size</dt><dd class=\"parameter-def\">Size of value to assign, or 0 to automatically calculate size from value string. </dd></dl><h4>Returns</h4>Pointer to allocated node. This pointer will never be NULL. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1memory__pool_462de142669e0ff649e8e615b82bf457_1462de142669e0ff649e8e615b82bf457\">function memory_pool::allocate_attribute</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_attribute&lt;Ch&gt;* allocate_attribute(const Ch *name=0, const Ch *value=0, std::size_t name_size=0, std::size_t value_size=0);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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 <code>std::bad_alloc</code>. If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function will call <a href=\"#namespacerapidxml_ff5d67f74437199d316d2b2660653ae1_1ff5d67f74437199d316d2b2660653ae1\" kindref=\"member\">rapidxml::parse_error_handler()</a> function. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">name</dt><dd class=\"parameter-def\">Name to assign to the attribute, or 0 to assign no name. </dd></dl><dl><dt class=\"parameter-name\">value</dt><dd class=\"parameter-def\">Value to assign to the attribute, or 0 to assign no value. </dd></dl><dl><dt class=\"parameter-name\">name_size</dt><dd class=\"parameter-def\">Size of name to assign, or 0 to automatically calculate size from name string. </dd></dl><dl><dt class=\"parameter-name\">value_size</dt><dd class=\"parameter-def\">Size of value to assign, or 0 to automatically calculate size from value string. </dd></dl><h4>Returns</h4>Pointer to allocated attribute. This pointer will never be NULL. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1memory__pool_69729185bc59b0875192d667c47b8859_169729185bc59b0875192d667c47b8859\">function memory_pool::allocate_string</h3><h4>Synopsis</h4><code class=\"synopsis\">Ch* allocate_string(const Ch *source=0, std::size_t size=0);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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 <code>std::bad_alloc</code>. If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function will call <a href=\"#namespacerapidxml_ff5d67f74437199d316d2b2660653ae1_1ff5d67f74437199d316d2b2660653ae1\" kindref=\"member\">rapidxml::parse_error_handler()</a> function. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">source</dt><dd class=\"parameter-def\">String to initialize the allocated memory with, or 0 to not initialize it. </dd></dl><dl><dt class=\"parameter-name\">size</dt><dd class=\"parameter-def\">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. </dd></dl><h4>Returns</h4>Pointer to allocated char array. This pointer will never be NULL. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1memory__pool_95c49fcb056e9103ec906a59e3e01d76_195c49fcb056e9103ec906a59e3e01d76\">function memory_pool::clone_node</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_node&lt;Ch&gt;* clone_node(const xml_node&lt; Ch &gt; *source, xml_node&lt; Ch &gt; *result=0);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Clones an <a href=\"#classrapidxml_1_1xml__node\" kindref=\"compound\">xml_node</a> 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. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">source</dt><dd class=\"parameter-def\">Node to clone. </dd></dl><dl><dt class=\"parameter-name\">result</dt><dd class=\"parameter-def\">Node to put results in, or 0 to automatically allocate result node </dd></dl><h4>Returns</h4>Pointer to cloned node. This pointer will never be NULL. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1memory__pool_c8bb3912a3ce86b15842e79d0b421204_1c8bb3912a3ce86b15842e79d0b421204\">function memory_pool::clear</h3><h4>Synopsis</h4><code class=\"synopsis\">void clear();\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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. </para><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1memory__pool_c0a55a6ef0837dca67572e357100d78a_1c0a55a6ef0837dca67572e357100d78a\">function memory_pool::set_allocator</h3><h4>Synopsis</h4><code class=\"synopsis\">void set_allocator(alloc_func *af, free_func *ff);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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 <code>longjmp()</code> function to pass control to other place of program. If it returns invalid pointer, results are undefined. <br/><br/>\r\n User defined allocation functions must have the following forms: <br/><code><br/>\r\nvoid *allocate(std::size_t size); <br/>\r\nvoid free(void *pointer); </code><br/></para><h4>Parameters</h4><dl><dt class=\"parameter-name\">af</dt><dd class=\"parameter-def\">Allocation function, or 0 to restore default function </dd></dl><dl><dt class=\"parameter-name\">ff</dt><dd class=\"parameter-def\">Free function, or 0 to restore default function </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1parse__error\">class rapidxml::parse_error</h3>\r\n\r\n\t\t\t\t\t\t\t  Defined in <a href=\"rapidxml.hpp\">rapidxml.hpp</a><br/><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Parse error exception. This exception is thrown by the parser when an error occurs. Use <a href=\"#classrapidxml_1_1parse__error_ff06f49065b54a8a86e02e9a2441a8ba_1ff06f49065b54a8a86e02e9a2441a8ba\" kindref=\"member\">what()</a> function to get human-readable error message. Use <a href=\"#classrapidxml_1_1parse__error_377be7d201d95221c318682c35377aca_1377be7d201d95221c318682c35377aca\" kindref=\"member\">where()</a> function to get a pointer to position within source text where error was detected. <br/><br/>\r\n If throwing exceptions by the parser is undesirable, it can be disabled by defining RAPIDXML_NO_EXCEPTIONS macro before <a href=\"#rapidxml_8hpp\" kindref=\"compound\">rapidxml.hpp</a> is included. This will cause the parser to call <a href=\"#namespacerapidxml_ff5d67f74437199d316d2b2660653ae1_1ff5d67f74437199d316d2b2660653ae1\" kindref=\"member\">rapidxml::parse_error_handler()</a> function instead of throwing an exception. This function must be defined by the user. <br/><br/>\r\n This class derives from <code>std::exception</code> class. </para><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1parse__error_4dd8d1bdbd9221df4dcb90cafaee3332_14dd8d1bdbd9221df4dcb90cafaee3332\">\r\n\t\t\t\tconstructor\r\n\t\t\t parse_error::parse_error</h3><h4>Synopsis</h4><code class=\"synopsis\">parse_error(const char *what, void *where);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Constructs parse error. </para><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1parse__error_ff06f49065b54a8a86e02e9a2441a8ba_1ff06f49065b54a8a86e02e9a2441a8ba\">function parse_error::what</h3><h4>Synopsis</h4><code class=\"synopsis\">virtual const char* what() const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets human readable description of error. </para><h4>Returns</h4>Pointer to null terminated description of the error. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1parse__error_377be7d201d95221c318682c35377aca_1377be7d201d95221c318682c35377aca\">function parse_error::where</h3><h4>Synopsis</h4><code class=\"synopsis\">Ch* where() const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets pointer to character data where error happened. Ch should be the same as char type of <a href=\"#classrapidxml_1_1xml__document\" kindref=\"compound\">xml_document</a> that produced the error. </para><h4>Returns</h4>Pointer to location within the parsed string where error occured. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__attribute\">class\r\n\t\t\t\t\t\t\t\t\t  template\r\n\t\t\t\t\t\t\t\t   rapidxml::xml_attribute</h3>\r\n\r\n\t\t\t\t\t\t\t  Defined in <a href=\"rapidxml.hpp\">rapidxml.hpp</a><br/>\r\n\t\t\t\t\t\t\t\t  Inherits from\r\n\t\t\t\t\t\t\t\t  <a href=\"#classrapidxml_1_1xml__base\">xml_base</a> <br/><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Class representing attribute node of XML document. Each attribute has name and value strings, which are available through <a href=\"#classrapidxml_1_1xml__base_622eade29fdf7806d3ef93ac4d90e707_1622eade29fdf7806d3ef93ac4d90e707\" kindref=\"member\">name()</a> and <a href=\"#classrapidxml_1_1xml__base_c54fa4987fb503916a7b541eb15c9c7f_1c54fa4987fb503916a7b541eb15c9c7f\" kindref=\"member\">value()</a> functions (inherited from <a href=\"#classrapidxml_1_1xml__base\" kindref=\"compound\">xml_base</a>). 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. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">Ch</dt><dd>Character type to use. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__attribute_d5464aadf08269a886b730993525db34_1d5464aadf08269a886b730993525db34\">\r\n\t\t\t\tconstructor\r\n\t\t\t xml_attribute::xml_attribute</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_attribute();\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Constructs an empty attribute with the specified type. Consider using <a href=\"#classrapidxml_1_1memory__pool\" kindref=\"compound\">memory_pool</a> of appropriate <a href=\"#classrapidxml_1_1xml__document\" kindref=\"compound\">xml_document</a> if allocating attributes manually. </para><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__attribute_77aea7d8d996ba4f6bd61cc478a4e72d_177aea7d8d996ba4f6bd61cc478a4e72d\">function xml_attribute::document</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_document&lt;Ch&gt;* document() const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets document of which attribute is a child. </para><h4>Returns</h4>Pointer to document that contains this attribute, or 0 if there is no parent document. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__attribute_5c4a98d2b75f9b41b12c110108fd55ab_15c4a98d2b75f9b41b12c110108fd55ab\">function xml_attribute::previous_attribute</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_attribute&lt;Ch&gt;* previous_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets previous attribute, optionally matching attribute name. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">name</dt><dd class=\"parameter-def\">Name of attribute to find, or 0 to return previous attribute regardless of its name; this string doesn&apos;t have to be zero-terminated if name_size is non-zero </dd></dl><dl><dt class=\"parameter-name\">name_size</dt><dd class=\"parameter-def\">Size of name, in characters, or 0 to have size calculated automatically from string </dd></dl><dl><dt class=\"parameter-name\">case_sensitive</dt><dd class=\"parameter-def\">Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters </dd></dl><h4>Returns</h4>Pointer to found attribute, or 0 if not found. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__attribute_1b8a814d0d3a7165396b08433eee8a91_11b8a814d0d3a7165396b08433eee8a91\">function xml_attribute::next_attribute</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_attribute&lt;Ch&gt;* next_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets next attribute, optionally matching attribute name. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">name</dt><dd class=\"parameter-def\">Name of attribute to find, or 0 to return next attribute regardless of its name; this string doesn&apos;t have to be zero-terminated if name_size is non-zero </dd></dl><dl><dt class=\"parameter-name\">name_size</dt><dd class=\"parameter-def\">Size of name, in characters, or 0 to have size calculated automatically from string </dd></dl><dl><dt class=\"parameter-name\">case_sensitive</dt><dd class=\"parameter-def\">Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters </dd></dl><h4>Returns</h4>Pointer to found attribute, or 0 if not found. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__base\">class\r\n\t\t\t\t\t\t\t\t\t  template\r\n\t\t\t\t\t\t\t\t   rapidxml::xml_base</h3>\r\n\r\n\t\t\t\t\t\t\t  Defined in <a href=\"rapidxml.hpp\">rapidxml.hpp</a><br/>\r\n\t\t\t\t\t\t\t\t  Base class for\r\n\t\t\t\t\t\t\t\t  <a href=\"#classrapidxml_1_1xml__attribute\">xml_attribute</a> <a href=\"#classrapidxml_1_1xml__node\">xml_node</a> <h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Base class for <a href=\"#classrapidxml_1_1xml__node\" kindref=\"compound\">xml_node</a> and <a href=\"#classrapidxml_1_1xml__attribute\" kindref=\"compound\">xml_attribute</a> implementing common functions: <a href=\"#classrapidxml_1_1xml__base_622eade29fdf7806d3ef93ac4d90e707_1622eade29fdf7806d3ef93ac4d90e707\" kindref=\"member\">name()</a>, <a href=\"#classrapidxml_1_1xml__base_0dae694c8f7e4d89f1003e2f3a15a43c_10dae694c8f7e4d89f1003e2f3a15a43c\" kindref=\"member\">name_size()</a>, <a href=\"#classrapidxml_1_1xml__base_c54fa4987fb503916a7b541eb15c9c7f_1c54fa4987fb503916a7b541eb15c9c7f\" kindref=\"member\">value()</a>, <a href=\"#classrapidxml_1_1xml__base_aed5ae791b7164c1ee5e649198cbb3db_1aed5ae791b7164c1ee5e649198cbb3db\" kindref=\"member\">value_size()</a> and <a href=\"#classrapidxml_1_1xml__base_798e8df7ea53ade4d9f0701017dce80e_1798e8df7ea53ade4d9f0701017dce80e\" kindref=\"member\">parent()</a>. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">Ch</dt><dd>Character type to use </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__base_23630d2c130a9e0e3f3afa7584a9b218_123630d2c130a9e0e3f3afa7584a9b218\">\r\n\t\t\t\tconstructor\r\n\t\t\t xml_base::xml_base</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_base();\r\n\t\t\t\t\t\t\t\t\t  </code><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__base_622eade29fdf7806d3ef93ac4d90e707_1622eade29fdf7806d3ef93ac4d90e707\">function xml_base::name</h3><h4>Synopsis</h4><code class=\"synopsis\">Ch* name() const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets name of the node. Interpretation of name depends on type of node. Note that name will not be zero-terminated if <a href=\"#namespacerapidxml_9cae3801e70437cbc410c24bf6be691c_19cae3801e70437cbc410c24bf6be691c\" kindref=\"member\">rapidxml::parse_no_string_terminators</a> option was selected during parse. <br/><br/>\r\n Use <a href=\"#classrapidxml_1_1xml__base_0dae694c8f7e4d89f1003e2f3a15a43c_10dae694c8f7e4d89f1003e2f3a15a43c\" kindref=\"member\">name_size()</a> function to determine length of the name. </para><h4>Returns</h4>Name of node, or empty string if node has no name. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__base_0dae694c8f7e4d89f1003e2f3a15a43c_10dae694c8f7e4d89f1003e2f3a15a43c\">function xml_base::name_size</h3><h4>Synopsis</h4><code class=\"synopsis\">std::size_t name_size() const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets size of node name, not including terminator character. This function works correctly irrespective of whether name is or is not zero terminated. </para><h4>Returns</h4>Size of node name, in characters. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__base_c54fa4987fb503916a7b541eb15c9c7f_1c54fa4987fb503916a7b541eb15c9c7f\">function xml_base::value</h3><h4>Synopsis</h4><code class=\"synopsis\">Ch* value() const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets value of node. Interpretation of value depends on type of node. Note that value will not be zero-terminated if <a href=\"#namespacerapidxml_9cae3801e70437cbc410c24bf6be691c_19cae3801e70437cbc410c24bf6be691c\" kindref=\"member\">rapidxml::parse_no_string_terminators</a> option was selected during parse. <br/><br/>\r\n Use <a href=\"#classrapidxml_1_1xml__base_aed5ae791b7164c1ee5e649198cbb3db_1aed5ae791b7164c1ee5e649198cbb3db\" kindref=\"member\">value_size()</a> function to determine length of the value. </para><h4>Returns</h4>Value of node, or empty string if node has no value. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__base_aed5ae791b7164c1ee5e649198cbb3db_1aed5ae791b7164c1ee5e649198cbb3db\">function xml_base::value_size</h3><h4>Synopsis</h4><code class=\"synopsis\">std::size_t value_size() const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets size of node value, not including terminator character. This function works correctly irrespective of whether value is or is not zero terminated. </para><h4>Returns</h4>Size of node value, in characters. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__base_4e7e23d06d48126c65b1f6266acfba5c_14e7e23d06d48126c65b1f6266acfba5c\">function xml_base::name</h3><h4>Synopsis</h4><code class=\"synopsis\">void name(const Ch *name, std::size_t size);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Sets name of node to a non zero-terminated string. See <a href=\"#namespacerapidxml_1ownership_of_strings\" kindref=\"member\">Ownership Of Strings</a> . <br/><br/>\r\n 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 <a href=\"#classrapidxml_1_1memory__pool\" kindref=\"compound\">memory_pool</a> of the document to allocate the string - on destruction of the document the string will be automatically freed. <br/><br/>\r\n Size of name must be specified separately, because name does not have to be zero terminated. Use <a href=\"#classrapidxml_1_1xml__base_e099c291e104a0d277307fe71f5e0f9e_1e099c291e104a0d277307fe71f5e0f9e\" kindref=\"member\">name(const Ch *)</a> function to have the length automatically calculated (string must be zero terminated). </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">name</dt><dd class=\"parameter-def\">Name of node to set. Does not have to be zero terminated. </dd></dl><dl><dt class=\"parameter-name\">size</dt><dd class=\"parameter-def\">Size of name, in characters. This does not include zero terminator, if one is present. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__base_e099c291e104a0d277307fe71f5e0f9e_1e099c291e104a0d277307fe71f5e0f9e\">function xml_base::name</h3><h4>Synopsis</h4><code class=\"synopsis\">void name(const Ch *name);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Sets name of node to a zero-terminated string. See also <a href=\"#namespacerapidxml_1ownership_of_strings\" kindref=\"member\">Ownership Of Strings</a>  and <a href=\"#classrapidxml_1_1xml__base_4e7e23d06d48126c65b1f6266acfba5c_14e7e23d06d48126c65b1f6266acfba5c\" kindref=\"member\">xml_node::name(const Ch *, std::size_t)</a>. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">name</dt><dd class=\"parameter-def\">Name of node to set. Must be zero terminated. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__base_d9640aa3f5374673cb72a5289b6c91eb_1d9640aa3f5374673cb72a5289b6c91eb\">function xml_base::value</h3><h4>Synopsis</h4><code class=\"synopsis\">void value(const Ch *value, std::size_t size);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Sets value of node to a non zero-terminated string. See <a href=\"#namespacerapidxml_1ownership_of_strings\" kindref=\"member\">Ownership Of Strings</a> . <br/><br/>\r\n 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 <a href=\"#classrapidxml_1_1memory__pool\" kindref=\"compound\">memory_pool</a> of the document to allocate the string - on destruction of the document the string will be automatically freed. <br/><br/>\r\n Size of value must be specified separately, because it does not have to be zero terminated. Use <a href=\"#classrapidxml_1_1xml__base_18c7469acdca771de9b4f3054053029c_118c7469acdca771de9b4f3054053029c\" kindref=\"member\">value(const Ch *)</a> function to have the length automatically calculated (string must be zero terminated). <br/><br/>\r\n 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 <a href=\"#namespacerapidxml_87e8bbab53702cf3b438bd553c10b6b9_187e8bbab53702cf3b438bd553c10b6b9\" kindref=\"member\">rapidxml::parse_no_data_nodes</a> to prevent creation of data nodes by the parser. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">value</dt><dd class=\"parameter-def\">value of node to set. Does not have to be zero terminated. </dd></dl><dl><dt class=\"parameter-name\">size</dt><dd class=\"parameter-def\">Size of value, in characters. This does not include zero terminator, if one is present. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__base_18c7469acdca771de9b4f3054053029c_118c7469acdca771de9b4f3054053029c\">function xml_base::value</h3><h4>Synopsis</h4><code class=\"synopsis\">void value(const Ch *value);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Sets value of node to a zero-terminated string. See also <a href=\"#namespacerapidxml_1ownership_of_strings\" kindref=\"member\">Ownership Of Strings</a>  and <a href=\"#classrapidxml_1_1xml__base_d9640aa3f5374673cb72a5289b6c91eb_1d9640aa3f5374673cb72a5289b6c91eb\" kindref=\"member\">xml_node::value(const Ch *, std::size_t)</a>. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">value</dt><dd class=\"parameter-def\">Vame of node to set. Must be zero terminated. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__base_798e8df7ea53ade4d9f0701017dce80e_1798e8df7ea53ade4d9f0701017dce80e\">function xml_base::parent</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_node&lt;Ch&gt;* parent() const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets node parent. </para><h4>Returns</h4>Pointer to parent node, or 0 if there is no parent. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__document\">class\r\n\t\t\t\t\t\t\t\t\t  template\r\n\t\t\t\t\t\t\t\t   rapidxml::xml_document</h3>\r\n\r\n\t\t\t\t\t\t\t  Defined in <a href=\"rapidxml.hpp\">rapidxml.hpp</a><br/>\r\n\t\t\t\t\t\t\t\t  Inherits from\r\n\t\t\t\t\t\t\t\t  <a href=\"#classrapidxml_1_1xml__node\">xml_node</a> <a href=\"#classrapidxml_1_1memory__pool\">memory_pool</a> <br/><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">This class represents root of the DOM hierarchy. It is also an <a href=\"#classrapidxml_1_1xml__node\" kindref=\"compound\">xml_node</a> and a <a href=\"#classrapidxml_1_1memory__pool\" kindref=\"compound\">memory_pool</a> through public inheritance. Use <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">parse()</a> function to build a DOM tree from a zero-terminated XML text string. <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">parse()</a> function allocates memory for nodes and attributes by using functions of <a href=\"#classrapidxml_1_1xml__document\" kindref=\"compound\">xml_document</a>, which are inherited from <a href=\"#classrapidxml_1_1memory__pool\" kindref=\"compound\">memory_pool</a>. To access root node of the document, use the document itself, as if it was an <a href=\"#classrapidxml_1_1xml__node\" kindref=\"compound\">xml_node</a>. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">Ch</dt><dd>Character type to use. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__document_6ce266cc52d549c42abe3a3d5e8af9ba_16ce266cc52d549c42abe3a3d5e8af9ba\">\r\n\t\t\t\tconstructor\r\n\t\t\t xml_document::xml_document</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_document();\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Constructs empty XML document. </para><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\">function xml_document::parse</h3><h4>Synopsis</h4><code class=\"synopsis\">void parse(Ch *text);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Parses zero-terminated XML string according to given flags. Passed string will be modified by the parser, unless <a href=\"#namespacerapidxml_a97ba1a0a79a6d66f4eef3612508d943_1a97ba1a0a79a6d66f4eef3612508d943\" kindref=\"member\">rapidxml::parse_non_destructive</a> flag is used. The string must persist for the lifetime of the document. In case of error, <a href=\"#classrapidxml_1_1parse__error\" kindref=\"compound\">rapidxml::parse_error</a> exception will be thrown. <br/><br/>\r\n 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. <br/><br/>\r\n 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. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">text</dt><dd class=\"parameter-def\">XML data to parse; pointer is non-const to denote fact that this data may be modified by the parser. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__document_c8bb3912a3ce86b15842e79d0b421204_1c8bb3912a3ce86b15842e79d0b421204\">function xml_document::clear</h3><h4>Synopsis</h4><code class=\"synopsis\">void clear();\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Clears the document by deleting all nodes and clearing the memory pool. All nodes owned by document pool are destroyed. </para><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node\">class\r\n\t\t\t\t\t\t\t\t\t  template\r\n\t\t\t\t\t\t\t\t   rapidxml::xml_node</h3>\r\n\r\n\t\t\t\t\t\t\t  Defined in <a href=\"rapidxml.hpp\">rapidxml.hpp</a><br/>\r\n\t\t\t\t\t\t\t\t  Inherits from\r\n\t\t\t\t\t\t\t\t  <a href=\"#classrapidxml_1_1xml__base\">xml_base</a> <br/>\r\n\t\t\t\t\t\t\t\t  Base class for\r\n\t\t\t\t\t\t\t\t  <a href=\"#classrapidxml_1_1xml__document\">xml_document</a> <h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Class representing a node of XML document. Each node may have associated name and value strings, which are available through <a href=\"#classrapidxml_1_1xml__base_622eade29fdf7806d3ef93ac4d90e707_1622eade29fdf7806d3ef93ac4d90e707\" kindref=\"member\">name()</a> and <a href=\"#classrapidxml_1_1xml__base_c54fa4987fb503916a7b541eb15c9c7f_1c54fa4987fb503916a7b541eb15c9c7f\" kindref=\"member\">value()</a> functions. Interpretation of name and value depends on type of the node. Type of node can be determined by using <a href=\"#classrapidxml_1_1xml__node_975e86937621ae4afe6a423219de30d0_1975e86937621ae4afe6a423219de30d0\" kindref=\"member\">type()</a> function. <br/><br/>\r\n 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. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">Ch</dt><dd>Character type to use. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_34c55af3504549a475e5b9dfcaa6adf5_134c55af3504549a475e5b9dfcaa6adf5\">\r\n\t\t\t\tconstructor\r\n\t\t\t xml_node::xml_node</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_node(node_type type);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Constructs an empty node with the specified type. Consider using <a href=\"#classrapidxml_1_1memory__pool\" kindref=\"compound\">memory_pool</a> of appropriate document to allocate nodes manually. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">type</dt><dd class=\"parameter-def\">Type of node to construct. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_975e86937621ae4afe6a423219de30d0_1975e86937621ae4afe6a423219de30d0\">function xml_node::type</h3><h4>Synopsis</h4><code class=\"synopsis\">node_type type() const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets type of node. </para><h4>Returns</h4>Type of node. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_77aea7d8d996ba4f6bd61cc478a4e72d_177aea7d8d996ba4f6bd61cc478a4e72d\">function xml_node::document</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_document&lt;Ch&gt;* document() const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets document of which node is a child. </para><h4>Returns</h4>Pointer to document that contains this node, or 0 if there is no parent document. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_7823e36687669e59c2afdf66334ef35a_17823e36687669e59c2afdf66334ef35a\">function xml_node::first_node</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_node&lt;Ch&gt;* first_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets first child node, optionally matching node name. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">name</dt><dd class=\"parameter-def\">Name of child to find, or 0 to return first child regardless of its name; this string doesn&apos;t have to be zero-terminated if name_size is non-zero </dd></dl><dl><dt class=\"parameter-name\">name_size</dt><dd class=\"parameter-def\">Size of name, in characters, or 0 to have size calculated automatically from string </dd></dl><dl><dt class=\"parameter-name\">case_sensitive</dt><dd class=\"parameter-def\">Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters </dd></dl><h4>Returns</h4>Pointer to found child, or 0 if not found. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_fcb6e2209b591a36d2dadba20d2bc7cc_1fcb6e2209b591a36d2dadba20d2bc7cc\">function xml_node::last_node</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_node&lt;Ch&gt;* last_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets last child node, optionally matching node name. Behaviour is undefined if node has no children. Use <a href=\"#classrapidxml_1_1xml__node_7823e36687669e59c2afdf66334ef35a_17823e36687669e59c2afdf66334ef35a\" kindref=\"member\">first_node()</a> to test if node has children. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">name</dt><dd class=\"parameter-def\">Name of child to find, or 0 to return last child regardless of its name; this string doesn&apos;t have to be zero-terminated if name_size is non-zero </dd></dl><dl><dt class=\"parameter-name\">name_size</dt><dd class=\"parameter-def\">Size of name, in characters, or 0 to have size calculated automatically from string </dd></dl><dl><dt class=\"parameter-name\">case_sensitive</dt><dd class=\"parameter-def\">Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters </dd></dl><h4>Returns</h4>Pointer to found child, or 0 if not found. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_ac2f6886c0107e9d5f156e9542546df6_1ac2f6886c0107e9d5f156e9542546df6\">function xml_node::previous_sibling</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_node&lt;Ch&gt;* previous_sibling(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets previous sibling node, optionally matching node name. Behaviour is undefined if node has no parent. Use <a href=\"#classrapidxml_1_1xml__base_798e8df7ea53ade4d9f0701017dce80e_1798e8df7ea53ade4d9f0701017dce80e\" kindref=\"member\">parent()</a> to test if node has a parent. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">name</dt><dd class=\"parameter-def\">Name of sibling to find, or 0 to return previous sibling regardless of its name; this string doesn&apos;t have to be zero-terminated if name_size is non-zero </dd></dl><dl><dt class=\"parameter-name\">name_size</dt><dd class=\"parameter-def\">Size of name, in characters, or 0 to have size calculated automatically from string </dd></dl><dl><dt class=\"parameter-name\">case_sensitive</dt><dd class=\"parameter-def\">Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters </dd></dl><h4>Returns</h4>Pointer to found sibling, or 0 if not found. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_b3ead2cefecc03a813836203e3f6f38f_1b3ead2cefecc03a813836203e3f6f38f\">function xml_node::next_sibling</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_node&lt;Ch&gt;* next_sibling(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets next sibling node, optionally matching node name. Behaviour is undefined if node has no parent. Use <a href=\"#classrapidxml_1_1xml__base_798e8df7ea53ade4d9f0701017dce80e_1798e8df7ea53ade4d9f0701017dce80e\" kindref=\"member\">parent()</a> to test if node has a parent. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">name</dt><dd class=\"parameter-def\">Name of sibling to find, or 0 to return next sibling regardless of its name; this string doesn&apos;t have to be zero-terminated if name_size is non-zero </dd></dl><dl><dt class=\"parameter-name\">name_size</dt><dd class=\"parameter-def\">Size of name, in characters, or 0 to have size calculated automatically from string </dd></dl><dl><dt class=\"parameter-name\">case_sensitive</dt><dd class=\"parameter-def\">Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters </dd></dl><h4>Returns</h4>Pointer to found sibling, or 0 if not found. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_5810a09f82f8d53efbe9456286dcec83_15810a09f82f8d53efbe9456286dcec83\">function xml_node::first_attribute</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_attribute&lt;Ch&gt;* first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets first attribute of node, optionally matching attribute name. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">name</dt><dd class=\"parameter-def\">Name of attribute to find, or 0 to return first attribute regardless of its name; this string doesn&apos;t have to be zero-terminated if name_size is non-zero </dd></dl><dl><dt class=\"parameter-name\">name_size</dt><dd class=\"parameter-def\">Size of name, in characters, or 0 to have size calculated automatically from string </dd></dl><dl><dt class=\"parameter-name\">case_sensitive</dt><dd class=\"parameter-def\">Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters </dd></dl><h4>Returns</h4>Pointer to found attribute, or 0 if not found. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_16953d66751b5b949ee4ee2d9c0bc63a_116953d66751b5b949ee4ee2d9c0bc63a\">function xml_node::last_attribute</h3><h4>Synopsis</h4><code class=\"synopsis\">xml_attribute&lt;Ch&gt;* last_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Gets last attribute of node, optionally matching attribute name. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">name</dt><dd class=\"parameter-def\">Name of attribute to find, or 0 to return last attribute regardless of its name; this string doesn&apos;t have to be zero-terminated if name_size is non-zero </dd></dl><dl><dt class=\"parameter-name\">name_size</dt><dd class=\"parameter-def\">Size of name, in characters, or 0 to have size calculated automatically from string </dd></dl><dl><dt class=\"parameter-name\">case_sensitive</dt><dd class=\"parameter-def\">Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters </dd></dl><h4>Returns</h4>Pointer to found attribute, or 0 if not found. <p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_a78759bfa429fa2ab6bc5fe617cfa3cf_1a78759bfa429fa2ab6bc5fe617cfa3cf\">function xml_node::type</h3><h4>Synopsis</h4><code class=\"synopsis\">void type(node_type type);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Sets type of node. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">type</dt><dd class=\"parameter-def\">Type of node to set. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_0c39df6617e709eb2fba11300dea63f2_10c39df6617e709eb2fba11300dea63f2\">function xml_node::prepend_node</h3><h4>Synopsis</h4><code class=\"synopsis\">void prepend_node(xml_node&lt; Ch &gt; *child);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Prepends a new child node. The prepended child becomes the first child, and all existing children are moved one position back. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">child</dt><dd class=\"parameter-def\">Node to prepend. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_86de2e22276826089b7baed2599f8dee_186de2e22276826089b7baed2599f8dee\">function xml_node::append_node</h3><h4>Synopsis</h4><code class=\"synopsis\">void append_node(xml_node&lt; Ch &gt; *child);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Appends a new child node. The appended child becomes the last child. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">child</dt><dd class=\"parameter-def\">Node to append. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_780972a57fc447250ab47cc8f421b65e_1780972a57fc447250ab47cc8f421b65e\">function xml_node::insert_node</h3><h4>Synopsis</h4><code class=\"synopsis\">void insert_node(xml_node&lt; Ch &gt; *where, xml_node&lt; Ch &gt; *child);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Inserts a new child node at specified place inside the node. All children after and including the specified node are moved one position back. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">where</dt><dd class=\"parameter-def\">Place where to insert the child, or 0 to insert at the back. </dd></dl><dl><dt class=\"parameter-name\">child</dt><dd class=\"parameter-def\">Node to insert. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_9a31d861e1bddc710839c551a5d2b3a4_19a31d861e1bddc710839c551a5d2b3a4\">function xml_node::remove_first_node</h3><h4>Synopsis</h4><code class=\"synopsis\">void remove_first_node();\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Removes first child node. If node has no children, behaviour is undefined. Use <a href=\"#classrapidxml_1_1xml__node_7823e36687669e59c2afdf66334ef35a_17823e36687669e59c2afdf66334ef35a\" kindref=\"member\">first_node()</a> to test if node has children. </para><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_87addf2bc127ee31aa4b5295d3c9b530_187addf2bc127ee31aa4b5295d3c9b530\">function xml_node::remove_last_node</h3><h4>Synopsis</h4><code class=\"synopsis\">void remove_last_node();\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Removes last child of the node. If node has no children, behaviour is undefined. Use <a href=\"#classrapidxml_1_1xml__node_7823e36687669e59c2afdf66334ef35a_17823e36687669e59c2afdf66334ef35a\" kindref=\"member\">first_node()</a> to test if node has children. </para><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_9316463a2201631e7e2062b17729f9cd_19316463a2201631e7e2062b17729f9cd\">function xml_node::remove_node</h3><h4>Synopsis</h4><code class=\"synopsis\">void remove_node(xml_node&lt; Ch &gt; *where);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Removes specified child from the node. </para><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_0218147d13e41d5fa60ced4e7a7e9726_10218147d13e41d5fa60ced4e7a7e9726\">function xml_node::remove_all_nodes</h3><h4>Synopsis</h4><code class=\"synopsis\">void remove_all_nodes();\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Removes all child nodes (but not attributes). </para><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_f6dffa513da74cc0be71a7ba84f8265e_1f6dffa513da74cc0be71a7ba84f8265e\">function xml_node::prepend_attribute</h3><h4>Synopsis</h4><code class=\"synopsis\">void prepend_attribute(xml_attribute&lt; Ch &gt; *attribute);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Prepends a new attribute to the node. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">attribute</dt><dd class=\"parameter-def\">Attribute to prepend. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_8fbd4f5ef7169d493da9f8d87ac04b77_18fbd4f5ef7169d493da9f8d87ac04b77\">function xml_node::append_attribute</h3><h4>Synopsis</h4><code class=\"synopsis\">void append_attribute(xml_attribute&lt; Ch &gt; *attribute);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Appends a new attribute to the node. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">attribute</dt><dd class=\"parameter-def\">Attribute to append. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_070d5888b0557fe06a5b24961de1b988_1070d5888b0557fe06a5b24961de1b988\">function xml_node::insert_attribute</h3><h4>Synopsis</h4><code class=\"synopsis\">void insert_attribute(xml_attribute&lt; Ch &gt; *where, xml_attribute&lt; Ch &gt; *attribute);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Inserts a new attribute at specified place inside the node. All attributes after and including the specified attribute are moved one position back. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">where</dt><dd class=\"parameter-def\">Place where to insert the attribute, or 0 to insert at the back. </dd></dl><dl><dt class=\"parameter-name\">attribute</dt><dd class=\"parameter-def\">Attribute to insert. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_4eea4a7f6cb484ca9944f7eafe6e1843_14eea4a7f6cb484ca9944f7eafe6e1843\">function xml_node::remove_first_attribute</h3><h4>Synopsis</h4><code class=\"synopsis\">void remove_first_attribute();\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Removes first attribute of the node. If node has no attributes, behaviour is undefined. Use <a href=\"#classrapidxml_1_1xml__node_5810a09f82f8d53efbe9456286dcec83_15810a09f82f8d53efbe9456286dcec83\" kindref=\"member\">first_attribute()</a> to test if node has attributes. </para><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_37d87c4d5d89fa0cf05b72ee8d4cba3b_137d87c4d5d89fa0cf05b72ee8d4cba3b\">function xml_node::remove_last_attribute</h3><h4>Synopsis</h4><code class=\"synopsis\">void remove_last_attribute();\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Removes last attribute of the node. If node has no attributes, behaviour is undefined. Use <a href=\"#classrapidxml_1_1xml__node_5810a09f82f8d53efbe9456286dcec83_15810a09f82f8d53efbe9456286dcec83\" kindref=\"member\">first_attribute()</a> to test if node has attributes. </para><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_c75154db2e768c0e5b541fc8cd0775ab_1c75154db2e768c0e5b541fc8cd0775ab\">function xml_node::remove_attribute</h3><h4>Synopsis</h4><code class=\"synopsis\">void remove_attribute(xml_attribute&lt; Ch &gt; *where);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Removes specified attribute from node. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">where</dt><dd class=\"parameter-def\">Pointer to attribute to be removed. </dd></dl><p/><h3 class=\"reference-header\" id=\"classrapidxml_1_1xml__node_59e6ad4cfd5e8096c052e71d79561eda_159e6ad4cfd5e8096c052e71d79561eda\">function xml_node::remove_all_attributes</h3><h4>Synopsis</h4><code class=\"synopsis\">void remove_all_attributes();\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Removes all attributes of node. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_6a276b85e2da28c5f9c3dbce61c55682_16a276b85e2da28c5f9c3dbce61c55682\">enum node_type</h3><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Enumeration listing all node types produced by the parser. Use <a href=\"#classrapidxml_1_1xml__node_975e86937621ae4afe6a423219de30d0_1975e86937621ae4afe6a423219de30d0\" kindref=\"member\">xml_node::type()</a> function to query node type. </para><h4>Values</h4><dl><dt class=\"parameter-name\">node_document</dt><dd class=\"parameter-def\">A document node. Name and value are empty. </dd></dl><dl><dt class=\"parameter-name\">node_element</dt><dd class=\"parameter-def\">An element node. Name contains element name. Value contains text of first data node. </dd></dl><dl><dt class=\"parameter-name\">node_data</dt><dd class=\"parameter-def\">A data node. Name is empty. Value contains data text. </dd></dl><dl><dt class=\"parameter-name\">node_cdata</dt><dd class=\"parameter-def\">A CDATA node. Name is empty. Value contains data text. </dd></dl><dl><dt class=\"parameter-name\">node_comment</dt><dd class=\"parameter-def\">A comment node. Name is empty. Value contains comment text. </dd></dl><dl><dt class=\"parameter-name\">node_declaration</dt><dd class=\"parameter-def\">A declaration node. Name and value are empty. Declaration parameters (version, encoding and standalone) are in node attributes. </dd></dl><dl><dt class=\"parameter-name\">node_doctype</dt><dd class=\"parameter-def\">A DOCTYPE node. Name is empty. Value contains DOCTYPE text. </dd></dl><dl><dt class=\"parameter-name\">node_pi</dt><dd class=\"parameter-def\">A PI node. Name contains target. Value contains instructions. </dd></dl><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_ff5d67f74437199d316d2b2660653ae1_1ff5d67f74437199d316d2b2660653ae1\">function parse_error_handler</h3><h4>Synopsis</h4><code class=\"synopsis\">void rapidxml::parse_error_handler(const char *what, void *where);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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. <br/><br/>\r\n This function cannot return. If it does, the results are undefined. <br/><br/>\r\n A very simple definition might look like that: <preformatted>\r\n        void rapidxml::parse_error_handler(const char *what, void *where)\r\n        {\r\n            std::cout &lt;&lt; &quot;Parse error: &quot; &lt;&lt; what &lt;&lt; &quot;\\n&quot;;\r\n            std::abort();\r\n        }\r\n        </preformatted></para><h4>Parameters</h4><dl><dt class=\"parameter-name\">what</dt><dd class=\"parameter-def\">Human readable description of the error. </dd></dl><dl><dt class=\"parameter-name\">where</dt><dd class=\"parameter-def\">Pointer to character data where error was detected. </dd></dl><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_b94d570fc4c4ab2423813cd0243326b1_1b94d570fc4c4ab2423813cd0243326b1\">function print</h3><h4>Synopsis</h4><code class=\"synopsis\">OutIt rapidxml::print(OutIt out, const xml_node&lt; Ch &gt; &amp;node, int flags=0);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Prints XML to given output iterator. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">out</dt><dd class=\"parameter-def\">Output iterator to print to. </dd></dl><dl><dt class=\"parameter-name\">node</dt><dd class=\"parameter-def\">Node to be printed. Pass xml_document to print entire document. </dd></dl><dl><dt class=\"parameter-name\">flags</dt><dd class=\"parameter-def\">Flags controlling how XML is printed. </dd></dl><h4>Returns</h4>Output iterator pointing to position immediately after last character of printed text. <p/><h3 class=\"reference-header\" id=\"namespacerapidxml_13bc37d6d1047acb0efdbc1689221a5e_113bc37d6d1047acb0efdbc1689221a5e\">function print</h3><h4>Synopsis</h4><code class=\"synopsis\">std::basic_ostream&lt;Ch&gt;&amp; rapidxml::print(std::basic_ostream&lt; Ch &gt; &amp;out, const xml_node&lt; Ch &gt; &amp;node, int flags=0);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Prints XML to given output stream. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">out</dt><dd class=\"parameter-def\">Output stream to print to. </dd></dl><dl><dt class=\"parameter-name\">node</dt><dd class=\"parameter-def\">Node to be printed. Pass xml_document to print entire document. </dd></dl><dl><dt class=\"parameter-name\">flags</dt><dd class=\"parameter-def\">Flags controlling how XML is printed. </dd></dl><h4>Returns</h4>Output stream. <p/><h3 class=\"reference-header\" id=\"namespacerapidxml_5619b38000d967fb223b2b0a8c17463a_15619b38000d967fb223b2b0a8c17463a\">function operator&lt;&lt;</h3><h4>Synopsis</h4><code class=\"synopsis\">std::basic_ostream&lt;Ch&gt;&amp; rapidxml::operator&lt;&lt;(std::basic_ostream&lt; Ch &gt; &amp;out, const xml_node&lt; Ch &gt; &amp;node);\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Prints formatted XML to given output stream. Uses default printing flags. Use <a href=\"#namespacerapidxml_b94d570fc4c4ab2423813cd0243326b1_1b94d570fc4c4ab2423813cd0243326b1\" kindref=\"member\">print()</a> function to customize printing process. </para><h4>Parameters</h4><dl><dt class=\"parameter-name\">out</dt><dd class=\"parameter-def\">Output stream to print to. </dd></dl><dl><dt class=\"parameter-name\">node</dt><dd class=\"parameter-def\">Node to be printed. </dd></dl><h4>Returns</h4>Output stream. <p/><h3 class=\"reference-header\" id=\"namespacerapidxml_87e8bbab53702cf3b438bd553c10b6b9_187e8bbab53702cf3b438bd553c10b6b9\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_no_data_nodes</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_no_data_nodes\r\n\t\t\t\t\t\t\t\t\t\t\t  = 0x1;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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 <a href=\"#namespacerapidxml_97e2c4fdc04fae17126f9971a4fc993e_197e2c4fdc04fae17126f9971a4fc993e\" kindref=\"member\">rapidxml::parse_no_element_values</a> flag is also specified. Can be combined with other flags by use of | operator. <br/><br/>\r\n See <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_97e2c4fdc04fae17126f9971a4fc993e_197e2c4fdc04fae17126f9971a4fc993e\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_no_element_values</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_no_element_values\r\n\t\t\t\t\t\t\t\t\t\t\t  = 0x2;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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 <i>and</i> a value, the value will be ignored. Use <a href=\"#namespacerapidxml_87e8bbab53702cf3b438bd553c10b6b9_187e8bbab53702cf3b438bd553c10b6b9\" kindref=\"member\">rapidxml::parse_no_data_nodes</a> flag to prevent creation of data nodes if you want to manipulate data using values of elements. <br/><br/>\r\n See <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_9cae3801e70437cbc410c24bf6be691c_19cae3801e70437cbc410c24bf6be691c\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_no_string_terminators</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_no_string_terminators\r\n\t\t\t\t\t\t\t\t\t\t\t  = 0x4;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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. <br/><br/>\r\n See <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_7223b7815c4fb8b42e6e4e77e1ea6b97_17223b7815c4fb8b42e6e4e77e1ea6b97\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_no_entity_translation</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_no_entity_translation\r\n\t\t\t\t\t\t\t\t\t\t\t  = 0x8;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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. <br/><br/>\r\n See <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_ccde57f6054857ee4042a1b4d98c83b9_1ccde57f6054857ee4042a1b4d98c83b9\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_no_utf8</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_no_utf8\r\n\t\t\t\t\t\t\t\t\t\t\t  = 0x10;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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. <br/><br/>\r\n See <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_52e2c934ad9c845a5f4cc49570470556_152e2c934ad9c845a5f4cc49570470556\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_declaration_node</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_declaration_node\r\n\t\t\t\t\t\t\t\t\t\t\t  = 0x20;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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. <br/><br/>\r\n See <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_0f7479dacbc868456d07897a8c072784_10f7479dacbc868456d07897a8c072784\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_comment_nodes</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_comment_nodes\r\n\t\t\t\t\t\t\t\t\t\t\t  = 0x40;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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. <br/><br/>\r\n See <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_8e187746ba1ca04f107951ad32df962e_18e187746ba1ca04f107951ad32df962e\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_doctype_node</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_doctype_node\r\n\t\t\t\t\t\t\t\t\t\t\t  = 0x80;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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. <br/><br/>\r\n See <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_1c20b2b2b75711cd76423e119c49f830_11c20b2b2b75711cd76423e119c49f830\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_pi_nodes</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_pi_nodes\r\n\t\t\t\t\t\t\t\t\t\t\t  = 0x100;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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. <br/><br/>\r\n See <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_a5daff9d61c7d4eaf98e4d42efe628ee_1a5daff9d61c7d4eaf98e4d42efe628ee\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_validate_closing_tags</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_validate_closing_tags\r\n\t\t\t\t\t\t\t\t\t\t\t  = 0x200;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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. <br/><br/>\r\n See <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_ac1f06b1afd47b812732fb521b146fd9_1ac1f06b1afd47b812732fb521b146fd9\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_trim_whitespace</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_trim_whitespace\r\n\t\t\t\t\t\t\t\t\t\t\t  = 0x400;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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. <br/><br/>\r\n See <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_88f95d4e275ba01408fefde83078651b_188f95d4e275ba01408fefde83078651b\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_normalize_whitespace</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_normalize_whitespace\r\n\t\t\t\t\t\t\t\t\t\t\t  = 0x800;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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 <a href=\"#namespacerapidxml_ac1f06b1afd47b812732fb521b146fd9_1ac1f06b1afd47b812732fb521b146fd9\" kindref=\"member\">rapidxml::parse_trim_whitespace</a> 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. <br/><br/>\r\n See <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_45751cf2f38fd6915f35b3122b46d5b6_145751cf2f38fd6915f35b3122b46d5b6\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_default</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_default\r\n\t\t\t\t\t\t\t\t\t\t\t  = 0;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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 <i>negation</i> of the default setting. For example, if flag name is <a href=\"#namespacerapidxml_ccde57f6054857ee4042a1b4d98c83b9_1ccde57f6054857ee4042a1b4d98c83b9\" kindref=\"member\">rapidxml::parse_no_utf8</a>, it means that utf-8 is <i>enabled</i> by default, and using the flag will disable it. <br/><br/>\r\n See <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_a97ba1a0a79a6d66f4eef3612508d943_1a97ba1a0a79a6d66f4eef3612508d943\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_non_destructive</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_non_destructive\r\n\t\t\t\t\t\t\t\t\t\t\t  = parse_no_string_terminators | parse_no_entity_translation;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">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: <ul><li><para>names and values of nodes will not be zero terminated, you have to use <a href=\"#classrapidxml_1_1xml__base_0dae694c8f7e4d89f1003e2f3a15a43c_10dae694c8f7e4d89f1003e2f3a15a43c\" kindref=\"member\">xml_base::name_size()</a> and <a href=\"#classrapidxml_1_1xml__base_aed5ae791b7164c1ee5e649198cbb3db_1aed5ae791b7164c1ee5e649198cbb3db\" kindref=\"member\">xml_base::value_size()</a> functions to determine where name and value ends </para></li><li><para>entities will not be translated </para></li><li><para>whitespace will not be normalized </para></li></ul>\r\nSee <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_398c5476e76102f8bd76c10bb0abbe10_1398c5476e76102f8bd76c10bb0abbe10\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_fastest</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_fastest\r\n\t\t\t\t\t\t\t\t\t\t\t  = parse_non_destructive | parse_no_data_nodes;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">A combination of parse flags resulting in fastest possible parsing, without sacrificing important data. <br/><br/>\r\n See <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_b4f2515265facb42291570307924bd57_1b4f2515265facb42291570307924bd57\">\r\n\t\t\t\tconstant\r\n\t\t\t parse_full</h3><h4>Synopsis</h4><code class=\"synopsis\">const int parse_full\r\n\t\t\t\t\t\t\t\t\t\t\t  = parse_declaration_node | parse_comment_nodes | parse_doctype_node | parse_pi_nodes | parse_validate_closing_tags;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">A combination of parse flags resulting in largest amount of data being extracted. This usually results in slowest parsing. <br/><br/>\r\n See <a href=\"#classrapidxml_1_1xml__document_8338ce6042e7b04d5a42144fb446b69c_18338ce6042e7b04d5a42144fb446b69c\" kindref=\"member\">xml_document::parse()</a> function. </para><p/><h3 class=\"reference-header\" id=\"namespacerapidxml_b08b8d4293c203b69ed6c5ae77ac1907_1b08b8d4293c203b69ed6c5ae77ac1907\">\r\n\t\t\t\tconstant\r\n\t\t\t print_no_indenting</h3><h4>Synopsis</h4><code class=\"synopsis\">const int print_no_indenting\r\n\t\t\t\t\t\t\t\t\t\t\t  = 0x1;\r\n\t\t\t\t\t\t\t\t\t  </code><h4>Description</h4><para xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Printer flag instructing the printer to suppress indenting of XML. See <a href=\"#namespacerapidxml_b94d570fc4c4ab2423813cd0243326b1_1b94d570fc4c4ab2423813cd0243326b1\" kindref=\"member\">print()</a> function. </para><p/></body></html>"
  },
  {
    "path": "test/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.24)\nproject(rapidxml)\n\n# Include the Conan toolchain\ninclude(${CMAKE_CURRENT_SOURCE_DIR}/conan_toolchain.cmake)\n\n# GoogleTest requires at least C++14\nset(CMAKE_CXX_STANDARD 20)\nset(CMAKE_CXX_STANDARD_REQUIRED ON)\noption(RAPIDXML_PERF_TESTS \"Enable (very slow) performance tests\" OFF)\noption(RAPIDXML_SENTRY \"Use Sentry (for tests only)\" ON)\n\nfind_package(GTest)\nfind_package(flxml CONFIG REQUIRED)\n\nif (RAPIDXML_SENTRY)\n    set(SENTRY_BACKEND inproc)\n    find_package(sentry)\nendif(RAPIDXML_SENTRY)\n\nenable_testing()\nadd_executable(rapidxml-test\n        src/parse-simple.cpp\n        src/manipulations.cpp\n        src/round-trips.cpp\n        src/low-level-parse.cpp\n        src/perf.cpp\n        src/iterators.cpp\n        src/xpath.cpp\n        src/main.cc\n)\ntarget_link_libraries(rapidxml-test PRIVATE\n        GTest::gtest\n        flxml::flxml\n)\nif(RAPIDXML_SENTRY)\n    target_link_libraries(rapidxml-test PRIVATE sentry-native::sentry-native)\n    target_compile_definitions(rapidxml-test PRIVATE DWD_GTEST_SENTRY=1)\nendif()\ntarget_include_directories(rapidxml-test\n        PUBLIC\n        ${CMAKE_CURRENT_SOURCE_DIR}\n)\nif (RAPIDXML_PERF_TESTS)\n    message(\"Running performance tests\")\n    file(DOWNLOAD https://www.w3.org/TR/xml/REC-xml-20081126.xml ${CMAKE_CURRENT_BINARY_DIR}/REC-xml-20081126.xml)\n    target_compile_definitions(rapidxml-test PRIVATE RAPIDXML_TESTING=1 RAPIDXML_PERF_TESTS=1)\nelse()\n    message(\"Will skip performance tests\")\n    target_compile_definitions(rapidxml-test PRIVATE RAPIDXML_TESTING=1)\nendif()\n\ninclude(GoogleTest)\ngtest_discover_tests(rapidxml-test)\n"
  },
  {
    "path": "test/conanfile.py",
    "content": "from conan import ConanFile\nfrom conan.tools.cmake import CMakeToolchain, CMake, CMakeDeps\n\nclass FLXML(ConanFile):\n    name = \"flxml-test\"\n    settings = \"os\", \"compiler\", \"build_type\", \"arch\"\n    test_type = \"explicit\"\n\n    def configure(self):\n        self.options[\"sentry-native\"].backend = \"inproc\"\n\n    def requirements(self):\n        self.requires(f'flxml/{self.version}')\n        self.requires(\"sentry-native/0.7.11\")\n        self.requires(\"gtest/1.12.1\")\n\n    def generate(self):\n        deps = CMakeDeps(self)\n        deps.generate()\n        tc = CMakeToolchain(self)\n        tc.user_presets_path = False\n        tc.generate()\n\n    def build(self):\n        cmake = CMake(self)\n        cmake.configure()\n        cmake.build()\n\n    def test(self):\n        if not self.conf.get(\"tools.build:skip_test\"):\n            self.run(\"./rapidxml-test\", env=\"conanrun\")\n"
  },
  {
    "path": "test/sonar-project.properties",
    "content": "sonar.projectKey=dwd-github_rapidxml\nsonar.organization=dwd-github\n\n# This is the name and version displayed in the SonarCloud UI.\n#sonar.projectName=RapidXML\n#sonar.projectVersion=1.0\n\n\n# Path is relative to the sonar-project.properties file. Replace \"\\\" by \"/\" on Windows.\n#sonar.sources=.\n\n# Encoding of the source code. Default is default system encoding\n#sonar.sourceEncoding=UTF-8\n\n\nsonar.exclusions=**/deps/**, **/_deps/**, **/sentry-native/**, **/*.html, **/googletest/**\nsonar.sources=.\nsonar.coverage.exclusions=**/deps/**,**/_deps/**,**/sentry-native/**,**/*.html,**/googletest/**,**/test/**"
  },
  {
    "path": "test/src/iterators.cpp",
    "content": "//\n// Created by dave on 10/07/2024.\n//\n\n#include <gtest/gtest.h>\n#include <list>\n#include <algorithm>\n#include <ranges>\n#include <flxml.h>\n\nTEST(Iterators, Nodes) {\n    std::string xml = \"<children><one/><two/><three/></children>\";\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_full>(xml);\n    int i = 0;\n    for (auto & child : doc.first_node()->children()) {\n        ++i;\n        switch(i) {\n            case 1:\n                EXPECT_EQ(child.name(), \"one\");\n                break;\n            case 2:\n                EXPECT_EQ(child.name(), \"two\");\n                break;\n            case 3:\n                EXPECT_EQ(child.name(), \"three\");\n                break;\n        }\n    }\n    EXPECT_EQ(i, 3);\n}\n\nTEST(Iterators, Attributes) {\n    std::string xml = R\"(<children one=\"1\" two=\"2\" three=\"3\"/>)\";\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_full>(xml);\n    int i = 0;\n    for (auto & child : doc.first_node()->attributes()) {\n        ++i;\n        switch(i) {\n            case 1:\n                EXPECT_EQ(child.name(), \"one\");\n                break;\n            case 2:\n                EXPECT_EQ(child.name(), \"two\");\n                break;\n            case 3:\n                EXPECT_EQ(child.name(), \"three\");\n                break;\n        }\n    }\n    EXPECT_EQ(i, 3);\n}\n\nTEST(Predicates, Nodes) {\n    std::string xml = \"<children><one/><two/><three/></children>\";\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_full>(xml);\n    auto r = doc.first_node()->children();\n    for (auto const & child : r | std::ranges::views::filter([](auto const & n) { return n.name() == \"two\"; })) {\n        EXPECT_EQ(child.name(), \"two\");\n    }\n    auto c = std::ranges::count_if(r, [](auto const & n) { return n.name() == \"two\"; });\n    EXPECT_EQ(c, 1);\n    auto match = std::ranges::find_if(r, [](auto const & n) { return n.name() == \"two\"; });\n    EXPECT_EQ(match->name(), \"two\");\n}\n\nTEST(Predicates, AllNodes) {\n    std::string xml = \"<children><one><two/></one><three><four><five/></four><six/></three></children>\";\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_full>(xml);\n    auto it = flxml::descendant_iterator<>(doc.first_node());\n    EXPECT_EQ(it->name(), \"one\");\n    ++it;\n    EXPECT_EQ(it->name(), \"two\");\n    ++it;\n    EXPECT_EQ(it->name(), \"three\");\n    ++it;\n    EXPECT_EQ(it->name(), \"four\");\n    ++it;\n    EXPECT_EQ(it->name(), \"five\");\n    ++it;\n    EXPECT_EQ(it->name(), \"six\");\n    ++it;\n    EXPECT_FALSE(it.valid());\n}\n\nTEST(Predicates, AllNodesRev) {\n    std::string xml = \"<children><one><two/></one><three><four><five/></four><six/></three></children>\";\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_full>(xml);\n    auto it = flxml::descendant_iterator<>(doc.first_node());\n    EXPECT_EQ(it->name(), \"one\");\n    ++it;\n    EXPECT_EQ(it->name(), \"two\");\n    ++it;\n    EXPECT_EQ(it->name(), \"three\");\n    ++it;\n    EXPECT_EQ(it->name(), \"four\");\n    ++it;\n    EXPECT_EQ(it->name(), \"five\");\n    ++it;\n    EXPECT_EQ(it->name(), \"six\");\n    --it;\n    EXPECT_EQ(it->name(), \"five\");\n    --it;\n    EXPECT_EQ(it->name(), \"four\");\n    --it;\n    EXPECT_EQ(it->name(), \"three\");\n    --it;\n    EXPECT_EQ(it->name(), \"two\");\n    --it;\n    EXPECT_EQ(it->name(), \"one\");\n}\n\nTEST(Predicates, Attributes) {\n    std::string xml = R\"(<children one=\"1\" two=\"2\" three=\"3\"/>)\";\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_full>(xml);\n    auto r = doc.first_node()->attributes();\n    for (auto const & child : r | std::ranges::views::filter([](auto const & n) { return n.name() == \"two\"; })) {\n        EXPECT_EQ(child.name(), \"two\");\n    }\n    auto c = std::ranges::count_if(r, [](auto const & n) { return n.name() == \"two\"; });\n    EXPECT_EQ(c, 1);\n    auto match = std::ranges::find_if(r, [](auto const & n) { return n.name() == \"two\"; });\n    EXPECT_EQ(match->name(), \"two\");\n    auto match2 = std::ranges::find_if(doc.first_node()->attributes(), [](auto const & n) { return n.name() == \"two\"; });\n    EXPECT_EQ(match2->name(), \"two\");\n}\n"
  },
  {
    "path": "test/src/low-level-parse.cpp",
    "content": "//\n// Created by dave on 05/07/2024.\n//\n\n#include <gtest/gtest.h>\n#include <flxml.h>\n\nTEST(Constants, Empty) {\n    flxml::xml_document<> doc;\n    auto empty = doc.nullstr();\n    EXPECT_EQ(empty, \"\");\n    EXPECT_EQ(empty.size(), 0);\n}\n\nTEST(Predicates, Skip) {\n    std::string test_data{\"<simple/>\"};\n    auto start = test_data.c_str();\n    auto end = ++start;\n    flxml::xml_document<>::skip<flxml::xml_document<>::element_name_pred,0>(end);\n    EXPECT_EQ(*end, '/');\n    std::string_view sv({start, end});\n    EXPECT_EQ(sv, \"simple\");\n}\n\nTEST(PredicateBuffer, Skip) {\n    std::string test_data{\"<simple/>\"};\n    auto start = flxml::buffer_ptr(test_data);\n    auto end = ++start;\n    flxml::xml_document<>::skip<flxml::xml_document<>::element_name_pred,0>(end);\n    EXPECT_EQ(*end, '/');\n    std::string_view sv({start, end});\n    EXPECT_EQ(sv, \"simple\");\n}\n\nTEST(Predicates, SkipAndExpand) {\n    std::string test_data{\"&hello;<\"};\n    char * start = const_cast<char *>(test_data.c_str());\n    auto end = flxml::xml_document<>::skip_and_expand_character_refs<\n            flxml::xml_document<>::text_pred,\n            flxml::xml_document<>::text_pure_with_ws_pred,\n            flxml::parse_no_entity_translation>(start);\n    EXPECT_EQ(*end, '<');\n}\n\nTEST(Predicates, SkipAndExpandShort) {\n    std::string test_data{\"&hello;\"};\n    char * start = const_cast<char *>(test_data.c_str());\n    auto end = flxml::xml_document<>::skip_and_expand_character_refs<\n            flxml::xml_document<>::text_pred,\n            flxml::xml_document<>::text_pure_with_ws_pred,\n            flxml::parse_no_entity_translation>(start);\n    EXPECT_EQ(*end, '\\0');\n}\n\nTEST(Predicates, SkipAndExpandShorter) {\n    std::string test_data{\"&hell\"};\n    char * start = const_cast<char *>(test_data.c_str());\n    auto end = flxml::xml_document<>::skip_and_expand_character_refs<\n            flxml::xml_document<>::text_pred,\n            flxml::xml_document<>::text_pure_with_ws_pred,\n            flxml::parse_no_entity_translation>(start);\n    EXPECT_EQ(*end, '\\0');\n}\n\nTEST(ParseFns, ParseBom) {\n    std::string test_data{\"\\xEF\\xBB\\xBF<simple/>\"};\n    char *start = const_cast<char *>(test_data.c_str());\n    flxml::xml_document<> doc;\n    doc.parse_bom<0>(start);\n    EXPECT_EQ(*start, '<');\n}\n\nTEST(ParseFns, ParseBomShort) {\n    std::string test_data{\"\\xEF\\xBB\\xBF\"};\n    char *start = const_cast<char *>(test_data.c_str());\n    flxml::xml_document<> doc;\n    doc.parse_bom<0>(start);\n    EXPECT_EQ(*start, '\\0');\n}\n\nTEST(ParseFns, ParseBomShorter) {\n    std::string test_data{\"\\xEF\\xBB\"};\n    char *start = const_cast<char *>(test_data.c_str());\n    flxml::xml_document<> doc;\n    doc.parse_bom<0>(start);\n    EXPECT_EQ(*start, '\\xEF');\n}\n"
  },
  {
    "path": "test/src/main.cc",
    "content": "//\n// Created by dave on 30/07/2024.\n//\n\n#include \"gtest/gtest.h\"\n#ifdef DWD_GTEST_SENTRY\n#include <sentry.h>\n\nclass EventListener : public ::testing::TestEventListener {\n    sentry_transaction_context_t *tx_ctx = nullptr;\n    sentry_transaction_t *tx = nullptr;\n    sentry_span_t *main_span = nullptr;\n    sentry_span_t *suite_span = nullptr;\n    sentry_span_t *test_span = nullptr;\n    std::string const & m_progname;\npublic:\n    EventListener(std::string const & progname) : m_progname(progname) {}\n    ~EventListener() override = default;\n\n    // Override this to define how to set up the environment.\n    void OnTestProgramStart(const ::testing::UnitTest & u) override {\n        sentry_options_t *options = sentry_options_new();\n        sentry_options_set_traces_sample_rate(options, 1.0);\n        sentry_init(options);\n    }\n    void OnTestProgramEnd(const ::testing::UnitTest &) override {\n        sentry_shutdown();\n    }\n\n    void OnTestStart(::testing::TestInfo const & test_info) override {\n        const char * testName = test_info.name();\n        std::string tname = test_info.test_suite_name();\n        tname += \".\";\n        tname += testName;\n        test_span = sentry_span_start_child(\n                suite_span,\n                \"test\",\n                tname.c_str()\n        );\n    }\n\n    // Override this to define how to tear down the environment.\n    void OnTestEnd(const ::testing::TestInfo & ti) override {\n        if (ti.result()->Failed()) {\n            sentry_span_set_status(test_span, sentry_span_status_t::SENTRY_SPAN_STATUS_INTERNAL_ERROR);\n        }\n        sentry_span_finish(test_span); // Mark the span as finished\n    }\n\n    void OnTestIterationStart(const testing::UnitTest &unit_test, int iteration) override {\n        tx_ctx = sentry_transaction_context_new(\n                m_progname.c_str(),\n                \"googletest\"\n        );\n        tx = sentry_transaction_start(tx_ctx, sentry_value_new_null());\n        main_span = sentry_transaction_start_child(\n                tx,\n                \"googletest\",\n                m_progname.c_str()\n        );\n    }\n\n    void OnEnvironmentsSetUpStart(const testing::UnitTest &unit_test) override {\n\n    }\n\n    void OnEnvironmentsSetUpEnd(const testing::UnitTest &unit_test) override {\n\n    }\n\n    void OnTestSuiteStart(const testing::TestSuite &suite) override {\n        suite_span = sentry_span_start_child(\n                main_span,\n                \"test.suite\",\n                suite.name()\n        );\n        TestEventListener::OnTestSuiteStart(suite);\n    }\n\n    void OnTestCaseStart(const testing::TestCase &aCase) override {\n        TestEventListener::OnTestCaseStart(aCase);\n    }\n\n    void OnTestDisabled(const testing::TestInfo &info) override {\n        TestEventListener::OnTestDisabled(info);\n    }\n\n    void OnTestPartResult(const testing::TestPartResult &test_part_result) override {\n        sentry_set_span(test_span);\n        auto val = sentry_value_new_breadcrumb(\"test\", test_part_result.message());\n        sentry_add_breadcrumb(val);\n        if (test_part_result.failed()) {\n            auto ev = sentry_value_new_event();\n            auto exc = sentry_value_new_exception(\"GoogleTest\", test_part_result.message());\n            sentry_value_set_stacktrace(exc, nullptr, 0);\n            sentry_event_add_exception(ev, exc);\n            sentry_capture_event(ev);\n        }\n    }\n\n    void OnTestSuiteEnd(const testing::TestSuite &suite) override {\n        TestEventListener::OnTestSuiteEnd(suite);\n        if (suite.failed_test_count() > 0) {\n            sentry_span_set_status(suite_span, sentry_span_status_t::SENTRY_SPAN_STATUS_INTERNAL_ERROR);\n        }\n        sentry_span_finish(suite_span); // Mark the span as finished\n    }\n\n    void OnTestCaseEnd(const testing::TestCase &aCase) override {\n        TestEventListener::OnTestCaseEnd(aCase);\n    }\n\n    void OnEnvironmentsTearDownStart(const testing::UnitTest &unit_test) override {\n\n    }\n\n    void OnEnvironmentsTearDownEnd(const testing::UnitTest &unit_test) override {\n\n    }\n\n    void OnTestIterationEnd(const testing::UnitTest &unit_test, int iteration) override {\n        if (unit_test.failed_test_count() > 0) {\n            sentry_span_set_status(main_span, sentry_span_status_t::SENTRY_SPAN_STATUS_INTERNAL_ERROR);\n            sentry_transaction_set_status(tx, sentry_span_status_t::SENTRY_SPAN_STATUS_INTERNAL_ERROR);\n        }\n        sentry_span_finish(main_span); // Mark the span as finished\n        sentry_transaction_finish(tx);\n    }\n};\n#endif\n\nint main(int argc, char ** argv) {\n    std::string progname(argv[0]);\n    auto slash = progname.find_last_of(\"/\\\\\");\n    if (slash != std::string::npos) {\n        progname = progname.substr(slash + 1);\n    }\n    ::testing::InitGoogleTest(&argc, argv);\n    auto & listeners = ::testing::UnitTest::GetInstance()->listeners();\n#ifdef DWD_GTEST_SENTRY\n    listeners.Append(new EventListener(progname));\n#endif\n    auto ret =  RUN_ALL_TESTS();\n    return ret;\n}\n"
  },
  {
    "path": "test/src/manipulations.cpp",
    "content": "//\n// Created by dwd on 01/07/24.\n//\n\n#include <gtest/gtest.h>\n\n#include <flxml.h>\n#include <flxml/print.h>\n\nnamespace {\n    auto print(flxml::xml_document<> & doc) {\n        std::string output;\n        flxml::print(std::back_inserter(output), *doc.first_node());\n        return output;\n    }\n}\n\nTEST(Create, Node) {\n    flxml::xml_document<> doc;\n    auto node = doc.allocate_node(flxml::node_element, \"fish\", \"cakes\");\n    doc.append_node(node);\n\n    EXPECT_EQ(\n        print(doc),\n        \"<fish>cakes</fish>\\n\"\n    );\n}\n\nTEST(Create, NodeEmpty) {\n    flxml::xml_document<> doc;\n    auto node = doc.allocate_node(flxml::node_element, \"fish\");\n    doc.append_node(node);\n\n    EXPECT_EQ(\n        print(doc),\n        \"<fish/>\\n\"\n    );\n}\n\nTEST(Create, Node2) {\n    flxml::xml_document<> doc;\n    auto node = doc.allocate_node(flxml::node_element, \"fish\", \"cakes\");\n    doc.append_node(node);\n\n    EXPECT_EQ(\n        print(doc),\n        \"<fish>cakes</fish>\\n\"\n    );\n}\n\nstatic std::string s = \"tuna\";\n\nstd::string const & fn() {\n    return s;\n}\n\nTEST(Create, NodeAttr) {\n    flxml::xml_document<> doc;\n    auto node = doc.allocate_node(flxml::node_element, \"fish\", \"cakes\");\n    auto haddock = doc.allocate_attribute(\"id\", \"haddock\");\n    node->append_attribute(haddock);\n    doc.append_node(node);\n\n    EXPECT_EQ(\n        print(doc),\n        \"<fish id=\\\"haddock\\\">cakes</fish>\\n\"\n    );\n\n    const std::string & s2 = fn();\n    const flxml::xml_attribute<>::view_type & sv{s2};\n\n    auto tuna = doc.allocate_attribute(\"not-id\", fn());\n    // These check that the same buffer is being used throughout, instead of creating temporaries.\n    EXPECT_EQ(s.data(), s2.data());\n    EXPECT_EQ(s.data(), sv.data());\n    EXPECT_EQ(s.data(), tuna->value().data());\n    node->append_attribute(tuna);\n    EXPECT_EQ(haddock->next_attribute(), tuna);\n    EXPECT_EQ(tuna->parent(), node);\n    EXPECT_EQ(\n        print(doc),\n        \"<fish id=\\\"haddock\\\" not-id=\\\"tuna\\\">cakes</fish>\\n\"\n    );\n    node->remove_attribute(tuna);\n    EXPECT_EQ(haddock->next_attribute(), nullptr);\n    EXPECT_EQ(tuna->parent(), nullptr);\n    EXPECT_EQ(\n        print(doc),\n        \"<fish id=\\\"haddock\\\">cakes</fish>\\n\"\n    );\n    node->prepend_attribute(tuna);\n    EXPECT_EQ(\n        print(doc),\n        \"<fish not-id=\\\"tuna\\\" id=\\\"haddock\\\">cakes</fish>\\n\"\n    );\n    node->value(\"pie\");\n    EXPECT_EQ(\n        print(doc),\n        \"<fish not-id=\\\"tuna\\\" id=\\\"haddock\\\">pie</fish>\\n\"\n    );\n    node->remove_all_attributes();\n    EXPECT_EQ(\n        print(doc),\n        \"<fish>pie</fish>\\n\"\n    );\n    auto child = node->append_element({\"urn:xmpp:fish:0\", \"shark\"}, fn());\n    EXPECT_EQ(s.data(), child->value().data());\n    EXPECT_EQ(\n            print(doc),\n            \"<fish>\\n\\t<shark xmlns=\\\"urn:xmpp:fish:0\\\">tuna</shark>\\n</fish>\\n\"\n    );\n    child->append_element({\"urn:xmpp:fish:0\", \"species\"}, \"tiger\");\n    EXPECT_EQ(\n            print(doc),\n            \"<fish>\\n\\t<shark xmlns=\\\"urn:xmpp:fish:0\\\">\\n\\t\\t<species>tiger</species>\\n\\t</shark>\\n</fish>\\n\"\n    );\n}\n"
  },
  {
    "path": "test/src/parse-simple.cpp",
    "content": "//\n// Created by dwd on 1/13/24.\n//\n\n#include <gtest/gtest.h>\n#include <flxml.h>\n\nTEST(Parser, SingleElement) {\n    char doc_text[] = \"<single-element/>\";\n    flxml::xml_document<> doc;\n    doc.parse<0>(doc_text);\n\n    auto node = doc.first_node();\n    EXPECT_NE(nullptr, node);\n    EXPECT_FALSE(node->name().empty());\n    EXPECT_EQ(\"single-element\", node->name());\n    doc.validate();\n}\n\nTEST(Parser, DefaultElementNS) {\n    char doc_text[] = \"<element xmlns='this'><child/></element>\";\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_fastest | flxml::parse_parse_one>(doc_text);\n\n    auto node = doc.first_node();\n    EXPECT_NE(nullptr, node);\n    EXPECT_FALSE(node->name().empty());\n    EXPECT_EQ(\"element\", node->name());\n    EXPECT_EQ(node->xmlns(), \"this\");\n    auto child = node->first_node();\n    EXPECT_EQ(child->name(), \"child\");\n    EXPECT_EQ(child->xmlns(), \"this\");\n    doc.validate();\n    auto no_node = child->next_sibling();\n    EXPECT_THROW(no_node->xmlns(), flxml::no_such_node);\n}\n\nTEST(Parser, UnboundPrefix) {\n    flxml::xml_document<> doc;\n    char doc_text[] = \"<pfx:single-element/>\";\n    doc.parse<0>(doc_text);\n\n    auto node = doc.first_node();\n    EXPECT_EQ(\"single-element\", node->name());\n    EXPECT_THROW(\n        doc.validate(),\n        flxml::element_xmlns_unbound\n        );\n}\n\nTEST(Parser, DuplicateAttribute) {\n    flxml::xml_document<> doc;\n    char doc_text[] = \"<single-element attr='one' attr=\\\"two\\\"/>\";\n    doc.parse<0>(doc_text);\n\n    auto node = doc.first_node();\n    EXPECT_EQ(\"single-element\", node->name());\n    EXPECT_THROW(\n        doc.validate(),\n        flxml::duplicate_attribute\n        );\n}\n\nTEST(Parser, UnboundAttrPrefix) {\n    flxml::xml_document<> doc;\n    char doc_text[] = \"<single-element pfx1:attr='one' attr=\\\"two\\\"/>\";\n    doc.parse<0>(doc_text);\n\n    auto node = doc.first_node();\n    EXPECT_EQ(\"single-element\", node->name());\n    auto attr = node->first_attribute();\n    EXPECT_THROW(\n        doc.validate(),\n        flxml::attr_xmlns_unbound\n        );\n    EXPECT_THROW(\n        attr->xmlns(),\n        flxml::attr_xmlns_unbound\n    );\n}\n\n\nTEST(Parser, DuplicateAttrPrefix) {\n    flxml::xml_document<> doc;\n    char doc_text[] = \"<single-element pfx1:attr='one' pfx2:attr=\\\"two\\\" xmlns:pfx1='urn:fish' xmlns:pfx2='urn:fish'/>\";\n    doc.parse<0>(doc_text);\n\n    auto node = doc.first_node();\n    assert(std::string(\"single-element\") == node->name());\n    EXPECT_THROW(\n        doc.validate(),\n        flxml::duplicate_attribute\n    );\n}\n\n\nTEST(Parser, Xmlns) {\n    flxml::xml_document<> doc;\n    char doc_text[] = \"<pfx:single xmlns:pfx='urn:xmpp:example'/>\";\n    doc.parse<0>(doc_text);\n\n    auto node = doc.first_node();\n    EXPECT_EQ(\"single\", node->name());\n    EXPECT_EQ(\"pfx\", node->prefix());\n    EXPECT_EQ(\"urn:xmpp:example\", node->xmlns());\n    doc.validate();\n}\n\nTEST(Parser, ChildXmlns) {\n    flxml::xml_document<> doc;\n    char doc_text[] = \"<pfx:single xmlns:pfx='urn:xmpp:example' foo='bar'><pfx:firstchild/><child xmlns='urn:potato'/><pfx:child/></pfx:single>\";\n    doc.parse<0>(doc_text);\n\n    auto node = doc.first_node();\n    EXPECT_EQ(\"single\", node->name());\n    auto child = node->first_node({}, \"urn:potato\");\n    ASSERT_NE(nullptr, child);\n    EXPECT_EQ(\"child\", child->name());\n    EXPECT_EQ(\"urn:potato\", child->xmlns());\n    child = node->first_node();\n    EXPECT_EQ(\"firstchild\", child->name());\n    EXPECT_EQ(\"urn:xmpp:example\", child->xmlns());\n    child = child->next_sibling();\n    EXPECT_EQ(\"child\", child->name());\n    EXPECT_EQ(\"urn:potato\", child->xmlns());\n    child = child->next_sibling();\n    EXPECT_EQ(\"child\", child->name());\n    EXPECT_EQ(\"urn:xmpp:example\", child->xmlns());\n    child = node->first_node(\"child\");\n    EXPECT_EQ(\"child\", child->name());\n    EXPECT_EQ(\"urn:xmpp:example\", child->xmlns());\n    child = node->first_node()->next_sibling({}, \"urn:xmpp:example\");\n    EXPECT_EQ(\"child\", child->name());\n    EXPECT_EQ(\"urn:xmpp:example\", child->xmlns());\n    child = node->first_node()->next_sibling(\"child\");\n    // This will default to the same namespace as the first child ndoe.\n    EXPECT_EQ(\"child\", child->name());\n    EXPECT_EQ(\"urn:xmpp:example\", child->xmlns());\n    auto attr = node->first_attribute();\n    EXPECT_EQ(attr->xmlns(), \"http://www.w3.org/2000/xmlns/\");\n    EXPECT_EQ(attr->local_name(), \"pfx\");\n    EXPECT_EQ(attr->name(), \"xmlns:pfx\");\n    EXPECT_EQ(attr->value(), \"urn:xmpp:example\");\n    attr = attr->next_attribute();\n    EXPECT_EQ(attr->xmlns(), \"\");\n    EXPECT_EQ(attr->local_name(), \"foo\");\n    EXPECT_EQ(attr->name(), \"foo\");\n    EXPECT_EQ(attr->value(), \"bar\");\n    doc.validate();\n}\n\nTEST(Parser, HandleEOF){\n    flxml::xml_document<> doc;\n    char doc_text[] = \"<open_element>\";\n    EXPECT_THROW(\n        doc.parse<0>(doc_text),\n        flxml::eof_error\n    );\n}\n\nTEST(ParseOptions, Fastest) {\n    flxml::xml_document<> doc;\n    char doc_text[] = \"<pfx:single xmlns:pfx='urn:xmpp:example'><pfx:firstchild/><child xmlns='urn:potato'/><pfx:child/></pfx:single>\";\n    doc.parse<flxml::parse_fastest>(doc_text);\n\n    auto node = doc.first_node();\n    EXPECT_EQ(\"single\", node->name());\n    EXPECT_EQ(\"urn:xmpp:example\", node->xmlns());\n    auto child = node->first_node({}, \"urn:potato\");\n    ASSERT_NE(nullptr, child);\n    EXPECT_EQ(\"child\", child->name());\n    EXPECT_EQ(\"urn:potato\", child->xmlns());\n    child = node->first_node();\n    EXPECT_EQ(\"firstchild\", child->name());\n    EXPECT_EQ(\"urn:xmpp:example\", child->xmlns());\n    child = node->first_node(\"child\");\n    EXPECT_EQ(\"child\", child->name());\n    EXPECT_EQ(\"urn:xmpp:example\", child->xmlns());\n    doc.validate();\n}\n\nTEST(ParseOptions, OpenOnly) {\n    flxml::xml_document<> doc;\n    char doc_text[] = \"<pfx:single xmlns:pfx='urn:xmpp:example'>\";\n    doc.parse<flxml::parse_open_only>(doc_text);\n\n    auto node = doc.first_node();\n    EXPECT_EQ(\"single\", node->name());\n    EXPECT_EQ(\"pfx\", node->prefix());\n    EXPECT_EQ(\"urn:xmpp:example\", node->xmlns());\n    doc.validate();\n}\n\nTEST(ParseOptions, ParseOne) {\n    flxml::xml_document<> doc;\n    char doc_text[] = \"<pfx:single xmlns='jabber:client' xmlns:pfx='urn:xmpp:example'><pfx:features><feature1/><feature2/></pfx:features><message to='me@mydomain.com' from='you@yourdomcina.com' xml:lang='en'><body>Hello!</body></message>\";\n    const char * text = doc.parse<flxml::parse_open_only>(doc_text);\n\n    {\n        auto node = doc.first_node();\n        EXPECT_EQ(\"single\", node->name());\n        EXPECT_EQ(\"pfx\", node->prefix());\n        EXPECT_EQ(\"urn:xmpp:example\", node->xmlns());\n        EXPECT_STREQ(\n                \"<pfx:features><feature1/><feature2/></pfx:features><message to='me@mydomain.com' from='you@yourdomcina.com' xml:lang='en'><body>Hello!</body></message>\",\n                text);\n    }\n    doc.validate();\n    unsigned counter = 0;\n    while (*text) {\n        flxml::xml_document<> subdoc;\n        text = subdoc.parse<flxml::parse_parse_one>(text, &doc);\n        auto node = subdoc.first_node();\n        ASSERT_NE(nullptr, node);\n        switch(++counter) {\n        case 1:\n            EXPECT_EQ(\"features\", node->name());\n            EXPECT_EQ(\"urn:xmpp:example\", node->xmlns());\n            break;\n        case 2:\n            EXPECT_EQ(\"message\", node->name());\n            EXPECT_EQ(\"jabber:client\", node->xmlns());\n            break;\n        default:\n            FAIL();\n        }\n        subdoc.validate();\n    }\n}\n\nTEST(ParseOptions, OpenOnlyFastest) {\n    flxml::xml_document<> doc;\n    char doc_text[] = \"<pfx:single xmlns='jabber:client' xmlns:pfx='urn:xmpp:example'><pfx:features><feature1/><feature2/></pfx:features><message to='me@mydomain.com' from='you@yourdomcina.com' xml:lang='en'><body>Hello!</body></message>\";\n    const char * text = doc.parse<flxml::parse_open_only|flxml::parse_fastest>(doc_text);\n\n    {\n        auto node = doc.first_node();\n        EXPECT_EQ(\"single\", node->name());\n        EXPECT_EQ(\"pfx\", node->prefix());\n        EXPECT_EQ(\"urn:xmpp:example\", node->xmlns());\n        EXPECT_STREQ(\n                \"<pfx:features><feature1/><feature2/></pfx:features><message to='me@mydomain.com' from='you@yourdomcina.com' xml:lang='en'><body>Hello!</body></message>\",\n                text);\n    }\n    doc.validate();\n    unsigned counter = 0;\n    while (*text) {\n        flxml::xml_document<> subdoc;\n        text = subdoc.parse<flxml::parse_parse_one>(text, &doc);\n        auto node = subdoc.first_node();\n        ASSERT_NE(nullptr, node);\n        switch(++counter) {\n        case 1:\n            EXPECT_EQ(\"features\", node->name());\n            EXPECT_EQ(\"urn:xmpp:example\", node->xmlns());\n            break;\n        case 2:\n            EXPECT_EQ(\"message\", node->name());\n            EXPECT_EQ(\"jabber:client\", node->xmlns());\n            break;\n        default:\n            FAIL();\n        }\n        subdoc.validate();\n    }\n}\n\nTEST(Parser_Emoji, Single) {\n    std::string foo{\"<h>&apos;</h>\"};\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_default>(foo);\n    EXPECT_EQ(\"'\", doc.first_node()->value());\n}\n\nTEST(Parser_Emoji, SingleUni) {\n    std::string foo{\"<h>&#1234;</h>\"};\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_default>(foo);\n    EXPECT_EQ(\"\\xD3\\x92\", doc.first_node()->value());\n}\n\nTEST(Parser_Emoji, SingleEmoji) {\n    std::string foo{\"<h>&#128512;</h>\"};\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_default>(foo);\n    EXPECT_EQ(\"\\xF0\\x9F\\x98\\x80\", doc.first_node()->value());\n    EXPECT_EQ(4, doc.first_node()->value().size());\n}\n\nTEST(Parser_Emoji, SingleEmojiReuse) {\n    std::string bar(\"<h>Sir I bear a rhyme excelling in mystic verse and magic spelling &#128512;</h>\");\n    flxml::xml_document<> doc;\n    flxml::xml_document<> parent_doc;\n    parent_doc.parse<flxml::parse_default|flxml::parse_open_only>(\"<open>\");\n    doc.parse<flxml::parse_default>(bar, &parent_doc);\n    EXPECT_EQ(\"Sir I bear a rhyme excelling in mystic verse and magic spelling \\xF0\\x9F\\x98\\x80\", doc.first_node()->value());\n    auto doc_a = doc.first_node()->document();\n    doc.first_node()->value(doc_a->allocate_string(\"Sausages are the loneliest fruit, and are but one of the strange things I have witnessed in my long and interesting life.\"));\n    EXPECT_EQ(\"Sausages are the loneliest fruit, and are but one of the strange things I have witnessed in my long and interesting life.\", doc.first_node()->value());\n    bar = \"<h>&#128512;</h>\";\n    doc.parse<flxml::parse_default>(bar, &parent_doc);\n    EXPECT_EQ(\"\\xF0\\x9F\\x98\\x80\", doc.first_node()->value());\n    EXPECT_EQ(4, doc.first_node()->value().size());\n}\n\n"
  },
  {
    "path": "test/src/perf.cpp",
    "content": "//\n// Created by dave on 07/07/2024.\n//\n\n#include <flxml.h>\n#include <flxml/utils.h>\n\n#include <gtest/gtest.h>\n#include <numeric>\n#include \"flxml/print.h\"\n#include \"flxml/iterators.h\"\n\nconst auto xml_sample_file = \"REC-xml-20081126.xml\";\n\n#ifdef RAPIDXML_PERF_TESTS\n#define PERF_TEST() (void)0\n#else\n#define PERF_TEST() GTEST_SKIP() << \"Skipping performance test\"\n#endif\n\nTEST(Perf, Parse) {\n    using std::chrono::high_resolution_clock;\n    using std::chrono::duration_cast;\n    using std::chrono::microseconds;\n\n    PERF_TEST();\n    flxml::file source(xml_sample_file);\n\n    std::vector<unsigned long long> timings;\n    for (auto i = 0; i != 1000; ++i) {\n        flxml::xml_document<> doc;\n        auto t1 = high_resolution_clock::now();\n        doc.parse<flxml::parse_full>(source.data());\n        auto t2 = high_resolution_clock::now();\n        auto ms_int = duration_cast<microseconds>(t2 - t1);\n        timings.push_back(ms_int.count());\n    }\n    auto total = 0ULL;\n    for (auto t : timings) {\n        total += t / 1000;\n    }\n    std::cout << \"Execution time: \" << total << \" us\\n\";\n}\n\nTEST(Perf, Parse2) {\n    using std::chrono::high_resolution_clock;\n    using std::chrono::duration_cast;\n    using std::chrono::microseconds;\n\n    PERF_TEST();\n    flxml::file source(xml_sample_file);\n\n    std::vector<unsigned long long> timings;\n    for (auto i = 0; i != 1000; ++i) {\n        flxml::xml_document<> doc;\n        std::string_view sv{source.data(), source.size() - 1}; // Drop the NUL.\n        auto t1 = high_resolution_clock::now();\n        doc.parse<flxml::parse_full>(sv);\n        auto t2 = high_resolution_clock::now();\n        auto ms_int = duration_cast<microseconds>(t2 - t1);\n        timings.push_back(ms_int.count());\n    }\n    auto total = 0ULL;\n    for (auto t : timings) {\n        total += t / 1000;\n    }\n    std::cout << \"Execution time: \" << total << \" us\\n\";\n}\n\nTEST(Perf, PrintClean) {\n    using std::chrono::high_resolution_clock;\n    using std::chrono::duration_cast;\n    using std::chrono::microseconds;\n\n    PERF_TEST();\n    flxml::file source(xml_sample_file);\n\n    std::vector<unsigned long long> timings;\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_full>(source.data());\n    for (auto i = 0; i != 1000; ++i) {\n        std::string output;\n        auto t1 = high_resolution_clock::now();\n        flxml::print(std::back_inserter(output), doc);\n        auto t2 = high_resolution_clock::now();\n        auto ms_int = duration_cast<microseconds>(t2 - t1);\n        timings.push_back(ms_int.count());\n    }\n    auto total = 0ULL;\n    for (auto t : timings) {\n        total += t / 1000;\n    }\n    std::cout << \"Execution time: \" << total << \" us\\n\";\n}\n\nTEST(Perf, PrintDirty) {\n    using std::chrono::high_resolution_clock;\n    using std::chrono::duration_cast;\n    using std::chrono::microseconds;\n\n    PERF_TEST();\n    flxml::file source(xml_sample_file);\n\n    std::vector<unsigned long long> timings;\n    flxml::xml_document<> doc_o;\n    doc_o.parse<flxml::parse_full>(source.data());\n    flxml::xml_document<> doc;\n    for (auto & child : flxml::children(doc_o)) {\n        doc.append_node(doc.clone_node(&child, true));\n    }\n    for (auto i = 0; i != 1000; ++i) {\n        std::string output;\n        auto t1 = high_resolution_clock::now();\n        flxml::print(std::back_inserter(output), doc);\n        auto t2 = high_resolution_clock::now();\n        auto ms_int = duration_cast<microseconds>(t2 - t1);\n        timings.push_back(ms_int.count());\n    }\n    auto total = 0ULL;\n    for (auto t : timings) {\n        total += t / 1000;\n    }\n    std::cout << \"Execution time: \" << total << \" us\\n\";\n}\n\n"
  },
  {
    "path": "test/src/round-trips.cpp",
    "content": "//\n// Created by dave on 04/07/2024.\n//\n\n#include <gtest/gtest.h>\n#include <flxml.h>\n#include <flxml/print.h>\n\nnamespace {\n    auto print(flxml::xml_document<> & doc) {\n        std::string output;\n        flxml::print(std::back_inserter(output), doc, flxml::print_no_indenting);\n        return output;\n    }\n}\n\nTEST(RoundTrip, Simple) {\n    const char input[] = \"<simple/>\";\n    std::vector<char> buffer{input, input + sizeof(input)};\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_full>(buffer.data());\n    auto output = print(doc);\n    // Have we parsed correctly?\n    EXPECT_EQ(input, output);\n    // Have we mutated the underlying buffer?\n    EXPECT_EQ(input, std::string(buffer.data(), buffer.size() - 1));\n}\n\nTEST(RoundTrip, SimpleMod) {\n    const char input[] = \"<pfx:simple xmlns:pfx=\\\"this\\\"><pfx:that/></pfx:simple>\";\n    std::vector<char> buffer{input, input + sizeof(input)};\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_full>(buffer.data());\n    auto output = print(doc);\n    // Have we parsed correctly?\n    EXPECT_EQ(input, output);\n    // Have we mutated the underlying buffer?\n    EXPECT_EQ(input, std::string(buffer.data(), buffer.size() - 1));\n    auto that = doc.first_node()->first_node();\n    doc.first_node()->remove_node(that);\n    auto output2 = print(doc);\n    EXPECT_EQ(output2, \"<pfx:simple xmlns:pfx=\\\"this\\\"/>\");\n    std::string xmlns = \"that\";\n    std::string name = \"this\";\n    auto check = doc.first_node()->append_element(name, \"the other\");\n    doc.first_node()->append_element(name, \"another'\");\n    EXPECT_EQ(name, \"this\");\n    EXPECT_EQ(check->name(), name);\n    EXPECT_EQ(check->name().data(), name.data());\n    doc.first_node()->append_element(\"odd\", \"the other\");\n    doc.first_node()->append_element({xmlns, name}, \"the other\");\n    EXPECT_EQ(name, \"this\");\n    EXPECT_EQ(check->name(), name);\n    EXPECT_EQ(check->name().data(), name.data());\n    doc.first_node()->append_element({\"this\", \"that\"}, \"the other\");\n    doc.first_node()->append_element(name, \"last time\");\n    EXPECT_EQ(name, \"this\");\n    EXPECT_EQ(check->name(), name);\n    EXPECT_EQ(check->name().data(), name.data());\n    auto output3 = print(doc);\n    EXPECT_EQ(name, \"this\");\n    EXPECT_EQ(check->name(), name);\n    EXPECT_EQ(check->name().data(), name.data());\n    EXPECT_EQ(output3, \"<pfx:simple xmlns:pfx=\\\"this\\\"><this>the other</this><this>another&apos;</this><odd>the other</odd><this xmlns=\\\"that\\\">the other</this><pfx:that>the other</pfx:that><this>last time</this></pfx:simple>\");\n    flxml::xml_document<> doc2;\n    doc2.clone_node(doc.first_node(), true);\n    auto output4 = print(doc);\n    EXPECT_EQ(output3, output4);\n}\n\nTEST(RoundTrip, SimpleApos) {\n    const char input[] = \"<simple arg=\\\"'\\\"/>\";\n    std::vector<char> buffer{input, input + sizeof(input)};\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_full>(buffer.data());\n    auto output = print(doc);\n    // Have we parsed correctly?\n    flxml::xml_document<> doc2;\n    for (auto & child : flxml::children(doc)) {\n        doc2.append_node(doc2.clone_node(&child, true));\n    }\n    EXPECT_EQ(input, print(doc2));\n    EXPECT_EQ(input, output);\n    // Have we mutated the underlying buffer?\n    EXPECT_EQ(input, std::string(buffer.data(), buffer.size() - 1));\n}\n\nTEST(RoundTrip, SimpleApos2) {\n    const char input[] = \"<simple arg=\\\"&apos;\\\"/>\";\n    const char expected[] = \"<simple arg=\\\"'\\\"/>\";\n    std::vector<char> buffer{input, input + sizeof(input)};\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_full>(buffer.data());\n    auto output = print(doc);\n    EXPECT_EQ(doc.first_node()->first_attribute()->value(), \"'\");\n    // Have we parsed correctly?\n    flxml::xml_document<> doc2;\n    for (auto & child : flxml::children(doc)) {\n        doc2.append_node(doc2.clone_node(&child, true));\n    }\n    EXPECT_EQ(expected, print(doc2));\n    EXPECT_EQ(expected, output);\n    // Have we mutated the underlying buffer?\n    EXPECT_EQ(input, std::string(buffer.data(), buffer.size() - 1));\n}\n\nTEST(RoundTrip, SimpleLtBody) {\n    const char input[] = \"<simple arg=\\\"&apos;\\\">&lt;</simple>\";\n    const char expected[] = \"<simple arg=\\\"'\\\">&lt;</simple>\";\n    std::vector<char> buffer{input, input + sizeof(input)};\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_full>(buffer.data());\n    auto output = print(doc);\n    EXPECT_EQ(doc.first_node()->value(), \"<\");\n    EXPECT_EQ(doc.first_node()->first_attribute()->value(), \"'\");\n    // Have we parsed correctly?\n    flxml::xml_document<> doc2;\n    for (auto & child : flxml::children(doc)) {\n        doc2.append_node(doc2.clone_node(&child, true));\n    }\n    EXPECT_EQ(expected, print(doc2));\n    EXPECT_EQ(expected, output);\n    // Have we mutated the underlying buffer?\n    EXPECT_EQ(input, std::string(buffer.data(), buffer.size() - 1));\n}\n\nTEST(RoundTrip, MutateBody) {\n    const char input[] = \"<simple arg=\\\"&apos;\\\">&lt;</simple>\";\n    const char expected[] = \"<simple arg=\\\"'\\\">&lt;</simple>\";\n    const char expected2[] = \"<simple arg=\\\"'\\\">new value</simple>\";\n    std::vector<char> buffer{input, input + sizeof(input)};\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_full>(buffer.data());\n    auto output = print(doc);\n    EXPECT_EQ(expected, output);\n    // Have we mutated the underlying buffer?\n    EXPECT_EQ(input, std::string(buffer.data(), buffer.size() - 1));\n    doc.first_node()->value(\"new value\");\n    EXPECT_EQ(doc.first_node()->value_raw(), \"\");\n    EXPECT_EQ(doc.first_node()->value(), \"new value\");\n    EXPECT_EQ(expected2, print(doc));\n}\n\nTEST(RoundTrip, Everything) {\n    const char input[] = \"<?xml charset='utf-8' ?><!DOCTYPE ><simple arg=\\\"&apos;\\\"><!-- Comment here --></simple>\";\n    const char expected[] = \"<?xml charset=\\\"utf-8\\\"?><!DOCTYPE ><simple arg=\\\"'\\\"><!-- Comment here --></simple>\";\n    std::vector<char> buffer{input, input + sizeof(input)};\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_full>(buffer.data());\n    auto output = print(doc);\n    flxml::xml_document<> doc2;\n    for (auto & child : flxml::children(doc)) {\n        doc2.append_node(doc2.clone_node(&child, true));\n    }\n    EXPECT_EQ(expected, print(doc2));\n    // Have we parsed correctly?\n    EXPECT_EQ(expected, output);\n    // Have we mutated the underlying buffer?\n    EXPECT_EQ(input, std::string(buffer.data(), buffer.size() - 1));\n}\n\nTEST(RoundTrip, EverythingStream) {\n    const char input[] = \"<?xml charset='utf-8' ?><!DOCTYPE ><simple arg=\\\"&apos;\\\"><!-- Comment here --></simple>\";\n    const char expected[] = \"<?xml charset=\\\"utf-8\\\"?>\\n<!DOCTYPE >\\n<simple arg=\\\"'\\\">\\n\\t<!-- Comment here -->\\n</simple>\\n\\n\";\n    std::vector<char> buffer{input, input + sizeof(input) - 1};\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_full>(buffer);\n    std::stringstream ss1;\n    ss1 << doc;\n    auto output = ss1.str();\n    flxml::xml_document<> doc2;\n    for (auto & child : doc.children()) {\n        doc2.append_node(doc2.clone_node(&child, true));\n    }\n    std::stringstream ss2;\n    ss2 << doc2;\n    EXPECT_EQ(expected, ss2.str());\n    // Have we parsed correctly?\n    EXPECT_EQ(expected, output);\n    // Have we mutated the underlying buffer?\n    EXPECT_EQ(input, std::string(buffer.data(), buffer.size()));\n}\n"
  },
  {
    "path": "test/src/xpath.cpp",
    "content": "//\n// Created by dave on 29/07/2024.\n//\n\n#include <gtest/gtest.h>\n#include <flxml/predicates.h>\n\nTEST(XPath, parse) {\n    std::string xpath_string = \"//\";\n    std::string_view sv{xpath_string};\n    auto xp = flxml::xpath<>::parse(sv);\n    EXPECT_EQ(sv.length(), 0);\n    EXPECT_NE(xp.get(), nullptr);\n    EXPECT_EQ(xp->chain().size(), 1);\n}\n\nTEST(XPath, parse2) {\n    std::string xpath_string = \"//child\";\n    std::string_view sv{xpath_string};\n    auto xp = flxml::xpath<>::parse(sv);\n    EXPECT_EQ(sv.length(), 0);\n    EXPECT_NE(xp.get(), nullptr);\n    EXPECT_EQ(xp->chain().size(), 2);\n}\n\nTEST(XPath, parse1) {\n    std::string xpath_string = \"/child\";\n    std::string_view sv{xpath_string};\n    auto xp = flxml::xpath<>::parse(sv);\n    EXPECT_EQ(sv.length(), 0);\n    EXPECT_NE(xp.get(), nullptr);\n    EXPECT_EQ(xp->chain().size(), 2);\n}\n\nTEST(XPath, parse3) {\n    std::string xpath_string = \"//child[another/element]/something\";\n    std::string_view sv{xpath_string};\n    auto xp = flxml::xpath<>::parse(sv);\n    EXPECT_EQ(sv.length(), 0);\n    EXPECT_NE(xp.get(), nullptr);\n    EXPECT_EQ(xp->chain().size(), 4);\n    ASSERT_EQ(xp->chain()[1]->contexts().size(), 1);\n    EXPECT_EQ(xp->chain()[1]->contexts().begin()->get()->chain().size(), 4);\n}\n\nTEST(XPath, parse4) {\n    std::string xpath_string = \"\";\n    std::string_view sv{xpath_string};\n    EXPECT_THROW(\n        flxml::xpath<>::parse(sv),\n        std::runtime_error\n    );\n}\n\n\nTEST(XPath, parse_attr) {\n    std::string xpath_string = \"//child[@foo='bar']/something\";\n    std::string_view sv{xpath_string};\n    auto xp = flxml::xpath<>::parse(sv);\n    EXPECT_EQ(sv.length(), 0);\n    EXPECT_NE(xp.get(), nullptr);\n    EXPECT_EQ(xp->chain().size(), 4);\n    ASSERT_EQ(xp->chain()[1]->contexts().size(), 1);\n    EXPECT_EQ(xp->chain()[1]->contexts().begin()->get()->chain().size(), 1);\n}\n\nTEST(XPath, parse_text) {\n    std::string xpath_string = \"//child[text()='bar']/something\";\n    std::string_view sv{xpath_string};\n    auto xp = flxml::xpath<>::parse(sv);\n    EXPECT_EQ(sv.length(), 0);\n    EXPECT_NE(xp.get(), nullptr);\n    EXPECT_EQ(xp->chain().size(), 4);\n    ASSERT_EQ(xp->chain()[1]->contexts().size(), 1);\n    EXPECT_EQ(xp->chain()[1]->contexts().begin()->get()->chain().size(), 1);\n}\n\nTEST(XPathFirst, simple_all) {\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_fastest>(\"<simple><child/></simple>\");\n    std::string xpath = \"//\";\n    std::string_view sv{xpath};\n    auto xp = flxml::xpath<>::parse(sv);\n    auto r =  xp->first(doc);\n    ASSERT_TRUE(r);\n    EXPECT_EQ(r->type(), flxml::node_type::node_document);\n}\n\nTEST(XPathFirst, simple_any) {\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_fastest>(\"<simple><child/></simple>\");\n    std::string xpath = \"//child\";\n    std::string_view sv{xpath};\n    auto xp = flxml::xpath<>::parse(sv);\n    auto r =  xp->first(doc);\n    ASSERT_TRUE(r);\n    EXPECT_EQ(r->name(), \"child\");\n}\n\nTEST(XPathFirst, simple_sub) {\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_fastest>(\"<simple><child/></simple>\");\n    std::string xpath = \"//[child]\";\n    std::string_view sv{xpath};\n    auto xp = flxml::xpath<>::parse(sv);\n    auto r =  xp->first(doc);\n    ASSERT_TRUE(r);\n    EXPECT_EQ(r->name(), \"simple\");\n}\n\nTEST(XPathFirst, simple_attr) {\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_fastest>(\"<simple><child attr='val1'>foo</child><child attr='val2'>bar</child></simple>\");\n    std::string xpath = \"//child[@attr='val2']\";\n    std::string_view sv{xpath};\n    auto xp = flxml::xpath<>::parse(sv);\n    auto r =  xp->first(doc);\n    ASSERT_TRUE(r);\n    EXPECT_EQ(r->name(), \"child\");\n    EXPECT_EQ(r->value(), \"bar\");\n}\n\nTEST(XPathFirst, simple_text) {\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_fastest>(\"<simple><child attr='val1'>foo</child><child attr='val2'>bar</child></simple>\");\n    auto xp = flxml::xpath<>::parse(\"//child[text()='bar']\");\n    auto r =  xp->first(doc);\n    ASSERT_TRUE(r);\n    EXPECT_EQ(r->name(), \"child\");\n    EXPECT_EQ(r->value(), \"bar\");\n}\n\nTEST(XPathNS, simple_text) {\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_fastest>(\"<p1:simple xmlns:p1='p2'><p1:child attr='val1'>foo</p1:child><p1:child attr='val2'>bar</p1:child></p1:simple>\");\n    auto xp = flxml::xpath<>::parse(\"//child[text()='bar']\");\n    auto r =  xp->first(doc);\n    ASSERT_TRUE(r);\n    EXPECT_EQ(r->name(), \"child\");\n    EXPECT_EQ(r->value(), \"bar\");\n}\n\nTEST(XPathNS, xmlns_text) {\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_fastest>(\"<p1:simple xmlns:p1='p2'><p1:child attr='val1'>foo</p1:child><p1:child attr='val2'>bar</p1:child></p1:simple>\");\n    std::map<std::string,std::string> xmlns = {\n            {\"x1\", \"p2\"},\n            {\"x2\", \"p1\"}\n    };\n    auto xp = flxml::xpath<>::parse(xmlns,\"//x1:child[text()='bar']\");\n    auto r =  xp->first(doc);\n    ASSERT_TRUE(r);\n    EXPECT_EQ(r->name(), \"child\");\n    EXPECT_EQ(r->value(), \"bar\");\n}\n\nTEST(XPathNS, xmlns_both) {\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_fastest>(\"<p1:simple xmlns:p1='p2'><p1:child attr='val1'>foo</p1:child><p1:child attr='val2'>bar</p1:child></p1:simple>\");\n    std::map<std::string,std::string> xmlns = {\n            {\"x1\", \"p2\"},\n            {\"x2\", \"p1\"}\n    };\n    auto xp = flxml::xpath<>::parse(xmlns,\"//x1:child[text()='bar'][@attr='val2']\");\n    auto r =  xp->first(doc);\n    ASSERT_TRUE(r);\n    EXPECT_EQ(r->name(), \"child\");\n    EXPECT_EQ(r->value(), \"bar\");\n}\n\nTEST(XPathNS, xmlns_text_miss) {\n    flxml::xml_document<> doc;\n    doc.parse<flxml::parse_fastest>(\"<p1:simple xmlns:p1='p2'><p1:child attr='val1'>foo</p1:child><p1:child attr='val2'>bar</p1:child></p1:simple>\");\n    std::map<std::string,std::string> xmlns = {\n            {\"x1\", \"p2\"},\n            {\"x2\", \"p1\"}\n    };\n    auto xp = flxml::xpath<>::parse(xmlns,\"//x2:child[text()='bar']\");\n    auto r =  xp->first(doc);\n    ASSERT_FALSE(r);\n}\n"
  }
]