File indexing completed on 2024-11-10 04:40:47

0001 /*
0002     SPDX-FileCopyrightText: 2017 Daniel Vrátil <dvratil@kde.og>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QXmlStreamReader>
0010 
0011 #include <memory>
0012 
0013 class Node;
0014 class DocumentNode;
0015 class EnumNode;
0016 class ClassNode;
0017 class PropertyNode;
0018 
0019 class XmlParser
0020 {
0021 public:
0022     explicit XmlParser();
0023     ~XmlParser();
0024 
0025     bool parse(const QString &filename);
0026 
0027     Node const *tree() const;
0028 
0029 private:
0030     bool parseProtocol();
0031     bool parseCommand(DocumentNode *parent);
0032     bool parseEnum(ClassNode *parent);
0033     bool parseEnumValue(EnumNode *parent);
0034     bool parseParam(ClassNode *parent);
0035     bool parseCtor(ClassNode *parent);
0036     bool parseSetter(PropertyNode *parent);
0037 
0038     void printError(const QString &error);
0039 
0040 private:
0041     QXmlStreamReader mReader;
0042     std::unique_ptr<Node> mTree;
0043 };