added macros to utilize XML parsing
This commit is contained in:
parent
5d88f428a2
commit
74b76e83a3
|
@ -6,6 +6,7 @@ set(HEADER_FILES
|
||||||
enterpassworddialog/enterpassworddialog.h
|
enterpassworddialog/enterpassworddialog.h
|
||||||
misc/dialogutils.h
|
misc/dialogutils.h
|
||||||
misc/desktoputils.h
|
misc/desktoputils.h
|
||||||
|
misc/xmlparsermacros.h
|
||||||
models/checklistmodel.h
|
models/checklistmodel.h
|
||||||
resources/qtconfigarguments.h
|
resources/qtconfigarguments.h
|
||||||
resources/resources.h
|
resources/resources.h
|
||||||
|
|
|
@ -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))
|
|
@ -30,7 +30,8 @@ HEADERS += \
|
||||||
models/checklistmodel.h \
|
models/checklistmodel.h \
|
||||||
resources/qtconfigarguments.h \
|
resources/qtconfigarguments.h \
|
||||||
misc/dialogutils.h \
|
misc/dialogutils.h \
|
||||||
misc/desktoputils.h
|
misc/desktoputils.h \
|
||||||
|
misc/xmlparsermacros.h
|
||||||
|
|
||||||
SOURCES += resources/resources.cpp \
|
SOURCES += resources/resources.cpp \
|
||||||
models/checklistmodel.cpp \
|
models/checklistmodel.cpp \
|
||||||
|
|
Loading…
Reference in New Issue