|
Cute Chess
0.1
|
A class for reading games in PGN format from a text stream. More...
#include <pgnstream.h>
Public Types | |
| enum | Status { Ok, ReadPastEnd } |
| enum | TokenType { NoToken, PgnMove, PgnMoveNumber, PgnTag, PgnComment, PgnLineComment, PgnNag, PgnResult, Unknown } |
Public Member Functions | |
| Chess::Board * | board () |
| QIODevice * | device () const |
| bool | isOpen () const |
| qint64 | lineNumber () const |
| bool | nextGame () |
| PgnStream (const QString &variant="standard") | |
| PgnStream (QIODevice *device, const QString &variant="standard") | |
| PgnStream (const QByteArray *string, const QString &variant="standard") | |
| qint64 | pos () const |
| char | readChar () |
| TokenType | readNext () |
| void | reset () |
| void | rewind () |
| void | rewindChar () |
| bool | seek (qint64 pos, qint64 lineNumber=1) |
| void | setDevice (QIODevice *device) |
| void | setString (const QByteArray *string) |
| bool | setVariant (const QString &variant) |
| Status | status () const |
| const QByteArray * | string () const |
| QByteArray | tagName () const |
| QByteArray | tagValue () const |
| QByteArray | tokenString () const |
| TokenType | tokenType () const |
| QString | variant () const |
| ~PgnStream () | |
A class for reading games in PGN format from a text stream.
PgnStream is used for reading PGN games from a QIODevice or a string. It has its own input methods, and keeps track of the current line number which can be used to report errors in the games. PgnStream also has its own Chess::Board object, so that the same board can be easily used with all the games in the stream. The chess variant can be changed at any time, so it's possible to read PGN streams that contain games of multiple variants.
| enum PgnStream::Status |
| enum PgnStream::TokenType |
The type of a PGN token.
|
explicit |
Creates a new PgnStream.
A device or a string must be set before the stream can be used.
Creates a PgnStream that operates on device.
|
explicit |
Creates a PgnStream that operates on string.
| PgnStream::~PgnStream | ( | ) |
Destructs the PgnStream object.
| Chess::Board * PgnStream::board | ( | ) |
Returns the Board object which is used to verify the moves and FEN strings in the stream.
| QIODevice * PgnStream::device | ( | ) | const |
Returns the assigned device, or 0 if no device is in use.
| bool PgnStream::isOpen | ( | ) | const |
Returns true if the stream is open.
| qint64 PgnStream::lineNumber | ( | ) | const |
Returns the current line number.
| bool PgnStream::nextGame | ( | ) |
Seeks to the next game in the stream. Returns true if a game is available; otherwise returns false.
This function must be called once for each new game, or nothing can be parsed.
| qint64 PgnStream::pos | ( | ) | const |
Returns the current position in the stream.
| char PgnStream::readChar | ( | ) |
Reads one character and returns it.
| PgnStream::TokenType PgnStream::readNext | ( | ) |
Reads the next token and returns its type.
Returns PgnStream::NoToken if a token is not available.
| void PgnStream::reset | ( | ) |
Resets the stream to its default state.
| void PgnStream::rewind | ( | ) |
Rewinds back to the start of input. This is equivalent to calling seek(0).
| void PgnStream::rewindChar | ( | ) |
Rewinds the stream position by one character, which means that the next time readChar() is called, nothing is read and the buffer character is returned.
| bool PgnStream::seek | ( | qint64 | pos, |
| qint64 | lineNumber = 1 |
||
| ) |
Seeks to position pos in the device, and sets the current line number to lineNumber. Returns true if successful; otherwise returns false.
| void PgnStream::setDevice | ( | QIODevice * | device | ) |
Sets the current device to device.
| void PgnStream::setString | ( | const QByteArray * | string | ) |
Sets the current string to string.
| bool PgnStream::setVariant | ( | const QString & | variant | ) |
Sets the chess variant to variant. Returns true if successful; otherwise returns false.
| PgnStream::Status PgnStream::status | ( | ) | const |
Returns the status of the stream.
| const QByteArray * PgnStream::string | ( | ) | const |
Returns the assigned string, or 0 if no string is in use.
| QByteArray PgnStream::tagName | ( | ) | const |
Returns the name of the current PGN tag.
| QByteArray PgnStream::tagValue | ( | ) | const |
Returns the value of the current PGN tag.
| QByteArray PgnStream::tokenString | ( | ) | const |
Returns the current token as string.
| PgnStream::TokenType PgnStream::tokenType | ( | ) | const |
Returns the type of the current token.
| QString PgnStream::variant | ( | ) | const |
Returns the chess variant.
1.8.11