HooverChessUtils_PgnReader 0.9.0
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions
PGN-reader API

Classes

class  hoover_chess_utils::pgn_reader::SquareSet
 Set of squares. Implemented using a bit-mask. More...
 
struct  hoover_chess_utils::pgn_reader::BitBoard
 Board representation using SquareSets (bit boards) More...
 
class  hoover_chess_utils::pgn_reader::Move
 A legal move. Important: see the note! More...
 
class  hoover_chess_utils::pgn_reader::CompactMove
 Compact representation of Move More...
 
class  hoover_chess_utils::pgn_reader::ChessBoard
 The chessboard. More...
 
class  hoover_chess_utils::pgn_reader::PgnError
 PGN error exception. More...
 
struct  hoover_chess_utils::pgn_reader::MiniString_Uninitialized
 Tag for unitialized storage. This is a tiny optimization to save a single write when constructing a MiniString. More...
 
class  hoover_chess_utils::pgn_reader::MiniString< t_maxLen >
 A Pascal-style length-prefixed string with the specified maximum length. More...
 
class  hoover_chess_utils::pgn_reader::StringUtils
 Miscellaneous string utilities. More...
 
struct  hoover_chess_utils::pgn_reader::PgnErrorInfo
 Additional error info. More...
 
class  hoover_chess_utils::pgn_reader::PgnReaderActions
 Semantic actions for reading a PGN. The caller is expected to inherit this class and override all callbacks of interest. More...
 
class  hoover_chess_utils::pgn_reader::PgnReaderActionFilter
 PGN reader action filter. More...
 
class  hoover_chess_utils::pgn_reader::PgnReader
 The PGN reader interface. More...
 
struct  hoover_chess_utils::pgn_reader::CompressedPosition_FixedLength
 A position encoded in 192 bits. More...
 
class  hoover_chess_utils::pgn_reader::PositionCompressor_FixedLength
 Position compressor that produces fixed-length output (192 bits). More...
 
class  hoover_chess_utils::pgn_reader::PgnReaderActionCompileTimeFilter< args >
 PGN reader action filter (compile-time) More...
 

Macros

#define SQUARESET_ENUMERATE(sq, squareSet, ...)    SQUARESET_ENUMERATE_INTERNAL(sq, squareSet, squareset_enumerate_internal_mask, __VA_ARGS__)
 Enumerates all squares in a square set.
 

Typedefs

using hoover_chess_utils::pgn_reader::SquareUnderlyingType = std::uint_fast8_t
 Underlying type of Square
 
using hoover_chess_utils::pgn_reader::SquareCompactType = std::uint8_t
 Compact type for Square. The compact type can store all legal enumeration values.
 
using hoover_chess_utils::pgn_reader::ColorUnderlyingType = std::uint_fast8_t
 Underlying type of Color
 
using hoover_chess_utils::pgn_reader::ColorCompactType = std::uint8_t
 Compact type for Color. The compact type can store all legal enumeration values.
 
using hoover_chess_utils::pgn_reader::PieceUnderlyingType = std::uint_fast8_t
 Underlying type of Piece
 
using hoover_chess_utils::pgn_reader::PieceCompactType = std::uint8_t
 Compact type for Piece. The compact type can store all legal enumeration values.
 
using hoover_chess_utils::pgn_reader::PieceAndColorUnderlyingType = std::uint_fast8_t
 Underlying type of PieceAndColor
 
using hoover_chess_utils::pgn_reader::PieceAndColorCompactType = std::uint8_t
 Compact type for PieceAndColor. The compact type can store all legal enumeration values.
 
using hoover_chess_utils::pgn_reader::PositionStatusUnderlyingType = std::uint_fast8_t
 Underlying type of PositionStatus
 
using hoover_chess_utils::pgn_reader::PositionStatusCompactType = std::uint8_t
 Compact type for PositionStatus. The compact type can store all legal enumeration values.
 
using hoover_chess_utils::pgn_reader::RowColumnUnderlyingType = std::uint_fast8_t
 Underlying type of RowColumn
 
using hoover_chess_utils::pgn_reader::RowColumnCompactType = std::uint8_t
 Compact type for RowColumn. The compact type can store all legal enumeration values.
 
using hoover_chess_utils::pgn_reader::RowColumn = RowColumnUnderlyingType
 Row/column coordinate type. Valid range: [0, 7] signifying ranks 1–8 (as rows) or files A–H (as columns). The numbering is always from White's point of view.
 
using hoover_chess_utils::pgn_reader::ArrayBoard = std::array< PieceAndColorCompact, 64U >
 Board representation using an array.
 
using hoover_chess_utils::pgn_reader::MoveList = std::array< CompactMove, 256U >
 Move list returned by ChessBoard::generateMoves().
 
using hoover_chess_utils::pgn_reader::ShortMoveList = std::array< CompactMove, 8U >
 Short move list returned by move generators for writing a SAN move. That is, when the piece type and destination square are known, and moves need to be generated to resolve the required disambiguation.
 
using hoover_chess_utils::pgn_reader::FenString = MiniString< 96U >
 MiniString containing a FEN.
 

Enumerations

