17#ifndef HOOVER_CHESS_UTILS__PGN_READER__PGNREADER_H_INCLUDED
18#define HOOVER_CHESS_UTILS__PGN_READER__PGNREADER_H_INCLUDED
77 virtual void pgnTag(std::string_view key, std::string_view value)
79 static_cast<void>(key);
80 static_cast<void>(value);
111 static_cast<void>(result);
122 static_cast<void>(curBoard);
123 static_cast<void>(prevBoard);
136 static_cast<void>(move);
145 virtual void nag(std::uint8_t nagNum)
147 static_cast<void>(nagNum);
210 static_cast<void>(error);
211 static_cast<void>(additionalInfo);
246 const unsigned int shift {
static_cast<unsigned int>(action) };
247 if (shift < 32U) [[likely]]
249 return UINT32_C(1) << shift;
261 template <
typename... Args>
273 template <
typename... Args>
285 const std::uint32_t mask {
actionBit(action) };
The chessboard.
Definition chessboard.h:589
A legal move. Important: see the note!
Definition chessboard.h:198
PGN error exception.
Definition pgnreader-error.h:70
PGN reader action filter.
Definition pgnreader.h:240
constexpr std::uint32_t getBitMask() noexcept
Returns a bit mask of enabled action classes. When bit N is set, action class with numeric value N is...
Definition pgnreader.h:306
constexpr bool isEnabled(PgnReaderActionClass action) noexcept
Returns whether an action class is enabled.
Definition pgnreader.h:297
static constexpr std::uint32_t actionBit(PgnReaderActionClass action) noexcept
Definition pgnreader.h:244
constexpr void enablePack(PgnReaderActionClass action, Args... rest) noexcept
Definition pgnreader.h:262
constexpr void enablePack() noexcept
Definition pgnreader.h:257
constexpr PgnReaderActionFilter(Args... enabled) noexcept
Constructor.
Definition pgnreader.h:274
std::uint32_t m_filterBits
Definition pgnreader.h:242
constexpr void set(PgnReaderActionClass action, bool enable) noexcept
Enables/disables an action class.
Definition pgnreader.h:283
Semantic actions for reading a PGN. The caller is expected to inherit this class and override all cal...
Definition pgnreader.h:62
virtual void endOfPGN()
End of PGN.
Definition pgnreader.h:172
virtual void variationStart()
Invoked after a variation start is processed.
Definition pgnreader.h:156
virtual void moveTextSection()
Invoked when all PGN tags of the game are read and before any moves are processed.
Definition pgnreader.h:90
virtual void comment(std::string_view comment)
PGN comment.
Definition pgnreader.h:99
virtual void gameStart()
Invoked when a new game starts.
Definition pgnreader.h:67
virtual void gameTerminated(PgnResult result)
Invoked after the game termination marker is processed.
Definition pgnreader.h:109
virtual PgnReaderOnErrorAction onError(const PgnError &error, const PgnErrorInfo &additionalInfo)
Error handler for recoverable errors.
Definition pgnreader.h:208
virtual void variationEnd()
Invoked after a variation end marker is encountered but before the board states have been restored.
Definition pgnreader.h:167
virtual void nag(std::uint8_t nagNum)
Invoked after a numeric annotation glyph (NAG) is processed.
Definition pgnreader.h:145
virtual void afterMove(Move move)
Invoked after a move is processed.
Definition pgnreader.h:134
virtual void pgnTag(std::string_view key, std::string_view value)
Invoked when a PGN tag has been read.
Definition pgnreader.h:77
virtual void setBoardReferences(const ChessBoard &curBoard, const ChessBoard &prevBoard)
Invoked when the PGN reader is instantiated.
Definition pgnreader.h:120
The PGN reader interface.
Definition pgnreader.h:314
static void readFromMemory(std::string_view pgn, PgnReaderActions &actions, PgnReaderActionFilter filter)
Reads and processes a PGN from memory.
PgnResult
Game result.
Definition pgnreader-types.h:32
PgnReaderActionClass
PGN reader filterable action classes.
Definition pgnreader.h:219
PgnReaderOnErrorAction
Action for recoverable PGN reader error.
Definition pgnreader.h:41
@ Comment
Comment actions.
@ Variation
Variation start/end, including any actions within a variation.
@ ContinueFromNextGame
Continue from next game.
@ NAG
Numeric annotation glyph.
Definition pgnscannertokens.h:121
Definition chessboard-types-squareset.h:30
Additional error info.
Definition pgnreader.h:54
std::uint64_t lineNumber
Line number of the error. Numbering starts from 1.
Definition pgnreader.h:56