added header to undefine macros for XML parser

This commit is contained in:
Martchus 2016-03-06 17:12:50 +01:00
parent 2a9d4cb353
commit ba8dd4c113
4 changed files with 29 additions and 29 deletions

View File

@ -7,6 +7,7 @@ set(HEADER_FILES
misc/dialogutils.h
misc/desktoputils.h
misc/xmlparsermacros.h
misc/undefxmlparsermacros.h
models/checklistmodel.h
resources/qtconfigarguments.h
resources/resources.h

View File

@ -0,0 +1,24 @@
/*!
* \file undefxmlparsermacros.h
* \brief Undefines macros to utilize XML parsing using QXmlStreamReader.
* \sa For an example, see dbquery.cpp of the tageditor project.
*/
#ifdef iftag
# undef iftag
#endif
#ifdef eliftag
# undef eliftag
#endif
#ifdef else_skip
# undef else_skip
#endif
#ifdef children
# undef children
#endif
#ifdef text
# undef text
#endif
#ifdef attribute
# undef attribute
#endif

View File

@ -1,41 +1,15 @@
#include <QXmlStreamReader>
/*!
* \file xmlparsermacros.h
* \brief Macros to utilize XML parsing using QXmlStreamReader.
* \sa For an example, see dbquery.cpp of the tageditor project.
*/
#ifndef xmlReader
# error "xmlReader must be defined to use these macros."
#endif
// ensure there are no conflicting macros defined
#include "./undefxmlparsermacros.h"
#ifdef iftag
# undef iftag
#endif
#define iftag(tagName) if(xmlReader.name() == QLatin1String(tagName))
#ifdef eliftag
# undef eliftag
#endif
#define eliftag(tagName) else if(xmlReader.name() == QLatin1String(tagName))
#ifdef else_skip
# undef else_skip
#endif
#define else_skip else { xmlReader.skipCurrentElement(); }
#ifdef children
# undef children
#endif
#define children while(xmlReader.readNextStartElement())
#ifdef text
# undef text
#endif
#define text xmlReader.readElementText(QXmlStreamReader::ErrorOnUnexpectedElement)
#ifdef attribute
# undef attribute
#endif
#define attribute(attributeName) xmlReader.attributes().value(QLatin1String(attributeName))

View File

@ -31,7 +31,8 @@ HEADERS += \
resources/qtconfigarguments.h \
misc/dialogutils.h \
misc/desktoputils.h \
misc/xmlparsermacros.h
misc/xmlparsermacros.h \
misc/undefxmlparsermacros.h
SOURCES += resources/resources.cpp \
models/checklistmodel.cpp \