enum class  hoover_chess_utils::pgn_reader::Square : SquareUnderlyingType {
  hoover_chess_utils::pgn_reader::Square::A1 = 0U , hoover_chess_utils::pgn_reader::Square::B1 = 1U , hoover_chess_utils::pgn_reader::Square::C1 = 2U , hoover_chess_utils::pgn_reader::Square::D1 = 3U ,
  hoover_chess_utils::pgn_reader::Square::E1 = 4U , hoover_chess_utils::pgn_reader::Square::F1 = 5U , hoover_chess_utils::pgn_reader::Square::G1 = 6U , hoover_chess_utils::pgn_reader::Square::H1 = 7U ,
  hoover_chess_utils::pgn_reader::Square::A2 = 8U , hoover_chess_utils::pgn_reader::Square::B2 = 9U , hoover_chess_utils::pgn_reader::Square::C2 = 10U , hoover_chess_utils::pgn_reader::Square::D2 = 11U ,
  hoover_chess_utils::pgn_reader::Square::E2 = 12U , hoover_chess_utils::pgn_reader::Square::F2 = 13U , hoover_chess_utils::pgn_reader::Square::G2 = 14U , hoover_chess_utils::pgn_reader::Square::H2 = 15U ,
  hoover_chess_utils::pgn_reader::Square::A3 = 16U , hoover_chess_utils::pgn_reader::Square::B3 = 17U , hoover_chess_utils::pgn_reader::Square::C3 = 18U , hoover_chess_utils::pgn_reader::Square::D3 = 19U ,
  hoover_chess_utils::pgn_reader::Square::E3 = 20U , hoover_chess_utils::pgn_reader::Square::F3 = 21U , hoover_chess_utils::pgn_reader::Square::G3 = 22U , hoover_chess_utils::pgn_reader::Square::H3 = 23U ,
  hoover_chess_utils::pgn_reader::Square::A4 = 24U , hoover_chess_utils::pgn_reader::Square::B4 = 25U , hoover_chess_utils::pgn_reader::Square::C4 = 26U , hoover_chess_utils::pgn_reader::Square::D4 = 27U ,
  hoover_chess_utils::pgn_reader::Square::E4 = 28U , hoover_chess_utils::pgn_reader::Square::F4 = 29U , hoover_chess_utils::pgn_reader::Square::G4 = 30U , hoover_chess_utils::pgn_reader::Square::H4 = 31U ,
  hoover_chess_utils::pgn_reader::Square::A5 = 32U , hoover_chess_utils::pgn_reader::Square::B5 = 33U , hoover_chess_utils::pgn_reader::Square::C5 = 34U , hoover_chess_utils::pgn_reader::Square::D5 = 35U ,
  hoover_chess_utils::pgn_reader::Square::E5 = 36U , hoover_chess_utils::pgn_reader::Square::F5 = 37U , hoover_chess_utils::pgn_reader::Square::G5 = 38U , hoover_chess_utils::pgn_reader::Square::H5 = 39U ,
  hoover_chess_utils::pgn_reader::Square::A6 = 40U , hoover_chess_utils::pgn_reader::Square::B6 = 41U , hoover_chess_utils::pgn_reader::Square::C6 = 42U , hoover_chess_utils::pgn_reader::Square::D6 = 43U ,
  hoover_chess_utils::pgn_reader::Square::E6 = 44U , hoover_chess_utils::pgn_reader::Square::F6 = 45U , hoover_chess_utils::pgn_reader::Square::G6 = 46U , hoover_chess_utils::pgn_reader::Square::H6 = 47U ,
  hoover_chess_utils::pgn_reader::Square::A7 = 48U , hoover_chess_utils::pgn_reader::Square::B7 = 49U , hoover_chess_utils::pgn_reader::Square::C7 = 50U , hoover_chess_utils::pgn_reader::Square::D7 = 51U ,
  hoover_chess_utils::pgn_reader::Square::E7 = 52U , hoover_chess_utils::pgn_reader::Square::F7 = 53U , hoover_chess_utils::pgn_reader::Square::G7 = 54U , hoover_chess_utils::pgn_reader::Square::H7 = 55U ,
  hoover_chess_utils::pgn_reader::Square::A8 = 56U , hoover_chess_utils::pgn_reader::Square::B8 = 57U , hoover_chess_utils::pgn_reader::Square::C8 = 58U , hoover_chess_utils::pgn_reader::Square::D8 = 59U ,
  hoover_chess_utils::pgn_reader::Square::E8 = 60U , hoover_chess_utils::pgn_reader::Square::F8 = 61U , hoover_chess_utils::pgn_reader::Square::G8 = 62U , hoover_chess_utils::pgn_reader::Square::H8 = 63U ,
  hoover_chess_utils::pgn_reader::Square::NONE = 64U
}
 Named square. More...
 
enum class  hoover_chess_utils::pgn_reader::Color : ColorUnderlyingType { hoover_chess_utils::pgn_reader::Color::WHITE = 0U , hoover_chess_utils::pgn_reader::Color::BLACK = 8U }
 Color of a piece or side to move. More...
 
enum class  hoover_chess_utils::pgn_reader::Piece : PieceUnderlyingType {
  hoover_chess_utils::pgn_reader::Piece::NONE = 0U , hoover_chess_utils::pgn_reader::Piece::PAWN , hoover_chess_utils::pgn_reader::Piece::KNIGHT , hoover_chess_utils::pgn_reader::Piece::BISHOP ,
  hoover_chess_utils::pgn_reader::Piece::ROOK , hoover_chess_utils::pgn_reader::Piece::QUEEN , hoover_chess_utils::pgn_reader::Piece::KING
}
 Named piece. More...
 
enum class  hoover_chess_utils::pgn_reader::PieceAndColor : PieceAndColorUnderlyingType {
  hoover_chess_utils::pgn_reader::PieceAndColor::NONE = 0U , hoover_chess_utils::pgn_reader::PieceAndColor::WHITE_PAWN = 1U , hoover_chess_utils::pgn_reader::PieceAndColor::WHITE_KNIGHT , hoover_chess_utils::pgn_reader::PieceAndColor::WHITE_BISHOP ,
  hoover_chess_utils::pgn_reader::PieceAndColor::WHITE_ROOK , hoover_chess_utils::pgn_reader::PieceAndColor::WHITE_QUEEN , hoover_chess_utils::pgn_reader::PieceAndColor::WHITE_KING , hoover_chess_utils::pgn_reader::PieceAndColor::BLACK_PAWN = 9U ,
  hoover_chess_utils::pgn_reader::PieceAndColor::BLACK_KNIGHT , hoover_chess_utils::pgn_reader::PieceAndColor::BLACK_BISHOP , hoover_chess_utils::pgn_reader::PieceAndColor::BLACK_ROOK , hoover_chess_utils::pgn_reader::PieceAndColor::BLACK_QUEEN ,
  hoover_chess_utils::pgn_reader::PieceAndColor::BLACK_KING , hoover_chess_utils::pgn_reader::PieceAndColor::WHITE_NONE = 0U , hoover_chess_utils::pgn_reader::PieceAndColor::BLACK_NONE = 8U
}
 Named piece and color. More...
 
