Calculate and show how many shots over/under score is
[scorecard] / src / xml-parser.h
1 /*
2  * Copyright (C) 2009 Sakari Poussa
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 2.
7  */
8
9 #ifndef XMLPARSER_H
10 #define XMLPARSER_H
11
12 #include <QList>
13 #include <QXmlDefaultHandler>
14
15 #include "data.h"
16
17 class ScoreHandler : public QXmlDefaultHandler
18 {
19  public:
20   ScoreHandler(QList<Score *> &scoreList);
21
22   bool startDocument();
23   bool endDocument();
24   bool startElement(const QString &namespaceURI, const QString &localName,
25                     const QString &qName, const QXmlAttributes &attributes);
26   bool endElement(const QString &namespaceURI, const QString &localName,
27                   const QString &qName);
28   bool fatalError(const QXmlParseException &exception);
29   QString errorString() const;
30   
31  private:
32   QList<Score *> &scoreList;
33   Score *score;
34   Hole *hole;
35   QString errorStr;
36   bool inScore;
37 };
38
39 class ClubHandler : public QXmlDefaultHandler
40 {
41  public:
42   ClubHandler(QList<Club *> &clubList);
43
44   bool startDocument();
45   bool endDocument();
46   bool startElement(const QString &namespaceURI, const QString &localName,
47                     const QString &qName, const QXmlAttributes &attributes);
48   bool endElement(const QString &namespaceURI, const QString &localName,
49                   const QString &qName);
50   bool fatalError(const QXmlParseException &exception);
51   QString errorString() const;
52   
53  private:
54   QList<Club *> &clubList;
55   Club *club;
56   Course *course;
57   Hole *hole;
58   QString errorStr;
59   bool inClub;
60   bool inCourse;
61 };
62
63 #endif