Cute Chess  0.1
pgngameentry.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 PGNGAMEENTRY_H
20 #define PGNGAMEENTRY_H
21 
22 #include <QDate>
23 #include "board/result.h"
24 class PgnStream;
25 class PgnGameFilter;
26 class QDataStream;
27 
28 
40 class LIB_EXPORT PgnGameEntry
41 {
42  public:
44  enum TagType
45  {
53  VariantTag
54  };
55 
57  PgnGameEntry();
58 
60  void clear();
65  bool read(PgnStream& in);
66 
71  bool read(QDataStream& in);
72 
76  void write(QDataStream& out) const;
77 
82  bool match(const PgnGameFilter& filter) const;
83 
85  qint64 pos() const;
87  qint64 lineNumber() const;
88 
90  QString tagValue(TagType type) const;
91 
92  private:
93  void addTag(const QByteArray& tagValue);
94 
95  QByteArray m_data;
96 
97  qint64 m_pos;
98  qint64 m_lineNumber;
99 };
100 
102 extern LIB_EXPORT PgnStream& operator>>(PgnStream& in, PgnGameEntry& entry);
103 
105 extern LIB_EXPORT QDataStream& operator>>(QDataStream& in, PgnGameEntry& entry);
106 
108 extern LIB_EXPORT QDataStream& operator<<(QDataStream& out,
109  const PgnGameEntry& entry);
110 
111 #endif // PGNGAMEENTRY_H
A class for reading games in PGN format from a text stream.
Definition: pgnstream.h:42
An entry in a PGN collection.
Definition: pgngameentry.h:40
TagType
Definition: pgngameentry.h:44
A filter for chess games in a PGN database.
Definition: pgngamefilter.h:37
The starting date of the game.
Definition: pgngameentry.h:48
The player of the white pieces.
Definition: pgngameentry.h:50
The result of the game.
Definition: pgngameentry.h:52
The playing round ordinal of the game.
Definition: pgngameentry.h:49
The location of the event.
Definition: pgngameentry.h:47
The name of the tournament or match event.
Definition: pgngameentry.h:46
The player of the black pieces.
Definition: pgngameentry.h:51