enum class  hoover_chess_utils::pgn_reader::PieceAndColorCompact : PieceAndColorCompactType {
  hoover_chess_utils::pgn_reader::PieceAndColorCompact::NONE = 0U , hoover_chess_utils::pgn_reader::PieceAndColorCompact::WHITE_PAWN = 1U , hoover_chess_utils::pgn_reader::PieceAndColorCompact::WHITE_KNIGHT , hoover_chess_utils::pgn_reader::PieceAndColorCompact::WHITE_BISHOP ,
  hoover_chess_utils::pgn_reader::PieceAndColorCompact::WHITE_ROOK , hoover_chess_utils::pgn_reader::PieceAndColorCompact::WHITE_QUEEN , hoover_chess_utils::pgn_reader::PieceAndColorCompact::WHITE_KING , hoover_chess_utils::pgn_reader::PieceAndColorCompact::BLACK_PAWN = 9U ,
  hoover_chess_utils::pgn_reader::PieceAndColorCompact::BLACK_KNIGHT , hoover_chess_utils::pgn_reader::PieceAndColorCompact::BLACK_BISHOP , hoover_chess_utils::pgn_reader::PieceAndColorCompact::BLACK_ROOK , hoover_chess_utils::pgn_reader::PieceAndColorCompact::BLACK_QUEEN ,
  hoover_chess_utils::pgn_reader::PieceAndColorCompact::BLACK_KING , hoover_chess_utils::pgn_reader::PieceAndColorCompact::WHITE_NONE = 0U , hoover_chess_utils::pgn_reader::PieceAndColorCompact::BLACK_NONE = 8U
}
 Named piece and color (compact representation) More...
 
enum class  hoover_chess_utils::pgn_reader::PositionStatus : PositionStatusUnderlyingType { hoover_chess_utils::pgn_reader::PositionStatus::NORMAL , hoover_chess_utils::pgn_reader::PositionStatus::CHECK , hoover_chess_utils::pgn_reader::PositionStatus::STALEMATE , hoover_chess_utils::pgn_reader::PositionStatus::MATE }
 Status of a position. More...
 
enum class  hoover_chess_utils::pgn_reader::MoveTypeAndPromotion : MoveTypeAndPromotionUnderlyingType {
  hoover_chess_utils::pgn_reader::MoveTypeAndPromotion::REGULAR_PAWN_MOVE = 0U , hoover_chess_utils::pgn_reader::MoveTypeAndPromotion::REGULAR_KNIGHT_MOVE = 1U , hoover_chess_utils::pgn_reader::MoveTypeAndPromotion::REGULAR_BISHOP_MOVE = 2U , hoover_chess_utils::pgn_reader::MoveTypeAndPromotion::REGULAR_ROOK_MOVE = 3U ,
  hoover_chess_utils::pgn_reader::MoveTypeAndPromotion::REGULAR_QUEEN_MOVE = 4U , hoover_chess_utils::pgn_reader::MoveTypeAndPromotion::REGULAR_KING_MOVE = 5U , hoover_chess_utils::pgn_reader::MoveTypeAndPromotion::CASTLING_SHORT = 6U , hoover_chess_utils::pgn_reader::MoveTypeAndPromotion::CASTLING_LONG = 7U ,
  hoover_chess_utils::pgn_reader::MoveTypeAndPromotion::PROMO_KNIGHT = 8U , hoover_chess_utils::pgn_reader::MoveTypeAndPromotion::PROMO_BISHOP = 9U , hoover_chess_utils::pgn_reader::MoveTypeAndPromotion::PROMO_ROOK = 10U , hoover_chess_utils::pgn_reader::MoveTypeAndPromotion::PROMO_QUEEN = 11U ,
  hoover_chess_utils::pgn_reader::MoveTypeAndPromotion::EN_PASSANT = 12U , hoover_chess_utils::pgn_reader::MoveTypeAndPromotion::ILLEGAL = 15U
}
 Move type (4 bits, range: 0..15) More...
 
enum class  hoover_chess_utils::pgn_reader::PgnErrorCode : unsigned {
  hoover_chess_utils::pgn_reader::PgnErrorCode::OK = 0U , hoover_chess_utils::pgn_reader::PgnErrorCode::BAD_CHARACTER = 1U , hoover_chess_utils::pgn_reader::PgnErrorCode::BAD_PGN_TAG , hoover_chess_utils::pgn_reader::PgnErrorCode::UNEXPECTED_MOVE_NUM ,
  hoover_chess_utils::pgn_reader::PgnErrorCode::UNEXPECTED_TOKEN , hoover_chess_utils::pgn_reader::PgnErrorCode::BAD_FEN , hoover_chess_utils::pgn_reader::PgnErrorCode::ILLEGAL_MOVE , hoover_chess_utils::pgn_reader::PgnErrorCode::AMBIGUOUS_MOVE ,
  hoover_chess_utils::pgn_reader::PgnErrorCode::UNIMPLEMENTED , hoover_chess_utils::pgn_reader::PgnErrorCode::INTERNAL_ERROR
}
 Error code. More...
 
enum class  hoover_chess_utils::pgn_reader::PgnResult : std::uint_fast8_t { hoover_chess_utils::pgn_reader::PgnResult::WHITE_WIN , hoover_chess_utils::pgn_reader::PgnResult::BLACK_WIN , hoover_chess_utils::pgn_reader::PgnResult::DRAW , hoover_chess_utils::pgn_reader::PgnResult::UNKNOWN }
 Game result. More...
 
