libscid snapshot+e944e108ed8b
Chess applications made easy.
Source on GitHub License GPL v2
Loading...
Searching...
No Matches
scid::eco Namespace Reference

ECO code values and opening-position classification. More...

Classes

class  Book
 Exact-position ECO classifier loaded from a Scid ECO file. More...
 

Typedefs

using Error = scid::core::errorT
 Error code type used by the ECO loader.
 
using Position = scid::core::Position
 Position type classified by an ECO book.
 
using Code = std::uint16_t
 Packed ECO classification code.
 
using String = char[6]
 Fixed-size buffer large enough for any NUL-terminated ECO string.
 

Functions

void toString (Code ecoCode, char *ecoStr, bool extensions=true)
 Writes ecoCode to ecoStr.
 
void toBasicString (Code ecoCode, char *ecoStr)
 Writes only the basic three-character ECO code.
 
void toExtendedString (Code ecoCode, char *ecoStr)
 Writes the full Scid ECO string, including optional subcodes.
 
Code fromString (const char *ecoStr)
 Parses an ECO string into a compact code.
 
Code lastSubCode (Code ecoCode)
 Returns the last concrete code covered by ecoCode.
 
Code basicCode (Code ecoCode)
 Removes Scid's extended subcode from ecoCode.
 
Code reduce (Code ecoCode)
 Maps ecoCode to the dense ECO-statistics bucket used by database code.
 

Variables

constexpr Error OK = scid::core::OK
 
constexpr Error ERROR_FileOpen = scid::core::ERROR_FileOpen
 
constexpr Error ERROR_Corrupt = scid::core::ERROR_Corrupt
 
constexpr Code ECO_None = 0
 Sentinel value used when no ECO classification is known.
 

Detailed Description

ECO code values and opening-position classification.

ECO is the opening-classification layer. It maps ECO text such as B20 or C50a1 to compact numeric values, loads Scid ECO text files, and classifies exact scid::core::Position values.

Database records can carry compact ECO classifications for browsing, sorting, searching and statistics, while this namespace supplies the public code vocabulary and the position classifier that can produce those classifications.

Typedef Documentation

◆ Code

using scid::eco::Code = typedef std::uint16_t

Packed ECO classification code.

ECO strings have a public textual form such as "B20" or "C50a1". This type is the compact numeric representation used for storage, sorting, and range calculations. ECO_None is reserved for "no ECO code".

◆ String

using scid::eco::String = typedef char[6]

Fixed-size buffer large enough for any NUL-terminated ECO string.

The longest emitted form is five visible characters, for example "E99z4", plus the terminating NUL byte.

Function Documentation

◆ basicCode()

Code scid::eco::basicCode ( Code  ecoCode)

Removes Scid's extended subcode from ecoCode.

ECO_None returns ECO_None.

◆ fromString()

Code scid::eco::fromString ( const char *  ecoStr)

Parses an ECO string into a compact code.

Canonical ECO text starts with A through E, case-insensitively, followed by two digits, an optional lower-case subcode a through z, and an optional numeric extension 1 through 4. Prefixes such as "B" and "B2" are accepted and map to the first code in that range. Invalid leading text returns ECO_None.

◆ lastSubCode()

Code scid::eco::lastSubCode ( Code  ecoCode)

Returns the last concrete code covered by ecoCode.

Basic codes expand to their final extended subcode. Letter-only extended codes such as "B91a" expand through their 1..4 numeric extensions. ECO_None returns ECO_None.

◆ reduce()

Code scid::eco::reduce ( Code  ecoCode)

Maps ecoCode to the dense ECO-statistics bucket used by database code.

Each basic ECO code has one bucket for the basic line plus one bucket for each lower-case subcode. Numeric extensions 1..4 fold into the same bucket as their parent subcode. Use this for aggregate statistics, not for display or round-tripping. ecoCode must not be ECO_None.

◆ toBasicString()

void scid::eco::toBasicString ( Code  ecoCode,
char *  ecoStr 
)
inline

Writes only the basic three-character ECO code.

This is a convenience wrapper around toString() for callers that want "B20" rather than Scid's extended forms such as "B20a3".

◆ toString()

void scid::eco::toString ( Code  ecoCode,
char *  ecoStr,
bool  extensions = true 
)

Writes ecoCode to ecoStr.

When extensions is false, only the basic three-character ECO code is emitted. When true, Scid's optional lower-case subcode and numeric extension are included. ecoStr must have room for at least String. ECO_None writes an empty string.