AusweisApp
Lade ...
Suche ...
Keine Treffer
ElementParser.h
gehe zur Dokumentation dieser Datei
1
5#pragma once
6
8
9#include <QList>
10#include <QLoggingCategory>
11#include <QSharedPointer>
12#include <QXmlStreamReader>
13
14
15class test_ElementParser;
16
17
18namespace governikus
19{
20
22{
23 friend class ::test_ElementParser;
24
25 public:
26 explicit ElementParser(QSharedPointer<QXmlStreamReader> pXmlReader);
27 virtual ~ElementParser();
28
29 [[nodiscard]] bool parserFailed() const;
30
31 protected:
32 // helper methods
34
40
45 QString readElementText();
46
52 void assertMandatoryElement(const QString& pValue, const char* const pElementName);
53
60 template<typename T> bool assertMandatoryList(const QList<T>& pList, const char* const pElementName);
61
67 bool assertNoDuplicateElement(bool pNotYetSeen);
68
79 bool readUniqueElementText(QString& pText);
80
85 void skipCurrentElement() const;
86
91 [[nodiscard]] QStringView getElementName() const;
92
93 void setParserFailed();
94
95 void initData(const QByteArray& pXmlData);
96
97 [[nodiscard]] QStringView getElementTypeByNamespace(const QString& pNamespace) const;
98
99 private:
100 static const QLoggingCategory& getLoggingCategory();
101
102 QSharedPointer<QXmlStreamReader> mXmlReader;
103 bool mParseError;
104};
105
106
107template<typename T> bool ElementParser::assertMandatoryList(const QList<T>& pList, const char* const pElementName)
108{
109 if (pList.isEmpty())
110 {
111 qCWarning(getLoggingCategory()) << "Mandatory list is empty:" << pElementName;
112 mParseError = true;
113 return false;
114 }
115
116 return true;
117}
118
119
120} // namespace governikus
Definition ConnectionHandle.h:13
Definition ElementParser.h:22
bool assertMandatoryList(const QList< T > &pList, const char *const pElementName)
Issues a log warning and sets the error when the list is empty.
Definition ElementParser.h:107
ConnectionHandle parseConnectionHandle()
Definition ElementParser.cpp:128
QStringView getElementTypeByNamespace(const QString &pNamespace) const
Definition ElementParser.cpp:108
bool parserFailed() const
Definition ElementParser.cpp:26
bool readNextStartElement()
Like QXmlStreamReader::readNextStartElement(), but also checks mParseError.
Definition ElementParser.cpp:32
void assertMandatoryElement(const QString &pValue, const char *const pElementName)
Issues a log warning and sets the error when the element has not been set, i.e.
Definition ElementParser.cpp:72
ElementParser(QSharedPointer< QXmlStreamReader > pXmlReader)
Definition ElementParser.cpp:16
QString readElementText()
Returns the text (simplified()) between the current start element and the corresponding end element.
Definition ElementParser.cpp:38
QStringView getElementName() const
Returns the name of the current element and issues a log message with it.
Definition ElementParser.cpp:100
bool assertNoDuplicateElement(bool pNotYetSeen)
Issues a log warning and sets the error when a duplicate element has been encountered.
Definition ElementParser.cpp:60
void initData(const QByteArray &pXmlData)
Definition ElementParser.cpp:114
void skipCurrentElement() const
Skips parsing of the current element Used to ignore unknown or unrecognized elements while parsing.
Definition ElementParser.cpp:94
bool readUniqueElementText(QString &pText)
Returns the text (simplified()) between the current start element and the corresponding end element,...
Definition ElementParser.cpp:82
void setParserFailed()
Definition ElementParser.cpp:122
Defines the AccessRight and AccessRole enum.
Definition CommandApdu.h:17