Scid  4.7.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Classes | Public Member Functions | Static Public Member Functions | List of all members
PBook Class Reference

A PBook is a collection of chess positions, each with the corresponding ECO code, a mnemonic name, and the list of moves to reach the position. More...

#include <pbook.h>

Public Member Functions

std::pair< const char *, const char * > findECOstr (Position *pos) const
 Retrieve an ECO string containing the ECO code and the mnemonic name. More...
 
ecoT findECO (Position *pos) const
 Retrieve the ECO code of a position. More...
 
std::string EcoSummary (const char *ecoPrefix) const
 
unsigned GetLineNumber () const
 
unsigned FewestPieces () const
 
size_t Size () const
 

Static Public Member Functions

static std::pair< errorT, std::unique_ptr< PBook > > ReadEcoFile (const char *FileName)
 Read a file with a list of ECO codes and creates a PBook object. More...
 

Detailed Description

A PBook is a collection of chess positions, each with the corresponding ECO code, a mnemonic name, and the list of moves to reach the position.

Definition at line 37 of file pbook.h.

Member Function Documentation

◆ EcoSummary()

std::string PBook::EcoSummary ( const char *  ecoPrefix) const

Definition at line 107 of file pbook.cpp.

◆ FewestPieces()

unsigned PBook::FewestPieces ( ) const
inline

Definition at line 94 of file pbook.h.

◆ findECO()

ecoT PBook::findECO ( Position pos) const
inline

Retrieve the ECO code of a position.

Parameters
posthe position to search for.
Returns
the corresponding ECO code or ECO_None if not found.

Definition at line 79 of file pbook.h.

◆ findECOstr()

std::pair< const char *, const char * > PBook::findECOstr ( Position pos) const

Retrieve an ECO string containing the ECO code and the mnemonic name.

Parameters
posthe position to search for.
Returns
  • if the position is found, a std::pair with the range iterators for the string (string_view).
  • a std::pair containing nullptr otherwise.

Definition at line 78 of file pbook.cpp.

◆ GetLineNumber()

unsigned PBook::GetLineNumber ( ) const
inline

Definition at line 93 of file pbook.h.

◆ ReadEcoFile()

std::pair< errorT, std::unique_ptr< PBook > > PBook::ReadEcoFile ( const char *  FileName)
static

Read a file with a list of ECO codes and creates a PBook object.

The file is composed of lines like this: C50a "Italian Game" 1.e4 e5 2.Nf3 Nc6 3.Bc4 *

Parameters
FileNamethe name of the file to be read.
Returns
  • on success, a std::pair containing OK and the pointer to the newly created object.
  • on failure, a std::pair containing an error code and nullptr.

Definition at line 135 of file pbook.cpp.

◆ Size()

size_t PBook::Size ( ) const
inline

Definition at line 95 of file pbook.h.


The documentation for this class was generated from the following files: