Scid
4.7.0
|
Base class for non-native databases. More...
#include <codec_proxy.h>
Public Member Functions | |
errorT | open (const char *filename, fileModeT fMode) |
Opens/creates a database encoded in a non-native format. More... | |
errorT | parseNext (Game &) |
Reads the next game. More... | |
std::pair< size_t, size_t > | parseProgress () |
Returns info about the parsing progress. More... | |
const char * | parseErrors () |
Returns the list of errors produced by parseNext() calls. More... | |
errorT | gameAdd (Game *) |
Adds a game into the database. More... | |
errorT | gameSave (Game *, gamenumT) |
Replaces a game in the database. More... | |
![]() | |
Codec | getType () const override |
Returns the Codec type. More... | |
std::vector< std::string > | getFilenames () const override |
Returns the full path of the files used by the database. More... | |
std::vector< std::pair< const char *, std::string > > | getExtraInfo () const override |
Returns a vector of tag pairs containing extra information about the database (type, description, autoload, etc..) More... | |
const byte * | getGameData (uint64_t offset, uint32_t length) override |
Fetches the data of a game (excluding index info), encoded in native format. More... | |
errorT | flush () override |
Writes all pending output to the files. More... | |
std::pair< errorT, uint64_t > | dyn_addGameData (const byte *src, size_t length) |
Stores the data of a game into memory. More... | |
std::pair< errorT, idNumberT > | dyn_addName (nameT nt, const char *name) |
Given a name (string), retrieve the corresponding ID. More... | |
errorT | dyn_addIndexEntry (const IndexEntry &ie) |
Add an IndexEntry to idx_. More... | |
errorT | dyn_saveIndexEntry (const IndexEntry &ie, gamenumT replaced) |
Replace an IndexEntry. More... | |
![]() | |
errorT | addGame (const IndexEntry *srcIe, const NameBase *srcNb, const byte *srcData, size_t dataLen) override |
Add a game to the database. More... | |
errorT | addGame (Game *game) override |
Add a game to the database. More... | |
errorT | saveGame (Game *game, gamenumT replaced) override |
Replaces a game in the database. More... | |
errorT | saveIndexEntry (const IndexEntry &ie, gamenumT replaced) override |
Replaces a game's IndexEntry (which contains the header data of a game). More... | |
std::pair< errorT, idNumberT > | addName (nameT nt, const char *name) override |
Adds a name (player, event, site or round) to the database. More... | |
![]() | |
virtual | ~ICodecDatabase () |
Static Public Member Functions | |
template<typename TProgress , typename TSource , typename TDestFn > | |
static errorT | parseGames (const TProgress &progress, TSource &src, TDestFn destFn) |
![]() | |
static std::pair< ICodecDatabase *, errorT > | open (Codec codec, fileModeT fMode, const char *filename, const Progress &progress, Index *idx, NameBase *nb) |
Creates a new object and calls the virtual function dyn_open(). More... | |
Additional Inherited Members | |
![]() | |
enum | Codec { MEMORY, SCID4, PGN } |
![]() | |
CodecNative () | |
![]() | |
Index * | idx_ |
NameBase * | nb_ |
ByteBuffer | bbuf_ |
Base class for non-native databases.
Every class derived from ICodecDatabase must keep an Index object and the corresponding NameBase object fully updated in memory. This implies that the virtual function dyn_open() must load in memory the header's data of all the games; however a dependency between the codecs and the Index class is not desirable. This class provides an interface that encapsulates the codecs, requiring only the ability to exchange Game objects.
Definition at line 48 of file codec_proxy.h.
|
inline |
Adds a game into the database.
Game* | valid pointer to a Game object with the new data. |
errorT
code otherwise. Definition at line 90 of file codec_proxy.h.
|
inline |
Replaces a game in the database.
Game* | valid pointer to a Game object with the new data. |
gamenumT | valid gamenumT of the game to be replaced. |
errorT
code otherwise. Definition at line 98 of file codec_proxy.h.
errorT CodecProxy< Derived >::open | ( | const char * | filename, |
fileModeT | fMode | ||
) |
Opens/creates a database encoded in a non-native format.
filename | full path of the database to be opened. |
fMode | valid file access mode. |
errorT
code otherwise.
|
inline |
Returns the list of errors produced by parseNext() calls.
Definition at line 83 of file codec_proxy.h.
|
inlinestatic |
Definition at line 172 of file codec_proxy.h.
|
inline |
Reads the next game.
A derived class implements this function to sequentially read the games contained into the database.
Game& | the Game object where the data will be stored. |
Definition at line 69 of file codec_proxy.h.
|
inline |
Returns info about the parsing progress.
Definition at line 76 of file codec_proxy.h.