diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-02-07 20:38:10 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-03-24 00:08:35 +0300 |
commit | d1590377de1141144d59ca1160de2822177f6f2a (patch) | |
tree | a368b251dedc7164cadbfe459de4cf5c983acf98 /src/utils/xml/tinyxml2.inc | |
parent | 65422e722cfe0616c65498c71aa0651857dcc49a (diff) | |
download | plus-d1590377de1141144d59ca1160de2822177f6f2a.tar.gz plus-d1590377de1141144d59ca1160de2822177f6f2a.tar.bz2 plus-d1590377de1141144d59ca1160de2822177f6f2a.tar.xz plus-d1590377de1141144d59ca1160de2822177f6f2a.zip |
Add support for tinyxml2 for reading / writing xml files.
Diffstat (limited to 'src/utils/xml/tinyxml2.inc')
-rw-r--r-- | src/utils/xml/tinyxml2.inc | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/utils/xml/tinyxml2.inc b/src/utils/xml/tinyxml2.inc new file mode 100644 index 000000000..a0554e5b9 --- /dev/null +++ b/src/utils/xml/tinyxml2.inc @@ -0,0 +1,70 @@ +/* + * 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 + +#include <tinyxml2.h> + +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 |