libscid 0.1.0
Chess applications made easy.
Loading...
Searching...
No Matches
scid::eco::Book Class Reference

A Book 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 <book.h>

Classes

struct  Line
 

Public Member Functions

std::string_view findEcoString (const Position &position) const
 Retrieve an ECO string containing the ECO code and the mnemonic name.
 
Code findEco (const Position &position) const
 Retrieve the ECO code of a position.
 
std::vector< LinelinesWithPrefix (std::string_view ecoPrefix) const
 
unsigned lineCount () const
 
unsigned fewestPieces () const
 
size_t size () const
 

Static Public Member Functions

static std::pair< Error, Bookload (const std::filesystem::path &path)
 Read a file with a list of ECO codes and creates a Book object.
 

Detailed Description

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

Member Function Documentation

◆ findEco()

Code scid::eco::Book::findEco ( const Position position) const

Retrieve the ECO code of a position.

Parameters
positionthe position to search for.
Returns
the corresponding ECO code or scid::eco::ECO_None if not found.

◆ findEcoString()

std::string_view scid::eco::Book::findEcoString ( const Position position) const

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

Parameters
positionthe position to search for.
Returns
an empty string_view if the position is not found

◆ load()

static std::pair< Error, Book > scid::eco::Book::load ( const std::filesystem::path &  path)
static

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

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

Parameters
paththe path of the file to be read.
Returns
  • on success, a std::pair containing scid::eco::OK and the newly created object.
  • on failure, a std::pair containing an error code and an empty object.

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