enum class  hoover_chess_utils::pgn_reader::PgnReaderOnErrorAction { hoover_chess_utils::pgn_reader::PgnReaderOnErrorAction::Abort , hoover_chess_utils::pgn_reader::PgnReaderOnErrorAction::ContinueFromNextGame }
 Action for recoverable PGN reader error. More...
 
enum class  hoover_chess_utils::pgn_reader::PgnReaderActionClass : unsigned int {
  hoover_chess_utils::pgn_reader::PgnReaderActionClass::PgnTag = 0U , hoover_chess_utils::pgn_reader::PgnReaderActionClass::Move , hoover_chess_utils::pgn_reader::PgnReaderActionClass::NAG , hoover_chess_utils::pgn_reader::PgnReaderActionClass::Variation ,
  hoover_chess_utils::pgn_reader::PgnReaderActionClass::Comment
}
 PGN reader filterable action classes. More...
 
enum class  hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding {
  hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::WHITE_KING_NOT_IN_TURN = 0U , hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::WHITE_BISHOP = 1U , hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::WHITE_ROOK_CANNOT_CASTLE = 2U , hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::WHITE_QUEEN = 3U ,
  hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::WHITE_KNIGHT = 4U , hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::WHITE_PAWN = 5U , hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::WHITE_ROOK_CAN_CASTLE = 6U , hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::WHITE_KING_IN_TURN = 7U ,
  hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::EP_PAWN = 8U , hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::BLACK_BISHOP = 9U , hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::BLACK_ROOK_CANNOT_CASTLE = 10U , hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::BLACK_QUEEN = 11U ,
  hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::BLACK_KNIGHT = 12U , hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::BLACK_PAWN = 13U , hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::BLACK_ROOK_CAN_CASTLE = 14U , hoover_chess_utils::pgn_reader::CompressedPosition_PieceEncoding::BLACK_KING = 15U
}
 Compressed piece encoding for fixed-length compressed position. More...
 

Functions

constexpr bool hoover_chess_utils::pgn_reader::isValidValue (Square sq) noexcept
 Checks whether a value is a valid enumeration value.
 
constexpr bool hoover_chess_utils::pgn_reader::isValidSquare (Square sq) noexcept
 Checks whether a value is a square.
 
constexpr Square hoover_chess_utils::pgn_reader::makeSquare (RowColumn col, RowColumn row) noexcept
 Constructs a square from column and row.
 
constexpr RowColumn hoover_chess_utils::pgn_reader::columnOf (Square sq) noexcept
 Returns column number of square.
 
constexpr RowColumn hoover_chess_utils::pgn_reader::rowOf (Square sq) noexcept
 Returns row number of square.
 
constexpr Square hoover_chess_utils::pgn_reader::getSquareForIndex (std::size_t index) noexcept
 Returns a square for an index. In essence, this is the ordinal of the square.
 
constexpr std::size_t hoover_chess_utils::pgn_reader::getIndexOfSquare (Square sq) noexcept
 Returns an index for a square.
 
constexpr Square hoover_chess_utils::pgn_reader::addToSquareNoOverflowCheck (Square sq, std::int_fast8_t shift) noexcept
 Adds to square. This function performs no overflow checking.
 
constexpr bool hoover_chess_utils::pgn_reader::isValidValue (Color c) noexcept
 Checks whether a value is a valid enumeration value.
 
constexpr Color hoover_chess_utils::pgn_reader::oppositeColor (Color c) noexcept
 Flips the color.
 
constexpr Color hoover_chess_utils::pgn_reader::colorOf (PieceAndColor pc) noexcept
 Returns color of a piece.
 
constexpr bool hoover_chess_utils::pgn_reader::isValidValue (Piece p) noexcept
 Checks whether a value is a valid enumeration value.
 
constexpr bool hoover_chess_utils::pgn_reader::isValidValue (PieceAndColor pc) noexcept
 Checks whether a value is a valid enumeration value.
 
constexpr Piece hoover_chess_utils::pgn_reader::pieceOf (PieceAndColor pc) noexcept
 Returns piece of a piece and color enumeration value.
 
constexpr PieceAndColor hoover_chess_utils::pgn_reader::makePieceAndColor (Piece p, Color c) noexcept
 Constructs a PieceAndColor enumeration value from Piece and Color.
 
constexpr PieceAndColorCompact hoover_chess_utils::pgn_reader::toCompactType (PieceAndColor pc) noexcept
 Converts PieceAndColor (fast type) to PieceAndColorCompact (compact type).
 
constexpr PieceAndColor hoover_chess_utils::pgn_reader::toFastType (PieceAndColorCompact pc) noexcept
 Converts PieceAndColorCompact (compact type) to PieceAndColor (fast type).
 
constexpr std::uint_fast32_t hoover_chess_utils::pgn_reader::makePlyNum (std::uint_fast32_t moveNum, Color color) noexcept
 Computes the ply number from full move number and side to move.
 
constexpr Color hoover_chess_utils::pgn_reader::colorOfPly (std::uint_fast32_t plyNum) noexcept
 Returns side to move for a ply number.
 
constexpr std::uint_fast32_t hoover_chess_utils::pgn_reader::moveNumOfPly (std::uint_fast32_t plyNum) noexcept
 Computes the full move for a ply number.
 
auto hoover_chess_utils::pgn_reader::operator<=> (const CompressedPosition_FixedLength &lhs, const CompressedPosition_FixedLength &rhs) noexcept
 Three-way comparison operator (spaceship). The comparison provides strong ordering.
 
bool hoover_chess_utils::pgn_reader::operator== (const CompressedPosition_FixedLength &lhs, const CompressedPosition_FixedLength &rhs) noexcept
 Equality comparison operator.
 

