Cute Chess  0.1
openingsuite.h
1 /*
2  This file is part of Cute Chess.
3 
4  Cute Chess 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, either version 3 of the License, or
7  (at your option) any later version.
8 
9  Cute Chess is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #ifndef OPENINGSUITE_H
19 #define OPENINGSUITE_H
20 
21 #include <QVector>
22 #include "pgngame.h"
23 class QString;
24 class QFile;
25 class QTextStream;
26 class PgnStream;
27 
39 class LIB_EXPORT OpeningSuite
40 {
41  public:
43  enum Format
44  {
46  PgnFormat
47  };
48 
50  enum Order
51  {
53  RandomOrder
54  };
55 
59  OpeningSuite(const QString& fen);
73  OpeningSuite(const QString& fileName,
74  Format format,
75  Order order = SequentialOrder,
76  int startIndex = 0);
78  ~OpeningSuite();
79 
81  Format format() const;
83  Order order() const;
88  bool isNull() const;
89 
101  bool initialize();
106  PgnGame nextGame(int maxPlies);
107 
108  private:
109  struct FilePosition
110  {
111  qint64 pos;
112  qint64 lineNumber;
113  };
114 
115  FilePosition getPgnPos();
116  FilePosition getEpdPos();
117 
118  Format m_format;
119  Order m_order;
120  int m_gamesRead;
121  int m_gameIndex;
122  int m_startIndex;
123  QString m_fileName;
124  QString m_fen;
125  QFile* m_file;
126  QTextStream* m_epdStream;
127  PgnStream* m_pgnStream;
128  QVector<FilePosition> m_filePositions;
129 };
130 
131 #endif // OPENINGSUITE_H
A class for reading games in PGN format from a text stream.
Definition: pgnstream.h:41
Order
Definition: openingsuite.h:50
A game of chess in PGN format.
Definition: pgngame.h:51
EPD format.
Definition: openingsuite.h:45
Sequential order.
Definition: openingsuite.h:52
Format
Definition: openingsuite.h:43
A suite of chess openings.
Definition: openingsuite.h:39