added macros to utilize XML parsing

This commit is contained in:
Martchus 2016-03-03 01:43:48 +01:00
parent 5d88f428a2
commit 74b76e83a3
3 changed files with 44 additions and 1 deletions

View File

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

41
misc/xmlparsermacros.h Normal file
View File

@ -0,0 +1,41 @@
#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
#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

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