Detailed Description

Macro Definition Documentation

◆ SQUARESET_ENUMERATE

#define SQUARESET_ENUMERATE (   sq,
  squareSet,
  ... 
)     SQUARESET_ENUMERATE_INTERNAL(sq, squareSet, squareset_enumerate_internal_mask, __VA_ARGS__)

Enumerates all squares in a square set.

Parameters
[in]sqVariable name for enumerated squares
[in]squareSetSquare set
[in]...Statements to execute per enumerated square. Statements may include continue and break. The last statement does not have to end with semi-colon.

Example

std::uint8_t inefficientPopcount(SquareSet sqSetToEnumerate)
{
std::uint8_t ret { };
sq, sqSetToEnumerate,
++ret);
return ret;
}
#define SQUARESET_ENUMERATE(sq, squareSet,...)
Enumerates all squares in a square set.
Definition chessboard-types-squareset.h:623

Typedef Documentation

◆ ArrayBoard

Board representation using an array.

The layout is as follows:

index = row * 8 + column
See also
ChessBoard::setBoard()
getIndexOfSquare()

◆ ColorCompactType

Compact type for Color. The compact type can store all legal enumeration values.

◆ ColorUnderlyingType

using hoover_chess_utils::pgn_reader::ColorUnderlyingType = typedef std::uint_fast8_t

Underlying type of Color

See also
ColorCompactType

◆ FenString

MiniString containing a FEN.

For maximum size bound, the following template was used:

xxxxxxxx/xxxxxxxx/xxxxxxxx/xxxxxxxx/xxxxxxxx/xxxxxxxx/xxxxxxxx/xxxxxxxx w KQkq ep 255 4294967295
123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456
0        1         2         3         4         5         6         7         8         9

which is 96 bytes. Technically, this board could not have EP, but that can be arranged with individual empty squares.

◆ MoveList

using hoover_chess_utils::pgn_reader::MoveList = typedef std::array<CompactMove, 256U>

Move list returned by ChessBoard::generateMoves().

The move list is big enough to store all possible moves for any given position.

◆ PieceAndColorCompactType

Compact type for PieceAndColor. The compact type can store all legal enumeration values.

◆ PieceAndColorUnderlyingType

Underlying type of PieceAndColor

See also
PieceAndColorCompactType

◆ PieceCompactType

Compact type for Piece. The compact type can store all legal enumeration values.

◆ PieceUnderlyingType

using hoover_chess_utils::pgn_reader::PieceUnderlyingType = typedef std::uint_fast8_t

Underlying type of Piece

See also
PieceCompactType

◆ PositionStatusCompactType

Compact type for PositionStatus. The compact type can store all legal enumeration values.

◆ PositionStatusUnderlyingType

Underlying type of PositionStatus

See also
PositionStatusCompactType

◆ RowColumn

Row/column coordinate type. Valid range: [0, 7] signifying ranks 1–8 (as rows) or files A–H (as columns). The numbering is always from White's point of view.

◆ RowColumnCompactType

Compact type for RowColumn. The compact type can store all legal enumeration values.

◆ RowColumnUnderlyingType

Underlying type of RowColumn

See also
RowColumnCompactType

◆ ShortMoveList

Short move list returned by move generators for writing a SAN move. That is, when the piece type and destination square are known, and moves need to be generated to resolve the required disambiguation.

◆ SquareCompactType

Compact type for Square. The compact type can store all legal enumeration values.

◆ SquareUnderlyingType

using hoover_chess_utils::pgn_reader::SquareUnderlyingType = typedef std::uint_fast8_t

Underlying type of Square

See also
SquareCompactType

Enumeration Type Documentation

◆ Color

Color of a piece or side to move.

Enumerator
WHITE 

White piece or white side to move.

BLACK 

Black piece or black side to move.

◆ CompressedPosition_PieceEncoding

Compressed piece encoding for fixed-length compressed position.

See also
CompressedPosition_FixedLength
PositionCompressor_FixedLength
Enumerator
WHITE_KING_NOT_IN_TURN 

White king, white to move.

WHITE_BISHOP 

White bishop.

WHITE_ROOK_CANNOT_CASTLE 

White rook (no castling rights)

WHITE_QUEEN 

White queen.

WHITE_KNIGHT 

White knight.

WHITE_PAWN 

White pawn.

WHITE_ROOK_CAN_CASTLE 

White rook, has castling rights.

WHITE_KING_IN_TURN 

White king, white to move.

EP_PAWN 

En-passant capturable pawn.

The color of the en-passant capturable pawn depends on the side to move. 
BLACK_BISHOP 

Black bishop.

BLACK_ROOK_CANNOT_CASTLE 

Black rook, no castling rights.

BLACK_QUEEN 

Black queen.

BLACK_KNIGHT 

Black knight.

BLACK_PAWN 

Black pawn.

BLACK_ROOK_CAN_CASTLE 

Black rook, has castling rights.

BLACK_KING 

Black king.

◆ MoveTypeAndPromotion

Move type (4 bits, range: 0..15)

Unless otherwise stated, Move::getSrc() and Move::getDst(). specify the source and destination squares of the move.

See also
Move::getTypeAndPromotion()
Enumerator
REGULAR_PAWN_MOVE 

Regular non-capturing or capturing move (no promotion or en passant)

REGULAR_KNIGHT_MOVE 

Knight move.

REGULAR_BISHOP_MOVE 

Bishop move.

REGULAR_ROOK_MOVE 

Rook move.

REGULAR_QUEEN_MOVE 

Queen move.

REGULAR_KING_MOVE 

King move (not castling)

CASTLING_SHORT 

Short castling.

