diff --git a/CMakeLists.txt b/CMakeLists.txt index 4251595..0730d5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/misc/undefxmlparsermacros.h b/misc/undefxmlparsermacros.h new file mode 100644 index 0000000..e1f5467 --- /dev/null +++ b/misc/undefxmlparsermacros.h @@ -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 diff --git a/misc/xmlparsermacros.h b/misc/xmlparsermacros.h index c8f9ad6..561de16 100644 --- a/misc/xmlparsermacros.h +++ b/misc/xmlparsermacros.h @@ -1,41 +1,15 @@ -#include - /*! * \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)) diff --git a/qtutilities.pro b/qtutilities.pro index d059c4e..0a40e87 100644 --- a/qtutilities.pro +++ b/qtutilities.pro @@ -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 \