libscid 0.1.0
Chess applications made easy.
Loading...
Searching...
No Matches
scid::database::scidBaseT Struct Reference

Classes

struct  RatingUpdateStats
 
struct  Stats
 

Public Member Functions

scid::core::errorT open (std::string_view dbType, fileModeT fMode, const char *filename, const Progress &progress={})
 
void Close ()
 
std::string getFileName () const
 
bool isOpen () const
 
bool isReadOnly () const
 
gamenumT numGames () const
 
std::vector< std::pair< const char *, std::string > > getExtraInfo () const
 Returns a vector of tag pairs containing extra information about the database (type, description, autoload, etc..)
 
scid::core::errorT setExtraInfo (const char *tagname, const char *new_value)
 Store an extra information about the database (type, description, etc..)
 
const IndexEntrygetIndexEntry (gamenumT g) const
 
const IndexEntrygetIndexEntry_bounds (gamenumT g) const
 
GameInfo gameInfo (gamenumT g) const
 
std::optional< GameInfogameInfoBounds (gamenumT g) const
 
scid::core::errorT updateGameInfo (gamenumT g, const GameInfoUpdate &update)
 
TagRoster tagRoster (gamenumT gnum) const
 
TagRoster tagRoster (IndexEntry const &ie) const
 
const NameBasegetNameBase () const
 
scid::core::ratingT peakElo (idNumberT playerID) const
 Return the highest elo of the player (in the database's games)
 
scid::core::errorT loadGame (const IndexEntry &ie, scid::core::Game &dest, char *scidFlags, std::size_t scidFlagsLen) const
 
scid::core::errorT loadGame (gamenumT gNum, scid::core::Game &dest, char *scidFlags, std::size_t scidFlagsLen) const
 
scid::core::errorT loadGameMovesOnly (gamenumT gNum, scid::core::Game &dest) const
 
scid::core::errorT loadGameMovesOnly (const IndexEntry &ie, scid::core::Game &dest) const
 
scid::core::errorT gameTags (gamenumT gNum, std::vector< std::pair< std::string, std::string > > &dest) const
 
scid::core::errorT loadStandardTags (gamenumT gNum, scid::core::Game &dest, char *scidFlags, std::size_t scidFlagsLen) const
 
scid::core::errorT gameTags (const IndexEntry &ie, std::vector< std::pair< std::string, std::string > > &dest) const
 
std::vector< scid::core::FullMovemainlineMoves (gamenumT gNum, std::size_t maxPly) const
 
std::vector< scid::core::FullMovemainlineMoves (const IndexEntry *ie, std::size_t maxPly) const
 
std::string moveSAN (gamenumT gNum, int plyToSkip, int count) const
 
std::string moveSAN (const IndexEntry *ie, int plyToSkip, int count) const
 
std::pair< scid::core::errorT, size_t > replaceGameDates (HFilter filter, const Progress &progress, scid::core::dateT oldDate, scid::core::dateT newDate)
 
std::pair< scid::core::errorT, size_t > replaceGameEventDates (HFilter filter, const Progress &progress, scid::core::dateT oldDate, scid::core::dateT newDate)
 
std::pair< scid::core::errorT, size_t > setPlayerRatings (HFilter filter, const Progress &progress, idNumberT player, scid::core::ratingT rating, scid::core::ratingTypeT ratingType)
 
template<typename TRatingResolver >
std::pair< scid::core::errorT, RatingUpdateStatsupdatePlayerRatings (HFilter filter, const Progress &progress, bool overwrite, bool saveRatings, TRatingResolver ratingFor)
 
scid::core::errorT searchBoard (const IndexEntry &ie, scid::core::Game &game, scid::core::Position *pos, scid::core::Position *posFlip, bool useVariations, bool possibleMatch, bool possibleFlippedMatch, gameExactMatchT searchType, scid::core::uint &ply) const
 
scid::core::errorT searchBoard (gamenumT gNum, scid::core::Game &game, scid::core::Position *pos, scid::core::Position *posFlip, bool useVariations, bool possibleMatch, bool possibleFlippedMatch, gameExactMatchT searchType, scid::core::uint &ply) const
 
bool materialSearchMatch (const IndexEntry &ie, bool possibleMatch, bool possibleFlippedMatch, scid::core::byte *min, scid::core::byte *max, scid::core::byte *minFlipped, scid::core::byte *maxFlipped, patternT *patterns, std::size_t patternCount, patternT *flippedPatterns, std::size_t flippedPatternCount, int minPly, int maxPly, int matchLength, bool oppBishops, bool sameBishops, int minDiff, int maxDiff) const
 
bool materialSearchMatch (gamenumT gNum, bool possibleMatch, bool possibleFlippedMatch, scid::core::byte *min, scid::core::byte *max, scid::core::byte *minFlipped, scid::core::byte *maxFlipped, patternT *patterns, std::size_t patternCount, patternT *flippedPatterns, std::size_t flippedPatternCount, int minPly, int maxPly, int matchLength, bool oppBishops, bool sameBishops, int minDiff, int maxDiff) const
 
bool setPositionSearchFilter (const scid::core::Position &pos, HFilter &filter, const Progress &progress) const
 
scid::core::errorT importGames (const scidBaseT *srcBase, const HFilter &filter, const Progress &progress)
 
scid::core::errorT importGames (std::string_view dbType, const char *filename, const Progress &progress, std::string &errorMsg)
 
scid::core::errorT saveGame (scid::core::Game const &game, const char *scidFlags, gamenumT replacedGameId=INVALID_GAMEID)
 Add or replace a game into the database.
 
scid::core::errorT addGame (scid::core::Game const &game, const char *scidFlags)
 
bool getFlag (scid::core::uint flag, scid::core::uint gNum) const
 
scid::core::errorT setFlag (bool value, scid::core::uint flag, scid::core::uint gNum)
 
scid::core::errorT setFlags (bool value, scid::core::uint flag, const HFilter &filter)
 
scid::core::errorT invertFlag (scid::core::uint flag, scid::core::uint gNum)
 
scid::core::errorT invertFlags (scid::core::uint flag, const HFilter &filter)
 
std::string newFilter ()
 A Filter is a selection of games, usually obtained searching the database.
 
void deleteFilter (const char *filterId)
 
HFilter getFilter (std::string_view filterId) const
 
HFilter defaultFilter () const
 
gamenumT defaultFilterCount () const
 
scid::core::byte defaultFilterGet (gamenumT g) const
 
void defaultFilterSet (gamenumT g, scid::core::byte value)
 
void defaultFilterFill (scid::core::byte value)
 
uint64_t cacheInvalidationToken () const
 
std::string composeFilter (std::string_view mainFilter, std::string_view maskFilter) const
 A composed filter is a special construct created combining two filters and includes only the games contained in both filters.
 
std::pair< std::string, std::string > getFilterComponents (std::string_view filterId) const
 Get the components of a composed filter.
 
const StatsgetStats () const
 
std::vector< TreeNodegetTreeStat (const HFilter &filter) const
 
scid::core::uint getNameFreq (nameT nt, idNumberT id)
 
scid::core::errorT getCompactStat (unsigned long long *n_deleted, unsigned long long *n_unused, unsigned long long *n_sparse, unsigned long long *n_badNameId)
 
scid::core::errorT compact (const Progress &progress)
 
bool createSortCache (const char *criteria)
 Increment the reference count of a SortCache object matching criteria.
 
void releaseSortCache (const char *criteria)
 Decrement the reference count of the SortCache object matching criteria.
 
size_t listGames (const char *criteria, size_t start, size_t count, const HFilter &filter, gamenumT *destCont)
 Retrieve a list of ordered game indexes sorted by criteria.
 
size_t sortedPosition (const char *criteria, const HFilter &filter, gamenumT gameId)
 Get the sorted position of a game.
 
template<typename TInitFunc , typename TMapFunc >
std::pair< scid::core::errorT, size_t > transformNames (nameT nt, HFilter hfilter, const Progress &progress, const std::vector< std::string > &newNames, TInitFunc fnInit, TMapFunc getID)
 Transform the names of the games included in hfilter.
 
std::pair< scid::core::errorT, size_t > stripGames (HFilter hfilter, const Progress &progress, std::vector< std::string_view > const &removeTags)
 Strip the games included in hfilter.
 
std::unique_ptr< gamenumT[]> extractDuplicates ()
 
void setDuplicates (std::unique_ptr< gamenumT[]> duplicates)
 
gamenumT getDuplicates (gamenumT gNum) const
 

Friends

class SearchPos
 

Member Function Documentation

◆ composeFilter()

std::string scid::database::scidBaseT::composeFilter ( std::string_view  mainFilter,
std::string_view  maskFilter 
) const

A composed filter is a special construct created combining two filters and includes only the games contained in both filters.

It should NOT be deleted and became invalid if any of its components is deleted. @mainFilter: valid identifier of the main filter (the filter which is modified by non-const operations). @maskFilter: valid identifier of the mask filter (const).

Returns
the id of the composed filter.

◆ createSortCache()

bool scid::database::scidBaseT::createSortCache ( const char *  criteria)

Increment the reference count of a SortCache object matching criteria.

Parameters
criteriathe list of fields by which games will be ordered. Each field should be followed by '+' to indicate an ascending order or by '-' for a descending order.
Returns
true on success

◆ getFilterComponents()

std::pair< std::string, std::string > scid::database::scidBaseT::getFilterComponents ( std::string_view  filterId) const

Get the components of a composed filter.

@filterId: valid identifier of a filter.

Returns
the components (second is empty if its not a a composed filter).

◆ listGames()

size_t scid::database::scidBaseT::listGames ( const char *  criteria,
size_t  start,
size_t  count,
const HFilter filter,
gamenumT *  destCont 
)

Retrieve a list of ordered game indexes sorted by criteria.

This function will be much faster if a SortCache object matching criteria already exists (previously created with createSortCache).

Parameters
criteriathe list of fields by which games will be ordered. Each field should be followed by '+' to indicate an ascending order or by '-' for a descending order.
startthe offset of the first row to return. The offset of the initial row is 0.
countmaximum number of rows to return.
filtera reference to a valid (!= NULL) HFilter object. Games not included into the filter will be ignored.
[out]destContvalid pointer to an array where the sorted list of games will be stored (should be able to contain at least count elements).
Returns
the number of games' ids stored into destCont.

◆ newFilter()

std::string scid::database::scidBaseT::newFilter ( )

A Filter is a selection of games, usually obtained searching the database.

A new Filter is created calling the function newFilter() and must be released calling the function deleteFilter().

◆ releaseSortCache()

void scid::database::scidBaseT::releaseSortCache ( const char *  criteria)

Decrement the reference count of the SortCache object matching criteria.

Cached objects with refCount <= 0 are destroyed independently from the value of criteria.

Parameters
criteriathe list of fields by which games will be ordered. Each field should be followed by '+' to indicate an ascending order or by '-' for a descending order.

◆ saveGame()

scid::core::errorT scid::database::scidBaseT::saveGame ( scid::core::Game const &  game,
const char *  scidFlags,
gamenumT  replacedGameId = INVALID_GAMEID 
)

Add or replace a game into the database.

Parameters
gamecore game data to store.
scidFlagsdatabase/application Scid flags for the game.
replacedGameIdid of the game to replace. If >= numGames(), a new game will be added.
Returns
scid::core::OK if successful or an error code.

◆ sortedPosition()

size_t scid::database::scidBaseT::sortedPosition ( const char *  criteria,
const HFilter filter,
gamenumT  gameId 
)

Get the sorted position of a game.

This function will be much faster if a SortCache object matching criteria already exists (previously created with createSortCache).

Parameters
criteriathe list of fields by which games will be ordered. Each field should be followed by '+' to indicate an ascending order or by '-' for a descending order.
filtera reference to a valid (!= NULL) HFilter object. Games not included into the filter will be ignored.
gameIdthe id of the game.
Returns
the sorted position of gameId.

◆ stripGames()

std::pair< scid::core::errorT, size_t > scid::database::scidBaseT::stripGames ( HFilter  hfilter,
const Progress progress,
std::vector< std::string_view > const &  removeTags 
)

Strip the games included in hfilter.

Parameters
hfilterHFilter containing the games to be transformed.
progressa Progress object used for GUI communications.
entry_opoperator that will be applied to games.
Returns
a std::pair containing scid::core::OK (or an error code) and the number of games modified.

◆ transformNames()

template<typename TInitFunc , typename TMapFunc >
std::pair< scid::core::errorT, size_t > scid::database::scidBaseT::transformNames ( nameT  nt,
HFilter  hfilter,
const Progress progress,
const std::vector< std::string > &  newNames,
TInitFunc  fnInit,
TMapFunc  getID 
)

Transform the names of the games included in hfilter.

The function getID maps all the old idNumberT to the new idNumberT. It's invoked for each game and must accept as parameters a idNumberT and a const GameInfo&; must return the (eventually different) idNumberT.

Parameters
nttype of the names to be modified.
hfilterHFilter containing the games to be transformed.
progressa Progress object used for GUI communications.
newNamesoptional vector of names to be added to the database.
fnInitfunction that is invoked before beginning the transformation; must accept a vector that contains the idNumberTs of the names in newNames.
getIDfunction that maps the old idNumberTs to the new ones.
Returns
a std::pair containing scid::core::OK (or an error code) and the number of games modified.

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