AusweisApp
Lade ...
Suche ...
Keine Treffer
ElementParser.h
gehe zur Dokumentation dieser Datei
1
9#pragma once
10
12
13#include <QList>
14#include <QLoggingCategory>
15#include <QSharedPointer>
16#include <QXmlStreamReader>
17
18
19Q_DECLARE_LOGGING_CATEGORY(paos)
20
21class test_ElementParser;
22
23namespace governikus
24{
25
27{
28 friend class ::test_ElementParser;
29
30 public:
32 virtual ~ElementParser();
33
34 [[nodiscard]] bool parserFailed() const;
35
36 protected:
37 // helper methods
39
45
50 QString readElementText();
51
57 void assertMandatoryElement(const QString& pValue, const char* const pElementName);
58
65 template<typename T> bool assertMandatoryList(const QList<T>& pList, const char* const pElementName);
66
73
84 bool readUniqueElementText(QString& pText);
85
90 void skipCurrentElement() const;
91
97
98 void setParserFailed();
99
100 void initData(const QByteArray& pXmlData);
101
103
104 private:
106 bool mParseError;
107};
108
109
110template<typename T> bool ElementParser::assertMandatoryList(const QList<T>& pList, const char* const pElementName)
111{
112 if (pList.isEmpty())
113 {
114 qCWarning(paos) << "Mandatory list is empty:" << pElementName;
115 mParseError = true;
116 return false;
117 }
118
119 return true;
120}
121
122
123} // namespace governikus
Definition ConnectionHandle.h:17
Definition ElementParser.h:27
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:110
ConnectionHandle parseConnectionHandle()
Definition ElementParser.cpp:123
QStringView getElementTypeByNamespace(const QString &pNamespace) const
Definition ElementParser.cpp:103
bool parserFailed() const
Definition ElementParser.cpp:21
bool readNextStartElement()
Like QXmlStreamReader::readNextStartElement(), but also checks mParseError.
Definition ElementParser.cpp:27
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:67
ElementParser(QSharedPointer< QXmlStreamReader > pXmlReader)
Definition ElementParser.cpp:11
QString readElementText()
Returns the text (simplified()) between the current start element and the corresponding end element.
Definition ElementParser.cpp:33
QStringView getElementName() const
Returns the name of the current element and issues a log message with it.
Definition ElementParser.cpp:95
bool assertNoDuplicateElement(bool pNotYetSeen)
Issues a log warning and sets the error when a duplicate element has been encountered.
Definition ElementParser.cpp:55
void initData(const QByteArray &pXmlData)
Definition ElementParser.cpp:109
void skipCurrentElement() const
Skips parsing of the current element Used to ignore unknown or unrecognized elements while parsing.
Definition ElementParser.cpp:89
bool readUniqueElementText(QString &pText)
Returns the text (simplified()) between the current start element and the corresponding end element,...
Definition ElementParser.cpp:77
void setParserFailed()
Definition ElementParser.cpp:117
Implementation of GeneralAuthenticate response APDUs.
Definition CommandApdu.h:17
QSharedPointer< T > decodeObject(const QByteArray &pData, bool pLogging=true)
Template function for decoding an OpenSSL type from DER encoded QByteArray.
Definition ASN1TemplateUtil.h:114