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