summaryrefslogtreecommitdiff
path: root/src/utils/xml
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/xml')
-rw-r--r--src/utils/xml/libxml.cpp346
-rw-r--r--src/utils/xml/libxml.h164
-rw-r--r--src/utils/xml/libxml.inc73
-rw-r--r--src/utils/xml/pugixml.cpp352
-rw-r--r--src/utils/xml/pugixml.h166
-rw-r--r--src/utils/xml/pugixml.inc58
-rw-r--r--src/utils/xml/pugixmlwriter.cpp74
-rw-r--r--src/utils/xml/pugixmlwriter.h65
-rw-r--r--src/utils/xml/tinyxml2.cpp323
-rw-r--r--src/utils/xml/tinyxml2.h168
-rw-r--r--src/utils/xml/tinyxml2.inc77
11 files changed, 0 insertions, 1866 deletions
diff --git a/src/utils/xml/libxml.cpp b/src/utils/xml/libxml.cpp
deleted file mode 100644
index 6dd87b3f2..000000000
--- a/src/utils/xml/libxml.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef ENABLE_LIBXML
-
-#include "utils/xml/libxml.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/fuzzer.h"
-#include "utils/stringutils.h"
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-namespace
-{
- bool valid = false;
-} // namespace
-
-static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg A_UNUSED, ...)
-#ifdef __GNUC__
-#ifdef __OpenBSD__
- __attribute__((__format__(printf, 2, 3)))
-#else // __OpenBSD__
- __attribute__((__format__(gnu_printf, 2, 3)))
-#endif // __OpenBSD__
-#endif // __GNUC__
-;
-
-static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg, ...)
-{
- if (msg == nullptr)
- return;
-
- size_t size = 1024;
- const size_t msgSize = strlen(msg);
- if (msgSize * 3 > size)
- size = msgSize * 3;
-
- char* buf = new char[size + 1];
- va_list ap;
-
- // Use a temporary buffer to fill in the variables
- va_start(ap, msg);
- vsnprintf(buf, size, msg, ap);
- buf[size] = 0;
- va_end(ap);
-
- if (logger != nullptr)
- logger->log_r("%s", buf);
- else
- puts(buf);
-
- // Delete temporary buffer
- delete [] buf;
- valid = false;
-}
-
-namespace XML
-{
- Document::Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError) :
- Resource(),
- mDoc(nullptr),
- mIsValid(false)
- {
-#ifdef USE_FUZZER
- if (Fuzzer::conditionTerminate(filename.c_str()))
- return;
-#endif // USE_FUZZER
-
- BLOCK_START("XML::Document::Document")
- int size = 0;
- char *data = nullptr;
- valid = true;
- if (useResman == UseVirtFs_true)
- {
- data = const_cast<char*>(VirtFs::loadFile(
- filename,
- size));
- }
- else
- {
- std::ifstream file;
- file.open(filename.c_str(), std::ios::in);
-
- if (file.is_open())
- {
- // Get length of file
- file.seekg(0, std::ios::end);
- size = CAST_S32(file.tellg());
- if (size < 0)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- else
- {
- file.seekg(0, std::ios::beg);
- data = new char[size];
- file.read(data, size);
- }
- file.close();
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- }
-
- if (data != nullptr)
- {
- mDoc = xmlParseMemory(data, size);
- delete [] data;
-
- if (mDoc == nullptr)
- {
- reportAlways("Error parsing XML file %s", filename.c_str());
- }
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading XML file %s", filename.c_str());
- }
- mIsValid = valid;
- BLOCK_END("XML::Document::Document")
- }
-
- Document::Document(const char *const data, const int size) :
- mDoc(data != nullptr ? xmlParseMemory(data, size) : nullptr),
- mIsValid(true)
- {
- }
-
- Document::~Document()
- {
- if (mDoc != nullptr)
- xmlFreeDoc(mDoc);
- }
-
- XmlNodePtr Document::rootNode()
- {
- return mDoc != nullptr ? xmlDocGetRootElement(mDoc) : nullptr;
- }
-
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def)
- {
- int &ret = def;
-
- xmlChar *const prop = XmlGetProp(node, name);
- if (prop != nullptr)
- {
- ret = atoi(reinterpret_cast<const char*>(prop));
- xmlFree(prop);
- }
-
- return ret;
- }
-
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max)
- {
- int &ret = def;
-
- xmlChar *const prop = XmlGetProp(node, name);
- if (prop != nullptr)
- {
- ret = atoi(reinterpret_cast<char*>(prop));
- xmlFree(prop);
- }
- if (ret < min)
- ret = min;
- else if (ret > max)
- ret = max;
- return ret;
- }
-
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def)
- {
- float &ret = def;
-
- xmlChar *const prop = XmlGetProp(node, name);
- if (prop != nullptr)
- {
- ret = static_cast<float>(atof(reinterpret_cast<char*>(prop)));
- xmlFree(prop);
- }
-
- return ret;
- }
-
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def)
- {
- double &ret = def;
-
- xmlChar *const prop = XmlGetProp(node, name);
- if (prop != nullptr)
- {
- ret = atof(reinterpret_cast<char*>(prop));
- xmlFree(prop);
- }
-
- return ret;
- }
-
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- xmlChar *const prop = XmlGetProp(node, name);
- if (prop != nullptr)
- {
- std::string val = reinterpret_cast<char*>(prop);
- xmlFree(prop);
- return val;
- }
-
- return def;
- }
-
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- std::string str = getProperty(node, name, def);
- if (translator == nullptr)
- return str;
-
- return translator->getStr(str);
- }
-
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def)
- {
- xmlChar *const prop = XmlGetProp(node, name);
-
- if (XmlStrEqual(prop, "true"))
- {
- XmlFree(prop);
- return true;
- }
- if (XmlStrEqual(prop, "false"))
- {
- XmlFree(prop);
- return false;
- }
- XmlFree(prop);
- return def;
- }
-
- XmlNodePtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name)
- {
- if (parent == nullptr)
- return nullptr;
- for_each_xml_child_node(child, parent)
- {
- if (xmlNameEqual(child, name))
- return child;
- }
-
- return nullptr;
- }
-
- // Initialize libxml2 and check for potential ABI mismatches between
- // compiled version and the shared library actually used.
- void initXML()
- {
- xmlInitParser();
- LIBXML_TEST_VERSION;
-
- // Suppress libxml2 error messages
- xmlSetGenericErrorFunc(nullptr, &xmlErrorLogger);
- }
-
- // Shutdown libxml
- void cleanupXML()
- {
- xmlCleanupParser();
- }
-
- bool Document::validateXml(const std::string &fileName)
- {
- const xmlDocPtr doc = xmlReadFile(fileName.c_str(),
- nullptr, XML_PARSE_PEDANTIC);
- const bool valid1(doc != nullptr);
- xmlFreeDoc(doc);
- if (!valid1)
- return false;
-
- std::ifstream file;
- file.open(fileName.c_str(), std::ios::in);
- if (!file.is_open())
- {
- file.close();
- return false;
- }
- char line[101];
- if (!file.getline(line, 100))
- return false;
- file.close();
-
- const std::string str = line;
- if (!strStartWith(str, "<?xml "))
- return false;
-
- return true;
- }
-} // namespace XML
-
-#endif // ENABLE_LIBXML
diff --git a/src/utils/xml/libxml.h b/src/utils/xml/libxml.h
deleted file mode 100644
index 6ec0ce08d..000000000
--- a/src/utils/xml/libxml.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef UTILS_XML_LIBXML_H
-#define UTILS_XML_LIBXML_H
-
-#ifdef ENABLE_LIBXML
-
-#define XML_INCLUDE_DEFINE
-
-#include "enums/simpletypes/skiperror.h"
-#include "enums/simpletypes/usevirtfs.h"
-
-#include "utils/xml/libxml.inc"
-
-#include "resources/resource.h"
-
-#ifndef _GLIBCXX_STRING
-#include <string>
-#endif // _GLIBCXX_STRING
-
-#include "localconsts.h"
-
-/**
- * XML helper functions.
- */
-namespace XML
-{
- /**
- * A helper class for parsing an XML document, which also cleans it up
- * again (RAII).
- */
- class Document final : public Resource
- {
- public:
- /**
- * Constructor that attempts to load the given file through the
- * resource manager. Logs errors.
- */
- Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError);
-
- /**
- * Constructor that attempts to load an XML document from memory.
- * Does not log errors.
- *
- * @param data the string to parse as XML
- * @param size the length of the string in bytes
- */
- Document(const char *const data, const int size);
-
- A_DELETE_COPY(Document)
-
- /**
- * Destructor. Frees the loaded XML file.
- */
- ~Document();
-
- /**
- * Returns the root node of the document (or NULL if there was a
- * load error).
- */
- XmlNodePtr rootNode() A_WARN_UNUSED;
-
- bool isLoaded() const
- { return mDoc != nullptr; }
-
- bool isValid() const
- { return mIsValid; }
-
- static bool validateXml(const std::string &fileName);
-
- private:
- xmlDocPtr mDoc;
- bool mIsValid;
- };
-
- /**
- * Gets an floating point property from an XmlNodePtr.
- */
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def) A_WARN_UNUSED;
-
- /**
- * Gets an double point property from an XmlNodePtr.
- */
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max) A_WARN_UNUSED;
-
- /**
- * Gets a string property from an XmlNodePtr.
- */
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a translated string property from an XmlNodePtr.
- */
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a boolean property from an XmlNodePtr.
- */
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def) A_WARN_UNUSED;
-
- /**
- * Finds the first child node with the given name
- */
- XmlNodePtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name) A_WARN_UNUSED;
-
- void initXML();
-
- void cleanupXML();
-} // namespace XML
-
-#define for_each_xml_child_node(var, parent) \
- for (XmlNodePtr var = parent->xmlChildrenNode; var; var = var->next)
-
-#endif // ENABLE_LIBXML
-#endif // UTILS_XML_LIBXML_H
diff --git a/src/utils/xml/libxml.inc b/src/utils/xml/libxml.inc
deleted file mode 100644
index ec837f224..000000000
--- a/src/utils/xml/libxml.inc
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef UTILS_XML_LIBXML_INC
-#define UTILS_XML_LIBXML_INC
-
-#ifdef ENABLE_LIBXML
-
-#include <libxml/xmlwriter.h>
-
-__XML_XMLWRITER_H__
-
-#define XmlNodePtr xmlNodePtr
-#define XmlNodePtrConst xmlNode *const
-#define XmlNodeConstPtr const xmlNodePtr
-#define XmlNodeConstPtrConst const xmlNode *const
-#define XmlStrEqual(str1, str2) xmlStrEqual(str1, \
- reinterpret_cast<const xmlChar*>(str2))
-#define xmlNameEqual(node, str) xmlStrEqual((node)->name, \
- reinterpret_cast<const xmlChar*>(str))
-#define XmlTextWriterPtr const xmlTextWriterPtr
-#define xmlTypeEqual(node, typ) ((node)->type == (typ))
-#define XmlHasProp(node, name) (xmlHasProp(node, \
- reinterpret_cast<const xmlChar*>(name)) != nullptr)
-#define XmlGetProp(node, name) xmlGetProp(node, \
- reinterpret_cast<const xmlChar*>(name))
-#define XmlTextWriterStartRootElement(writer, name) \
- xmlTextWriterStartElement(writer, reinterpret_cast<const xmlChar*>(name))
-#define XmlTextWriterStartElement(writer, name) \
- xmlTextWriterStartElement(writer, reinterpret_cast<const xmlChar*>(name))
-#define XmlTextWriterEndElement(writer) xmlTextWriterEndElement(writer)
-#define XmlTextWriterWriteAttribute(writer, name, content) \
- xmlTextWriterWriteAttribute(writer, \
- reinterpret_cast<const xmlChar*>(name), \
- reinterpret_cast<const xmlChar*>(content))
-#define XmlNodeGetContent(node) xmlNodeGetContent(node)
-#define XmlNewTextWriterFilename(name, flags) \
- xmlNewTextWriterFilename(name, flags)
-#define XmlSaveTextWriterFilename(writer, name)
-#define XmlTextWriterSetIndent(writer, flags) \
- xmlTextWriterSetIndent(writer, flags)
-#define XmlTextWriterStartDocument(writer, p1, p2, p3) \
- xmlTextWriterStartDocument(writer, p1, p2, p3)
-#define XmlTextWriterEndDocument(writer) xmlTextWriterEndDocument(writer)
-#define XmlFreeTextWriter(writer) xmlFreeTextWriter(writer)
-#define XmlHaveChildContent(node) ((node)->xmlChildrenNode != nullptr && \
- (node)->xmlChildrenNode->content != nullptr)
-#define XmlChildContent(node) reinterpret_cast<const char*>(\
- (node)->xmlChildrenNode->content)
-#define XmlFree(ptr) xmlFree(ptr)
-#define XmlNodeDefault nullptr
-#define XmlChar char
-#define XmlConstChar const char
-
-#endif // ENABLE_LIBXML
-#endif // UTILS_XML_LIBXML_INC
diff --git a/src/utils/xml/pugixml.cpp b/src/utils/xml/pugixml.cpp
deleted file mode 100644
index 12d885a4f..000000000
--- a/src/utils/xml/pugixml.cpp
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef ENABLE_PUGIXML
-
-#include "utils/xml/pugixml.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/delete2.h"
-#include "utils/fuzzer.h"
-#include "utils/stringutils.h"
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-namespace
-{
- bool valid = false;
-} // namespace
-
-namespace XML
-{
- static void showErrorStatus(pugi::xml_parse_result &result)
- {
-/*
- switch (result.status)
- {
- case pugi::status_ok:
- break;
- case pugi::status_file_not_found:
- logger->log("xml error: %s", result.description());
- break;
- }
-*/
- logger->log("xml error: %s", result.description());
- }
-
- Document::Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError) :
- Resource(),
- mDoc(),
- mData(nullptr),
- mIsValid(false)
- {
-#ifdef USE_FUZZER
- if (Fuzzer::conditionTerminate(filename.c_str()))
- return;
-#endif // USE_FUZZER
-
- BLOCK_START("XML::Document::Document")
- int size = 0;
- char *data = nullptr;
- valid = true;
- if (useResman == UseVirtFs_true)
- {
- data = const_cast<char*>(VirtFs::loadFile(
- filename.c_str(),
- size));
- }
- else
- {
- std::ifstream file;
- file.open(filename.c_str(), std::ios::in);
-
- if (file.is_open())
- {
- // Get length of file
- file.seekg(0, std::ios::end);
- size = CAST_S32(file.tellg());
- if (size < 0)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- else
- {
- file.seekg(0, std::ios::beg);
- data = new char[size];
- file.read(data, size);
- }
- file.close();
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- }
-
- if (data)
- {
- // +++ use other pugi::parse_* flags
- pugi::xml_parse_result result = mDoc.load_buffer_inplace(data,
- size,
- pugi::parse_default,
- pugi::encoding_utf8);
- if (result.status != pugi::status_ok)
- {
- showErrorStatus(result);
- delete [] data;
- }
- else
- {
- mData = data;
- }
-
-// if (!mDoc)
-// logger->log("Error parsing XML file %s", filename.c_str());
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading %s", filename.c_str());
- }
- mIsValid = valid;
- BLOCK_END("XML::Document::Document")
- }
-
- Document::Document(const char *const data, const int size) :
- mDoc(),
- mData(nullptr),
- mIsValid(true)
- {
- if (!data)
- return;
-
- char *buf = new char[size + 1];
- strncpy(buf, data, size);
- buf[size] = 0;
- pugi::xml_parse_result result = mDoc.load_buffer_inplace(buf,
- size,
- pugi::parse_default,
- pugi::encoding_utf8);
- if (result.status != pugi::status_ok)
- {
- showErrorStatus(result);
- delete [] buf;
- }
- else
- {
- mData = buf;
- }
- }
-
- Document::~Document()
- {
- delete [] mData;
- mData = nullptr;
- }
-
- XmlNodePtr Document::rootNode()
- {
- return mDoc.first_child();
- }
-
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def)
- {
- int &ret = def;
-
- if (!node)
- return ret;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- ret = atoi(attr.value());
-
- return ret;
- }
-
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max)
- {
- int &ret = def;
-
- if (!node)
- return ret;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- ret = atoi(attr.value());
-
- if (ret < min)
- ret = min;
- else if (ret > max)
- ret = max;
- return ret;
- }
-
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def)
- {
- float &ret = def;
-
- if (!node)
- return ret;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- ret = atof(attr.value());
-
- return ret;
- }
-
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def)
- {
- double &ret = def;
-
- if (!node)
- return ret;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- ret = atof(attr.value());
-
- return ret;
- }
-
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- if (!node)
- return def;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- return attr.value();
-
- return def;
- }
-
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- std::string str = getProperty(node, name, def);
- if (!translator)
- return str;
-
- return translator->getStr(str);
- }
-
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def)
- {
- if (!node)
- return def;
- const pugi::xml_attribute &attr = node.attribute(name);
- if (!attr.empty())
- {
- std::string val = attr.value();
- if (val == "true")
- return true;
- if (val == "false")
- return false;
- }
-
- return def;
- }
-
- XmlNodePtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name)
- {
- if (!parent || !name)
- return pugi::xml_node();
- for_each_xml_child_node(child, parent)
- {
- if (!strcmp(child.name(), name))
- return child;
- }
-
- return pugi::xml_node();
- }
-
- // Initialize libxml2 and check for potential ABI mismatches between
- // compiled version and the shared library actually used.
- void initXML()
- {
-// xmlInitParser();
-// LIBXML_TEST_VERSION;
-
- // Suppress libxml2 error messages
-// xmlSetGenericErrorFunc(nullptr, &xmlErrorLogger);
- }
-
- // Shutdown libxml
- void cleanupXML()
- {
-// xmlCleanupParser();
- }
-
- bool Document::validateXml(const std::string &fileName)
- {
- pugi::xml_document doc;
- pugi::xml_parse_result result = doc.load_file(fileName.c_str(),
- pugi::parse_default,
- pugi::encoding_utf8);
-
- if (result.status != pugi::status_ok)
- {
- showErrorStatus(result);
- return false;
- }
-
- std::ifstream file;
- file.open(fileName.c_str(), std::ios::in);
- if (!file.is_open())
- {
- file.close();
- return false;
- }
- char line[101];
- if (!file.getline(line, 100))
- return false;
- file.close();
-
- const std::string str = line;
- if (!strStartWith(str, "<?xml "))
- return false;
-
- return true;
- }
-} // namespace XML
-
-#endif // ENABLE_PUGIXML
diff --git a/src/utils/xml/pugixml.h b/src/utils/xml/pugixml.h
deleted file mode 100644
index e4337140e..000000000
--- a/src/utils/xml/pugixml.h
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef UTILS_XML_PUGIXML_H
-#define UTILS_XML_PUGIXML_H
-
-#ifdef ENABLE_PUGIXML
-
-#define XML_INCLUDE_DEFINE
-
-#include "enums/simpletypes/skiperror.h"
-#include "enums/simpletypes/usevirtfs.h"
-
-#include "utils/xml/pugixml.inc"
-
-#include "resources/resource.h"
-
-#include <pugixml.hpp>
-
-#include <string>
-
-#include "localconsts.h"
-
-/**
- * XML helper functions.
- */
-namespace XML
-{
- /**
- * A helper class for parsing an XML document, which also cleans it up
- * again (RAII).
- */
- class Document final : public Resource
- {
- public:
- /**
- * Constructor that attempts to load the given file through the
- * resource manager. Logs errors.
- */
- Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError);
-
- /**
- * Constructor that attempts to load an XML document from memory.
- * Does not log errors.
- *
- * @param data the string to parse as XML
- * @param size the length of the string in bytes
- */
- Document(const char *const data, const int size);
-
- A_DELETE_COPY(Document)
-
- /**
- * Destructor. Frees the loaded XML file.
- */
- ~Document();
-
- /**
- * Returns the root node of the document (or NULL if there was a
- * load error).
- */
- XmlNodePtr rootNode() A_WARN_UNUSED;
-
- bool isLoaded() const
- { return !mDoc.empty(); }
-
- bool isValid() const
- { return mIsValid; }
-
- static bool validateXml(const std::string &fileName);
-
- private:
- pugi::xml_document mDoc;
- char *mData;
- bool mIsValid;
- };
-
- /**
- * Gets an floating point property from an XmlNodePtr.
- */
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def) A_WARN_UNUSED;
-
- /**
- * Gets an double point property from an XmlNodePtr.
- */
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max) A_WARN_UNUSED;
-
- /**
- * Gets a string property from an XmlNodePtr.
- */
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a translated string property from an XmlNodePtr.
- */
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a boolean property from an XmlNodePtr.
- */
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def) A_WARN_UNUSED;
-
- /**
- * Finds the first child node with the given name
- */
- XmlNodePtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name) A_WARN_UNUSED;
-
- void initXML();
-
- void cleanupXML();
-} // namespace XML
-
-#define for_each_xml_child_node(var, parent) \
- for (pugi::xml_node var = parent.first_child(); \
- var; var = var.next_sibling())
-
-#endif // ENABLE_PUGIXML
-#endif // UTILS_XML_PUGIXML_H
diff --git a/src/utils/xml/pugixml.inc b/src/utils/xml/pugixml.inc
deleted file mode 100644
index c8685f877..000000000
--- a/src/utils/xml/pugixml.inc
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef UTILS_XML_PUGIXML_INC
-#define UTILS_XML_PUGIXML_INC
-
-#ifdef ENABLE_PUGIXML
-
-#define XML_ELEMENT_NODE pugi::node_element
-
-#define XmlNodePtr pugi::xml_node
-#define XmlNodePtrConst pugi::xml_node
-#define XmlNodeConstPtr const pugi::xml_node
-#define XmlNodeConstPtrConst const pugi::xml_node
-#define xmlNameEqual(node, str) !strcmp((node).name(), str)
-#define xmlTypeEqual(node, typ) ((node).type() == (typ))
-#define XmlHasProp(node, name) (!((node).attribute(name).empty()))
-#define XmlHaveChildContent(node) ((node).child_value() != nullptr && \
- *(node).child_value())
-#define XmlChildContent(node) (node).child_value()
-#define xmlChar char
-#define XmlFree(ptr)
-#define XmlNodeDefault pugi::xml_node()
-#define XmlNodeGetContent(node) (node).child_value()
-#define XmlTextWriterPtr const XML::Writer *
-#define XmlTextWriterStartRootElement(writer, name) (writer)->startNode(name)
-#define XmlTextWriterStartElement(writer, name) (writer)->startNode(name)
-#define XmlTextWriterEndElement(writer) (writer)->endNode()
-#define XmlTextWriterWriteAttribute(writer, name, content) \
- (writer)->addAttribute(name, content)
-#define XmlNewTextWriterFilename(name, flags) new XML::Writer(name);
-#define XmlSaveTextWriterFilename(writer, name)
-#define XmlTextWriterSetIndent(writer, flags)
-#define XmlTextWriterStartDocument(writer, p1, p2, p3)
-#define XmlTextWriterEndDocument(writer) (writer)->endDocument()
-#define XmlFreeTextWriter(writer) delete writer
-#define XmlChar const char
-#define XmlConstChar const char
-
-#endif // ENABLE_PUGIXML
-#endif // UTILS_XML_PUGIXML_INC
diff --git a/src/utils/xml/pugixmlwriter.cpp b/src/utils/xml/pugixmlwriter.cpp
deleted file mode 100644
index b8c6aafec..000000000
--- a/src/utils/xml/pugixmlwriter.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef ENABLE_PUGIXML
-
-#include "utils/xml/pugixmlwriter.h"
-
-#include "logger.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/delete2.h"
-#include "utils/fuzzer.h"
-#include "utils/stringutils.h"
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-namespace XML
-{
- Writer::Writer(const std::string &filename) :
- mDoc(),
- mNode(),
- mName(filename)
- {
- mNode = mDoc;
- }
-
- Writer::~Writer()
- {
- }
-
- void Writer::startNode(const std::string &name) const
- {
- mNode = mNode.append_child(name.c_str());
- }
-
- void Writer::endNode() const
- {
- mNode = mNode.parent();
- }
-
- void Writer::endDocument() const
- {
- mDoc.save_file(mName.c_str());
- }
-
- void Writer::addAttribute(const std::string &name,
- const std::string &value) const
- {
- mNode.append_attribute(name.c_str()) = value.c_str();
- }
-
-} // namespace XML
-
-#endif // ENABLE_PUGIXML
diff --git a/src/utils/xml/pugixmlwriter.h b/src/utils/xml/pugixmlwriter.h
deleted file mode 100644
index fe5977655..000000000
--- a/src/utils/xml/pugixmlwriter.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef UTILS_XML_PUGIXMLWRITER_H
-#define UTILS_XML_PUGIXMLWRITER_H
-
-#ifdef ENABLE_PUGIXML
-
-#include "enums/simpletypes/skiperror.h"
-#include "enums/simpletypes/usevirtfs.h"
-
-#include "utils/xml/pugixml.h"
-
-#include <pugixml.hpp>
-
-#include <string>
-
-#include "localconsts.h"
-
-namespace XML
-{
- class Writer final
- {
- public:
- explicit Writer(const std::string &filename);
-
- A_DELETE_COPY(Writer)
-
- ~Writer();
-
- void startNode(const std::string &name) const;
-
- void endNode() const;
-
- void endDocument() const;
-
- void addAttribute(const std::string &name,
- const std::string &value) const;
-
- private:
- mutable pugi::xml_document mDoc;
- mutable pugi::xml_node mNode;
- std::string mName;
- };
-} // namespace XML
-
-#endif // ENABLE_PUGIXML
-#endif // UTILS_XML_PUGIXMLWRITER_H
diff --git a/src/utils/xml/tinyxml2.cpp b/src/utils/xml/tinyxml2.cpp
deleted file mode 100644
index a7275b7f1..000000000
--- a/src/utils/xml/tinyxml2.cpp
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef ENABLE_TINYXML2
-
-#include "utils/xml/tinyxml2.h"
-
-#include "fs/virtfs/fs.h"
-
-#include "utils/cast.h"
-#include "utils/checkutils.h"
-#include "utils/fuzzer.h"
-#include "utils/stringutils.h"
-
-#include "utils/translation/podict.h"
-
-#include "debug.h"
-
-namespace
-{
- bool valid = false;
-} // namespace
-
-namespace XML
-{
- static void showErrorStatus(tinyxml2::XMLDocument &doc)
- {
- logger->log("xml error: %s, in lines: %s\n%s",
- doc.ErrorName(),
- doc.GetErrorStr1(),
- doc.GetErrorStr2());
- }
-
- Document::Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError) :
- Resource(),
- mDoc(),
- mData(nullptr),
- mIsValid(false)
- {
-#ifdef USE_FUZZER
- if (Fuzzer::conditionTerminate(filename.c_str()))
- return;
-#endif // USE_FUZZER
-
- BLOCK_START("XML::Document::Document")
- int size = 0;
- char *data = nullptr;
- valid = true;
- if (useResman == UseVirtFs_true)
- {
- data = const_cast<char*>(VirtFs::loadFile(
- filename.c_str(),
- size));
- }
- else
- {
- std::ifstream file;
- file.open(filename.c_str(), std::ios::in);
-
- if (file.is_open())
- {
- // Get length of file
- file.seekg(0, std::ios::end);
- size = CAST_S32(file.tellg());
- if (size < 0)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- else
- {
- file.seekg(0, std::ios::beg);
- data = new char[size];
- file.read(data, size);
- }
- file.close();
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading XML file %s",
- filename.c_str());
- }
- }
-
- if (data)
- {
- tinyxml2::XMLError result = mDoc.Parse(data,
- size);
- if (result != tinyxml2::XML_SUCCESS)
- {
- showErrorStatus(mDoc);
- delete [] data;
- }
- else
- {
- mData = data;
- }
- }
- else if (skipError == SkipError_false)
- {
- reportAlways("Error loading %s", filename.c_str());
- }
- mIsValid = valid;
- BLOCK_END("XML::Document::Document")
- }
-
- Document::Document(const char *const data, const int size) :
- Resource(),
- mDoc(),
- mData(nullptr),
- mIsValid(true)
- {
- if (!data)
- return;
-
- char *buf = new char[size + 1];
- strncpy(buf, data, size);
- buf[size] = 0;
-
- tinyxml2::XMLError result = mDoc.Parse(buf,
- size);
- if (result != tinyxml2::XML_SUCCESS)
- {
- showErrorStatus(mDoc);
- delete [] buf;
- }
- else
- {
- mData = buf;
- }
- }
-
- Document::~Document()
- {
- delete [] mData;
- mData = nullptr;
- }
-
- XmlNodeConstPtr Document::rootNode()
- {
- return mDoc.FirstChildElement();
- }
-
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def)
- {
- int &ret = def;
-
- if (!node)
- return ret;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- ret = atoi(attr);
-
- return ret;
- }
-
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max)
- {
- int &ret = def;
-
- if (!node)
- return ret;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- ret = atoi(attr);
-
- if (ret < min)
- ret = min;
- else if (ret > max)
- ret = max;
- return ret;
- }
-
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def)
- {
- float &ret = def;
-
- if (!node)
- return ret;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- ret = atof(attr);
-
- return ret;
- }
-
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def)
- {
- double &ret = def;
-
- if (!node)
- return ret;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- ret = atof(attr);
-
- return ret;
- }
-
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- if (!node)
- return def;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- return attr;
-
- return def;
- }
-
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def)
- {
- std::string str = getProperty(node, name, def);
- if (!translator)
- return str;
-
- return translator->getStr(str);
- }
-
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def)
- {
- if (!node)
- return def;
- const char *attr = node->Attribute(name);
- if (attr != nullptr)
- {
- std::string val = attr;
- if (val == "true")
- return true;
- if (val == "false")
- return false;
- }
-
- return def;
- }
-
- XmlNodeConstPtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name)
- {
- if (!parent || !name)
- return nullptr;
- return parent->FirstChildElement(name);
- }
-
- // Initialize xml
- void initXML()
- {
- }
-
- // Shutdown xml
- void cleanupXML()
- {
- }
-
- bool Document::validateXml(const std::string &fileName)
- {
- tinyxml2::XMLDocument doc;
- tinyxml2::XMLError result = doc.LoadFile(fileName.c_str());
-
- if (result != tinyxml2::XML_SUCCESS)
- {
- showErrorStatus(doc);
- return false;
- }
-
- std::ifstream file;
- file.open(fileName.c_str(), std::ios::in);
- if (!file.is_open())
- {
- file.close();
- return false;
- }
- char line[101];
- if (!file.getline(line, 100))
- return false;
- file.close();
-
- const std::string str = line;
- if (!strStartWith(str, "<?xml "))
- return false;
-
- return true;
- }
-} // namespace XML
-
-#endif // ENABLE_TINYXML2
diff --git a/src/utils/xml/tinyxml2.h b/src/utils/xml/tinyxml2.h
deleted file mode 100644
index f056dc43a..000000000
--- a/src/utils/xml/tinyxml2.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2004-2009 The Mana World Development Team
- * Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef UTILS_XML_TINYXML2_H
-#define UTILS_XML_TINYXML2_H
-
-#ifdef ENABLE_TINYXML2
-
-#define XML_INCLUDE_DEFINE
-
-#include "enums/simpletypes/skiperror.h"
-#include "enums/simpletypes/usevirtfs.h"
-
-#include "utils/xml/tinyxml2.inc"
-
-#include "resources/resource.h"
-
-#ifndef _GLIBCXX_STRING
-#include <string>
-#endif // _GLIBCXX_STRING
-
-#include "localconsts.h"
-
-/**
- * XML helper functions.
- */
-namespace XML
-{
- /**
- * A helper class for parsing an XML document, which also cleans it up
- * again (RAII).
- */
- class Document final : public Resource
- {
- public:
- /**
- * Constructor that attempts to load the given file through the
- * resource manager. Logs errors.
- */
- Document(const std::string &filename,
- const UseVirtFs useResman,
- const SkipError skipError);
-
- /**
- * Constructor that attempts to load an XML document from memory.
- * Does not log errors.
- *
- * @param data the string to parse as XML
- * @param size the length of the string in bytes
- */
- Document(const char *const data, const int size);
-
- A_DELETE_COPY(Document)
-
- /**
- * Destructor. Frees the loaded XML file.
- */
- ~Document();
-
- /**
- * Returns the root node of the document (or NULL if there was a
- * load error).
- */
- XmlNodePtr rootNode() A_WARN_UNUSED;
-
- bool isLoaded() const
- { return mDoc.Error() == false; }
-
- bool isValid() const
- { return mIsValid; }
-
- static bool validateXml(const std::string &fileName);
-
- private:
- tinyxml2::XMLDocument mDoc;
- char *mData;
- bool mIsValid;
- };
-
- /**
- * Gets an floating point property from an XmlNodePtr.
- */
- float getFloatProperty(XmlNodeConstPtr node,
- const char *const name,
- float def) A_WARN_UNUSED;
-
- /**
- * Gets an double point property from an XmlNodePtr.
- */
- double getDoubleProperty(XmlNodeConstPtr node,
- const char *const name,
- double def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getProperty(XmlNodeConstPtr node,
- const char *const name,
- int def) A_WARN_UNUSED;
-
- /**
- * Gets an integer property from an XmlNodePtr.
- */
- int getIntProperty(XmlNodeConstPtr node,
- const char *const name,
- int def,
- const int min,
- const int max) A_WARN_UNUSED;
-
- /**
- * Gets a string property from an XmlNodePtr.
- */
- std::string getProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a translated string property from an XmlNodePtr.
- */
- std::string langProperty(XmlNodeConstPtr node,
- const char *const name,
- const std::string &def) A_WARN_UNUSED;
-
- /**
- * Gets a boolean property from an XmlNodePtr.
- */
- bool getBoolProperty(XmlNodeConstPtr node,
- const char *const name,
- const bool def) A_WARN_UNUSED;
-
- /**
- * Finds the first child node with the given name
- */
- XmlNodeConstPtr findFirstChildByName(XmlNodeConstPtrConst parent,
- const char *const name)
- A_WARN_UNUSED;
-
- void initXML();
-
- void cleanupXML();
-} // namespace XML
-
-#define for_each_xml_child_node(var, parent) \
- for (const tinyxml2::XMLElement *var = parent->FirstChildElement(); \
- var != nullptr; \
- var = var->NextSiblingElement())
-
-#endif // ENABLE_TINYXML2
-#endif // UTILS_XML_TINYXML2_H
diff --git a/src/utils/xml/tinyxml2.inc b/src/utils/xml/tinyxml2.inc
deleted file mode 100644
index 408638184..000000000
--- a/src/utils/xml/tinyxml2.inc
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2017 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef UTILS_XML_TINYXML2_INC
-#define UTILS_XML_TINYXML2_INC
-
-#ifdef ENABLE_TINYXML2
-
-PRAGMA49(GCC diagnostic push)
-PRAGMA49(GCC diagnostic ignored "-Wzero-as-null-pointer-constant")
-PRAGMA49(GCC diagnostic ignored "-Wsuggest-override")
-PRAGMACLANG6GCC(GCC diagnostic push)
-PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
-#include <tinyxml2.h>
-PRAGMACLANG6GCC(GCC diagnostic pop)
-PRAGMA49(GCC diagnostic pop)
-
-TINYXML2_INCLUDED
-
-#define XML_ELEMENT_NODE tinyxml2::XMLElement
-
-#define XmlNodePtr const tinyxml2::XMLElement*
-#define XmlNodePtrConst const tinyxml2::XMLElement *const
-#define XmlNodeConstPtr const tinyxml2::XMLElement*
-#define XmlNodeConstPtrConst const tinyxml2::XMLElement *const
-#define xmlNameEqual(node, str) !strcmp((node)->Value(), str)
-#define XmlTextWriterPtr tinyxml2::XMLPrinter*
-// +++ need replace xmlTypeEqual to isXmlElementNode
-#define xmlTypeEqual(node, typ) true
-#define XmlHasProp(node, name) ((node)->Attribute(name) != nullptr)
-
-#define XmlNodeGetContent(node) (node)->GetText()
-#define XmlHaveChildContent(node) ((node)->GetText() != nullptr)
-#define XmlChildContent(node) ((node)->GetText())
-
-#define XmlFree(ptr)
-#define XmlNodeDefault nullptr
-#define XmlChar const char
-#define XmlConstChar const char
-
-#define XmlTextWriterStartElement(writer, name) (writer)->OpenElement(name)
-#define XmlTextWriterStartRootElement(writer, name) (writer)->OpenElement(name)
-#define XmlTextWriterEndElement(writer) (writer)->CloseElement()
-#define XmlTextWriterWriteAttribute(writer, name, content) \
- (writer)->PushAttribute(name, content)
-#define XmlNewTextWriterFilename(name, flags) new tinyxml2::XMLPrinter
-#define XmlSaveTextWriterFilename(writer, name) \
- { \
- FILE *const writer##File = fopen(name, "wb"); \
- fwrite((writer)->CStr(), 1, (writer)->CStrSize() - 1, writer##File); \
- fclose(writer##File); \
- }
-#define XmlTextWriterSetIndent(writer, flags)
-#define XmlTextWriterStartDocument(writer, p1, p2, p3) \
- (writer)->PushDeclaration("xml version=\"1.0\" encoding=\"utf-8\"")
-#define XmlTextWriterEndDocument(writer) (writer)->CloseElement()
-#define XmlFreeTextWriter(writer) delete writer
-
-#endif // ENABLE_TINYXML2
-#endif // UTILS_XML_TINYXML2_INC