|
HooverChessUtils_PgnReader 0.9.0
|
Semantic actions for reading a PGN. The caller is expected to inherit this class and override all callbacks of interest. More...
#include <pgnreader.h>
Public Member Functions | |
| virtual void | gameStart () |
| Invoked when a new game starts. | |
| virtual void | pgnTag (std::string_view key, std::string_view value) |
| Invoked when a PGN tag has been read. | |
| virtual void | moveTextSection () |
| Invoked when all PGN tags of the game are read and before any moves are processed. | |
| virtual void | comment (std::string_view comment) |
| PGN comment. | |
| virtual void | gameTerminated (PgnResult result) |
| Invoked after the game termination marker is processed. | |
| virtual void | setBoardReferences (const ChessBoard &curBoard, const ChessBoard &prevBoard) |
| Invoked when the PGN reader is instantiated. | |
| virtual void | afterMove (Move move) |
| Invoked after a move is processed. | |
| virtual void | nag (std::uint8_t nagNum) |
| Invoked after a numeric annotation glyph (NAG) is processed. | |
| virtual void | variationStart () |
| Invoked after a variation start is processed. | |
| virtual void | variationEnd () |
| Invoked after a variation end marker is encountered but before the board states have been restored. | |
| virtual void | endOfPGN () |
| End of PGN. | |
| virtual PgnReaderOnErrorAction | onError (const PgnError &error, const PgnErrorInfo &additionalInfo) |
| Error handler for recoverable errors. | |
Semantic actions for reading a PGN. The caller is expected to inherit this class and override all callbacks of interest.
|
inlinevirtual |
Invoked after a move is processed.
| [in] | move | Move |
The state of *curBoard is after move. The state of *prevBoard is before move.
Callback is filtered by PgnReaderActionClass::Move.
|
inlinevirtual |
PGN comment.
| [in] | comment | Comment text |
PGN comments may occur almost anywhere.
Callback is filtered by PgnReaderActionClass::Comment.
|
inlinevirtual |
End of PGN.
|
inlinevirtual |
Invoked when a new game starts.
Callback is always enabled.
|
inlinevirtual |
Invoked after the game termination marker is processed.
| [in] | result | Game result |
Callback is always enabled.
|
inlinevirtual |
Invoked when all PGN tags of the game are read and before any moves are processed.
The state of *curBoard is the game starting position. The state of *prevBoard is the same.
Callback is always enabled.
|
inlinevirtual |
Invoked after a numeric annotation glyph (NAG) is processed.
| [in] | nagNum | Numeric value of the NAG. |
Callback is filtered by PgnReaderActionClass::Move and PgnReaderActionClass::NAG (both required).
|
inlinevirtual |
Error handler for recoverable errors.
| [in] | error | Error object |
| [in] | additionalInfo | Additional information on error |
PgnReaderOnErrorAction::AbortCaller-provided error handler is invoked on recoverable PGN errors. Those are tokenizer (scanner) errors, parser errors, board setup errors (FEN errors), move replay errors, and other errors related to the correctness of the PGN input. When such an error occurs, this callback function is invoked, which then returns the policy action.
The actions are:
PgnReaderOnErrorAction::Abort (default) — Abort processing and re-throw the PGN error exception as is. This is the default policy in case error handler is not overridden.PgnReaderOnErrorAction::ContinueFromNextGame — Abort processing the current game. Skip to the next game and continue from there. Note the following:gameTerminated() to indicate that the game ended.PgnReader::readFromMemory().Internally, the procedure to skip to the next game when PgnReaderOnErrorAction::ContinueFromNextGame is returned is straightforward. The tokenizer is invoked until it returns either RESULT (i.e., "1-0", "1/2-1/2", "0-1", "*") or END_OF_FILE tokens. It is possible that more than more error is returned for a single erroneous game.
|
inlinevirtual |
Invoked when a PGN tag has been read.
| [in] | key | Key of the PGN tag |
| [in] | value | Value of the PGN tag |
Callback is filtered by PgnReaderActionClass::PgnTag.
|
inlinevirtual |
Invoked when the PGN reader is instantiated.
| [in] | curBoard | Pointer to current board (after move) |
| [in] | prevBoard | Pointer to previous board (before move) |
Callback is filtered by PgnReaderActionClass::Move.
|
inlinevirtual |
Invoked after a variation end marker is encountered but before the board states have been restored.
The state of *curBoard the end of variation, after the last move. The state of *prevBoard before the last move.
Callback is filtered by PgnReaderActionClass::Variation.
|
inlinevirtual |
Invoked after a variation start is processed.
The state of *curBoard is beginning of variation (before any moves). The state of *prevBoard is the same.
Callback is filtered by PgnReaderActionClass::Variation.