<dl>
  <dt>King source square</dt>
  <dd><tt>@ref Move::getSrc()</tt></dd>

  <dt>King destination square</dt>
  <dd><tt><tt>@ref makeSquare</tt>(6U, <tt>@ref rowOf</tt>(<tt>@ref Move::getSrc()</tt>))</tt></dd>

  <dt>Rook source square</dt>
  <dd><tt>@ref Move::getDst()</tt></dd>

  <dt>Rook destination square</dt>
  <dd><tt><tt>@ref makeSquare</tt>(5U, <tt>@ref rowOf</tt>(<tt>@ref Move::getDst()</tt>))</tt></dd>
</dl> 
CASTLING_LONG 

Long castling.

<dl>
  <dt>King source square</dt>
  <dd><tt>@ref Move::getSrc()</tt></dd>

  <dt>King destination square</dt>
  <dd><tt><tt>@ref makeSquare</tt>(2U, <tt>@ref rowOf</tt>(<tt>@ref Move::getSrc()</tt>))</tt></dd>

  <dt>Rook source square</dt>
  <dd><tt>@ref Move::getDst()</tt></dd>

  <dt>Rook destination square</dt>
  <dd><tt><tt>@ref makeSquare</tt>(3U, <tt>@ref rowOf</tt>(<tt>@ref Move::getDst()</tt>))</tt></dd>
</dl> 
PROMO_KNIGHT 

Pawn promotion to knight.

PROMO_BISHOP 

Pawn promotion to bishop.

PROMO_ROOK 

Pawn promotion to rook.

PROMO_QUEEN 

Pawn promotion to queen.

EN_PASSANT 

Pawn en-passant capture.

<dl>
  <dt>Pawn source square</dt>
  <dd><tt>@ref Move::getSrc()</tt></dd>

  <dt>Pawn destination square</dt>
  <dd><tt>@ref Move::getDst()</tt></dd>

  <dt>En passant square</dt>
  <dd><tt><tt>@ref makeSquare</tt>(<tt>@ref columnOf</tt>(<tt>@ref Move::getDst()</tt>), <tt>@ref rowOf</tt>(<tt>@ref Move::getSrc()</tt>))</tt></dd>
</dl> 
ILLEGAL 

Illegal move type.

Represents an illegal move. Returned by single move generators in
case the generated move count is not 1.

@note The destination square for illegal moves must be
<tt>@ref Square::H8</tt> for fast implementation of
<tt>@ref Move::isIllegal()</tt>. 

◆ PgnErrorCode

enum class hoover_chess_utils::pgn_reader::PgnErrorCode : unsigned
strong

Error code.

See also
PgnError
Enumerator
OK 

Code for success. Never set in PgnError by this code base.

BAD_CHARACTER 

Unexpected character in PGN input (tokenizer error)

BAD_PGN_TAG 

PGN tag parsing failed (parser error)

UNEXPECTED_MOVE_NUM 

Unexpected (bad) move number (PGN reader error)

UNEXPECTED_TOKEN 

Unexpected (bad) token (parser error)

BAD_FEN 

Bad or illegal FEN (position setup error)

ILLEGAL_MOVE 

Illegal move.

AMBIGUOUS_MOVE 

Ambiguous move (missing source file/rank specifiers)

UNIMPLEMENTED 

Unimplemented functionality.

INTERNAL_ERROR 

Internal logic error.

◆ PgnReaderActionClass

enum class hoover_chess_utils::pgn_reader::PgnReaderActionClass : unsigned int
strong

PGN reader filterable action classes.

Enumerator
PgnTag 

PGN tag actions.

Move 

Move actions, including boards.

NAG 

Numeric annotation glyphs actions.

@remark Requires also <tt>@ref Move</tt>. 
Variation 

Variation start/end, including any actions within a variation.

Comment 

Comment actions.

◆ PgnReaderOnErrorAction

Action for recoverable PGN reader error.

See also
PgnReaderActions::onError()
Enumerator
Abort 

Abort processing.

ContinueFromNextGame 

Continue from next game.

◆ PgnResult

enum class hoover_chess_utils::pgn_reader::PgnResult : std::uint_fast8_t
strong

Game result.

Enumerator
WHITE_WIN 

White win.

BLACK_WIN 

Black win.

DRAW 

Draw.

UNKNOWN 

Unknown/undetermined.

◆ Piece

Named piece.

Enumerator
NONE 

Value representing no piece.

PAWN 

Pawn.

KNIGHT 

Knight.

BISHOP 

Bishop.

ROOK 

Rook.

QUEEN 

Queen.

KING 

King.

◆ PieceAndColor

Named piece and color.

Remarks
Values are organized such that extracting Piece and Color is a matter of bitwise and.
Enumerator
NONE 

Value representing no piece and color. This is synonym to WHITE_NONE.

WHITE_PAWN 

White pawn.

WHITE_KNIGHT 

White knight.

WHITE_BISHOP 

White bishop.

WHITE_ROOK 

White rook.

WHITE_QUEEN 

White queen.

WHITE_KING 

White king.

BLACK_PAWN 

Black pawn.

BLACK_KNIGHT 

Black knight.

BLACK_BISHOP 

Black bishop.

BLACK_ROOK 

Black rook.

BLACK_QUEEN 

Black queen.

BLACK_KING 

Black king.

WHITE_NONE 

Special value to make makePieceAndColor(Piece::NONE, Color::WHITE) well-defined.

BLACK_NONE 

Special value to make makePieceAndColor(Piece::NONE, Color::BLACK) well-defined.

◆ PieceAndColorCompact

Named piece and color (compact representation)

The compact representation is generally better suited to store in memory than the fast type.

Use toCompactType() and toFastType() to switch between representations.

Enumerator
NONE 

Value representing no piece and color. This is synonym to WHITE_NONE.

WHITE_PAWN 

White pawn.

WHITE_KNIGHT 

White knight.

WHITE_BISHOP 

White bishop.

WHITE_ROOK 

White rook.

WHITE_QUEEN 

White queen.

WHITE_KING 

White king.

