KConfig

KConfigXmlParser.h
1 /*
2  This file is part of the KDE libraries
3 
4  SPDX-FileCopyrightText: 2003 Cornelius Schumacher <[email protected]>
5  SPDX-FileCopyrightText: 2003 Waldo Bastian <[email protected]>
6  SPDX-FileCopyrightText: 2003 Zack Rusin <[email protected]>
7  SPDX-FileCopyrightText: 2006 MichaĆ«l Larouche <[email protected]>
8  SPDX-FileCopyrightText: 2008 Allen Winter <[email protected]>
9  SPDX-FileCopyrightText: 2020 Tomaz Cananbrava <[email protected]>
10 
11  SPDX-License-Identifier: LGPL-2.0-or-later
12 */
13 
14 #ifndef KCONFIGXMLPARSER_H
15 #define KCONFIGXMLPARSER_H
16 
17 #include <QDomDocument>
18 #include <QString>
19 #include <QRegularExpression>
20 
21 #include "KConfigCommonStructs.h"
22 #include "KConfigParameters.h"
23 
24 /* This parses the contents of a Xml file into a ParseResult Structure,
25  * It also fails hard:
26  * If start() succeeds, you can use the result,
27  * if start() fails, the program aborts with an error message so there's
28  * no possibility of generating incorrect code information.
29  */
30 class KConfigXmlParser
31 {
32 public:
33  KConfigXmlParser(const KConfigParameters &cfg, const QString &inputFileName);
34 
35  // Start the parser and reads the contents of the inputFileName into the ParseResult Structure
36  void start();
37 
38  // Get the result of the parse
39  ParseResult getParseResult() const;
40 
41 private:
42  // creates a `somethingChanged` signal for every property
43  void createChangedSignal(CfgEntry &readEntry);
44 
45  void validateNameAndKey(CfgEntry &readEntry, const QDomElement &element);
46 
47  // TODO: Use std::optional and CfgEntry (without heap allocation) for this function
48  // *or* fail hard if the parse fails.
49  CfgEntry *parseEntry(const QString &group, const QString &parentGroup, const QDomElement &element);
50 
51  // Steps
52  void readIncludeTag(const QDomElement &element);
53  void readGroupTag(const QDomElement &element);
54  void readKcfgfileTag(const QDomElement &element);
55  void readSignalTag(const QDomElement &element);
56 
57  // Those are the Entries in the Xml, that represent a parameter within the <group> </group> tag.
58  void readParameterFromEntry(CfgEntry &entry, const QDomElement &element);
59  bool hasDefaultCode(CfgEntry &entry, const QDomElement &element);
60  void readChoicesFromEntry(CfgEntry &entry, const QDomElement &element);
61  void readGroupElements(CfgEntry &entry, const QDomElement &element);
62  void readParamDefaultValues(CfgEntry &entry, const QDomElement &element);
63 
64 private:
65  ParseResult mParseResult;
67  QString mInputFileName;
68  QStringList mAllNames;
69  QRegularExpression mValidNameRegexp;
70 };
71 
72 #endif
Configuration Compiler Configuration.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jul 10 2020 22:46:28 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.