edbee - Qt Editor Library
baseplistparser.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <QHash>
9 #include <QStack>
10 #include <QString>
11 #include <QVariant>
12 
13 class QIODevice;
14 class QXmlStreamReader;
15 
16 namespace edbee {
17 
20 {
21 public:
23  virtual ~BasePListParser();
24 
25  QString lastErrorMessage() const;
26 
27 protected:
28  void setLastErrorMessage( const QString& str );
29 
30  bool beginParsing( QIODevice* device );
31  bool endParsing();
32 
33  void raiseError( const QString& str );
34 
35  // general plist parsing
36  QList<QVariant> readList();
37  QHash<QString, QVariant> readDict();
38  QVariant readNextPlistType(int level=-1);
39 
40  bool readNextElement( const QString& name, int level=-1 );
41  QString readElementText();
42 
43  int currentStackLevel();
44 
45 private:
46 
47  QString lastErrorMessage_;
48  QStack<QString> elementStack_;
49  QXmlStreamReader* xml_;
50 
51 };
52 
53 } // edbee
int currentStackLevel()
returns the current stack-level
Definition: baseplistparser.cpp:180
BasePListParser()
The constructor for the parser.
Definition: baseplistparser.cpp:16
QString readElementText()
Reads the element text contents.
Definition: baseplistparser.cpp:171
bool readNextElement(const QString &name, int level=-1)
Reads the next element and optionally expects it to be the given name.
Definition: baseplistparser.cpp:137
virtual ~BasePListParser()
the default desctructor
Definition: baseplistparser.cpp:23
QString lastErrorMessage() const
Returns the last error message of the parsed file.
Definition: baseplistparser.cpp:30
void raiseError(const QString &str)
Call this method to raise an error and stop the xml parsing.
Definition: baseplistparser.cpp:79
Copyright 2011-2013 - Reliable Bits Software by Blommers IT.
Definition: commentcommand.cpp:22
QList< QVariant > readList()
reads a list of qvariants
Definition: baseplistparser.cpp:86
void setLastErrorMessage(const QString &str)
Sets the last error message. To correctly set the last error message while parsing please use raiseEr...
Definition: baseplistparser.cpp:38
QHash< QString, QVariant > readDict()
reads a dictionary
Definition: baseplistparser.cpp:99
bool beginParsing(QIODevice *device)
Start the parsing of the plist. If it isn&#39;t a valid plist this method return false. (it only checks and reads the existence of <plist>)
Definition: baseplistparser.cpp:46
QVariant readNextPlistType(int level=-1)
reads the next plist type
Definition: baseplistparser.cpp:114
A general plist xml-file parser.
Definition: baseplistparser.h:19
bool endParsing()
Closes the parsers.
Definition: baseplistparser.cpp:63