BLACK_PAWN 

Black pawn.

BLACK_KNIGHT 

Black knight.

BLACK_BISHOP 

Black bishop.

BLACK_ROOK 

Black rook.

BLACK_QUEEN 

Black queen.

BLACK_KING 

Black king.

WHITE_NONE 

Special value to make makePieceAndColor(Piece::NONE, Color::WHITE) well-defined.

BLACK_NONE 

Special value to make makePieceAndColor(Piece::NONE, Color::BLACK) well-defined.

◆ PositionStatus

Status of a position.

Remarks
Note that with correct API usage, a ChessBoard can never hold an illegal position. Hence, there is no enumeration for an illegal position.
See also
ChessBoard::determineStatus()
Enumerator
NORMAL 

Regular position (not in check, mate, or stalemate)

CHECK 

King is checked (but not mated)

STALEMATE 

Stalemate.

MATE 

Mate.

◆ Square

Named square.

Squares are ordered by rank (ascending) and file (ascending). Square::NONE comes after all valid squares. That is:

Square::A1 < Square::B1 < ... < Square::H1 < Square::A2 < ... < Square::H8 < Square::NONE

The enumeration value of a square is the same as its index on an array board.

In bit-board illustrations, the squares are represented as follows:

A8B8C8D8E8F8G8H8
A7B7C7D7E7F7G7H7
A6B6C6D6E6F6G6H6
A5B5C5D5E5F5G5H5
A4B4C4D4E4F4G4H4
A3B3C3D3E3F3G3H3
A2B2C2D2E2F2G2H2
A1B1C1D1E1F1G1H1
See also
isValidValue(Square), isValidSquare()
makeSquare(), rowOf(Square), columnOf(Square)
getSquareForIndex(), getIndexOfSquare()
RowColumn
Enumerator
A1 

row 0, column 0

B1 

row 0, column 1

C1 

row 0, column 2

D1 

row 0, column 3

E1 

row 0, column 4

F1 

row 0, column 5

G1 

row 0, column 6

H1 

row 0, column 7

A2 

row 1, column 0

B2 

row 1, column 1

C2 

row 1, column 2

D2 

row 1, column 3

E2 

row 1, column 4

F2 

row 1, column 5

G2 

row 1, column 6

H2 

row 1, column 7

A3 

row 2, column 0

B3 

row 2, column 1

C3 

row 2, column 2

D3 

row 2, column 3

E3 

row 2, column 4

F3 

row 2, column 5

G3 

row 2, column 6

H3 

row 2, column 7

A4 

row 3, column 0

B4 

row 3, column 1

C4 

row 3, column 2

D4 

row 3, column 3

E4 

row 3, column 4

F4 

row 3, column 5

G4 

row 3, column 6

H4 

row 3, column 7

A5 

row 4, column 0

B5 

row 4, column 1

C5 

row 4, column 2

D5 

row 4, column 3

E5 

row 4, column 4

F5 

row 4, column 5

G5 

row 4, column 6

H5 

row 4, column 7

A6 

row 5, column 0

B6 

row 5, column 1

C6 

row 5, column 2

D6 

row 5, column 3

E6 

row 5, column 4

F6 

row 5, column 5

G6 

row 5, column 6

H6 

row 5, column 7

A7 

row 6, column 0

B7 

row 6, column 1

C7 

row 6, column 2

D7 

row 6, column 3

E7 

row 6, column 4

F7 

row 6, column 5

G7 

row 6, column 6

H7 

row 6, column 7

A8 

row 7, column 0

B8 

row 7, column 1

C8 

row 7, column 2

D8 

row 7, column 3

E8 

row 7, column 4

F8 

row 7, column 5

G8 

row 7, column 6

H8 

row 7, column 7

NONE 

Token for 'no' square.

Function Documentation

◆ addToSquareNoOverflowCheck()

constexpr Square hoover_chess_utils::pgn_reader::addToSquareNoOverflowCheck ( Square  sq,
std::int_fast8_t  shift 
)
inlineconstexprnoexcept

Adds to square. This function performs no overflow checking.

Parameters
[in]sqSquare
[in]shiftAmount to add (or subtract for negative shifts)
Returns
Square value added by shift

This function is equivalent to:

constexpr std::size_t getIndexOfSquare(Square sq) noexcept
Returns an index for a square.
Definition chessboard-types.h:372
Square
Named square.
Definition chessboard-types.h:122
constexpr Square getSquareForIndex(std::size_t index) noexcept
Returns a square for an index. In essence, this is the ordinal of the square.
Definition chessboard-types.h:358

◆ colorOf()

constexpr Color hoover_chess_utils::pgn_reader::colorOf ( PieceAndColor  pc)
inlineconstexprnoexcept

Returns color of a piece.

Parameters
[in]pcPiece and color enumeration value
Returns
Color of pc

◆ colorOfPly()

constexpr Color hoover_chess_utils::pgn_reader::colorOfPly ( std::uint_fast32_t  plyNum)
inlineconstexprnoexcept

Returns side to move for a ply number.

Parameters
[in]plyNumPly number
Returns
Side to move

◆ columnOf()

constexpr RowColumn hoover_chess_utils::pgn_reader::columnOf ( Square  sq)
inlineconstexprnoexcept

Returns column number of square.

Parameters
[in]sqSquare. Range: [Square::A1, Square::H8]
Returns
Column number (0 for A-file)

◆ getIndexOfSquare()

constexpr std::size_t hoover_chess_utils::pgn_reader::getIndexOfSquare ( Square  sq)
inlineconstexprnoexcept

Returns an index for a square.

Parameters
[in]sqSquare. Range: [Square::A1, Square::H8]
Returns
Corresponding index on an array board
See also
ArrayBoard

◆ getSquareForIndex()

constexpr Square hoover_chess_utils::pgn_reader::getSquareForIndex ( std::size_t  index)
inlineconstexprnoexcept

