aboutsummaryrefslogtreecommitdiff
path: root/libs/installer_fomod/src/xmlreader.h
blob: 974d3a1ff7efd60369e8ce672c92363b38cb79d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef XMLREADER_H
#define XMLREADER_H

#include <QXmlStreamReader>

class XmlReader : public QXmlStreamReader
{
public:
  XmlReader(QIODevice* device) : QXmlStreamReader(device) {}

  XmlReader(QByteArray array) : QXmlStreamReader(array) {}

  /** Get the next token, ignoring comments and white space text */
  TokenType readNext()
  {
    while (QXmlStreamReader::readNext() == Comment || isWhitespace()) {
      continue;
    }
    return tokenType();
  }

  /** get the next element.
   *
   * \param start - the name of the current start element
   *
   * \returns false if no more elements
   */
  bool getNextElement(QString const& start);

  /* Get the text associated with this token. */
  QString getText();

  /** Print a message if we get an unexpected tag */
  void unexpected();

  /** Read till the end of an element. Used for leaf nodes */
  void finishedElement();
};

#endif  // XMLREADER_H