Returns a square for an index. In essence, this is the ordinal of the square.

Parameters
[in]indexIndex on array board. Range: [0, 63]
Returns
Corresponding Square
See also
ArrayBoard

◆ isValidSquare()

constexpr bool hoover_chess_utils::pgn_reader::isValidSquare ( Square  sq)
inlineconstexprnoexcept

Checks whether a value is a square.

Parameters
[in]sqSquare
Returns
Whether sq is a named square
Remarks
Value Square::NONE is not a square.

◆ isValidValue() [1/4]

constexpr bool hoover_chess_utils::pgn_reader::isValidValue ( Color  c)
inlineconstexprnoexcept

Checks whether a value is a valid enumeration value.

Parameters
[in]cColor enumeration value
Returns
Whether is a valid value. That is, either Color::WHITE or Color::BLACK.

◆ isValidValue() [2/4]

constexpr bool hoover_chess_utils::pgn_reader::isValidValue ( Piece  p)
inlineconstexprnoexcept

Checks whether a value is a valid enumeration value.

Parameters
[in]pPiece enumeration value
Returns
Whether p is a valid value.

◆ isValidValue() [3/4]

constexpr bool hoover_chess_utils::pgn_reader::isValidValue ( PieceAndColor  pc)
inlineconstexprnoexcept

Checks whether a value is a valid enumeration value.

Parameters
[in]pcPiece and color enumeration value
Returns
Whether pc is a valid value.

◆ isValidValue() [4/4]

constexpr bool hoover_chess_utils::pgn_reader::isValidValue ( Square  sq)
inlineconstexprnoexcept

Checks whether a value is a valid enumeration value.

Parameters
[in]sqSquare
Returns
Whether sq is a valid enumeration value. That is, a square or Square::NONE.

◆ makePieceAndColor()

constexpr PieceAndColor hoover_chess_utils::pgn_reader::makePieceAndColor ( Piece  p,
Color  c 
)
inlineconstexprnoexcept

Constructs a PieceAndColor enumeration value from Piece and Color.

Parameters
[in]pValid piece enumeration value. May be Piece::NONE.
[in]cValid color enumeration value.
Returns
Constructed PieceAndColor.

◆ makePlyNum()

constexpr std::uint_fast32_t hoover_chess_utils::pgn_reader::makePlyNum ( std::uint_fast32_t  moveNum,
Color  color 
)
inlineconstexprnoexcept

Computes the ply number from full move number and side to move.

Parameters
[in]moveNumFull move number. Range: [1, 2147483648]
[in]colorSide to move
Returns
Ply number

◆ makeSquare()

constexpr Square hoover_chess_utils::pgn_reader::makeSquare ( RowColumn  col,
RowColumn  row 
)
inlineconstexprnoexcept

Constructs a square from column and row.

Parameters
[in]colColumn number (0 for A-file). Range: [0, 7]
[in]rowRow number (0 for 1st rank). Range: [0, 7]
Returns
Constructed Square

◆ moveNumOfPly()

constexpr std::uint_fast32_t hoover_chess_utils::pgn_reader::moveNumOfPly ( std::uint_fast32_t  plyNum)
inlineconstexprnoexcept

Computes the full move for a ply number.

Parameters
[in]plyNumPly number
Returns
Full move number

◆ operator<=>()

auto hoover_chess_utils::pgn_reader::operator<=> ( const CompressedPosition_FixedLength lhs,
const CompressedPosition_FixedLength rhs 
)
inlinenoexcept

Three-way comparison operator (spaceship). The comparison provides strong ordering.

Parameters
[in]lhsLeft-hand side compressed position
[in]rhsRight-hand side compressed position
Returns
Three-way comparison result
Return values
<0lhs < rhs
0lhs == rhs
>0lhs > rhs
Remarks
The exact way that the less-than relation of two compressed positions is unspecified. This is for performance reasons. Currently, the compressed positions are cast to std::array<std::uint64_t, 3U> and comparison is performed between the arrays. This minimizes the number of required comparisons. The implementation is subject to change in future releases.

◆ operator==()

bool hoover_chess_utils::pgn_reader::operator== ( const CompressedPosition_FixedLength lhs,
const CompressedPosition_FixedLength rhs 
)
inlinenoexcept

Equality comparison operator.

Parameters
[in]lhsLeft-hand side compressed position
[in]rhsRight-hand side compressed position
Returns
Comparison result (true for equality)

◆ oppositeColor()

constexpr Color hoover_chess_utils::pgn_reader::oppositeColor ( Color  c)
inlineconstexprnoexcept

Flips the color.

Parameters
[in]cColor enumeration value
Returns
Opposite color

◆ pieceOf()

constexpr Piece hoover_chess_utils::pgn_reader::pieceOf ( PieceAndColor  pc)
inlineconstexprnoexcept

Returns piece of a piece and color enumeration value.

Parameters
[in]pcPiece and color enumeration value
Returns
Piece of pc

◆ rowOf()

constexpr RowColumn hoover_chess_utils::pgn_reader::rowOf ( Square  sq)
inlineconstexprnoexcept

Returns row number of square.

Parameters
[in]sqSquare. Range: [Square::A1, Square::H8]
Returns
Row number (0 for 1st rank)

◆ toCompactType()

constexpr PieceAndColorCompact hoover_chess_utils::pgn_reader::toCompactType ( PieceAndColor  pc)
inlineconstexprnoexcept

Converts PieceAndColor (fast type) to PieceAndColorCompact (compact type).

Parameters
[in]pcFast representation
Returns
Compact representation

◆ toFastType()

constexpr PieceAndColor hoover_chess_utils::pgn_reader::toFastType ( PieceAndColorCompact  pc)
inlineconstexprnoexcept

Converts PieceAndColorCompact (compact type) to PieceAndColor (fast type).

Parameters
[in]pcCompact representation
Returns
Fast representation