Scid
4.7.0
|
This interface separates the logic of a database from its representation. More...
#include <codec.h>
Public Types | |
enum | Codec { MEMORY, SCID4, PGN } |
Public Member Functions | |
virtual | ~ICodecDatabase () |
virtual Codec | getType () const =0 |
Returns the Codec type. More... | |
virtual std::vector< std::string > | getFilenames () const =0 |
Returns the full path of the files used by the database. More... | |
virtual std::vector< std::pair< const char *, std::string > > | getExtraInfo () const =0 |
Returns a vector of tag pairs containing extra information about the database (type, description, autoload, etc..) More... | |
virtual const byte * | getGameData (uint64_t offset, uint32_t length)=0 |
Fetches the data of a game (excluding index info), encoded in native format. More... | |
virtual errorT | addGame (const IndexEntry *srcIe, const NameBase *srcNb, const byte *srcData, size_t dataLen)=0 |
Add a game to the database. More... | |
virtual errorT | addGame (Game *game)=0 |
Add a game to the database. More... | |
virtual errorT | saveGame (Game *game, gamenumT replaced)=0 |
Replaces a game in the database. More... | |
virtual errorT | saveIndexEntry (const IndexEntry &ie, gamenumT replaced)=0 |
Replaces a game's IndexEntry (which contains the header data of a game). More... | |
virtual std::pair< errorT, idNumberT > | addName (nameT nt, const char *name)=0 |
Adds a name (player, event, site or round) to the database. More... | |
virtual errorT | flush ()=0 |
Writes all pending output to the files. More... | |
Static Public Member Functions | |
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... | |
This interface separates the logic of a database from its representation.
Ideally all the file I/O should be encapsulated in classes derived from this interface.
|
pure virtual |
Add a game to the database.
srcIe | valid pointer to the header data. |
srcNb | valid pointer to the NameBase containing srcIe's names. |
srcData | valid pointer to a buffer containing the game data (encoded in native format). |
dataLen | length of the game data (in bytes). |
Implemented in CodecNative< Derived >, CodecNative< CodecMemory >, and CodecNative< CodecSCID4 >.
Add a game to the database.
game | valid pointer to a Game object with the data of the game. |
Implemented in CodecNative< Derived >, CodecNative< CodecMemory >, and CodecNative< CodecSCID4 >.
|
pure virtual |
Adds a name (player, event, site or round) to the database.
nt | nameT type of the name to add. |
name | the name to add. |
Implemented in CodecNative< Derived >, CodecNative< CodecMemory >, and CodecNative< CodecSCID4 >.
|
pure virtual |
Writes all pending output to the files.
Implemented in CodecSCID4, CodecMemory, and CodecPgn.
|
pure virtual |
Returns a vector of tag pairs containing extra information about the database (type, description, autoload, etc..)
Implemented in CodecSCID4, and CodecMemory.
|
pure virtual |
Returns the full path of the files used by the database.
The order of the filenames must be consistent for objects of the same Codec type.
Implemented in CodecSCID4, CodecMemory, and CodecPgn.
|
pure virtual |
Fetches the data of a game (excluding index info), encoded in native format.
offset | offset of the requested game. |
length | length of the game data (in bytes). |
Implemented in CodecSCID4, and CodecMemory.
|
pure virtual |
Returns the Codec type.
Implemented in CodecSCID4, CodecMemory, and CodecPgn.
|
static |
Creates a new object and calls the virtual function dyn_open().
codec | the type of the object to be created. |
fMode | a valid file mode. |
filename | the full path of the database to be opened. |
progress | a Progress object used for GUI communications. |
idx | valid pointer to the Index object for this database. |
nb | valid pointer to the NameBase object for this database. |
Definition at line 30 of file scidbase.cpp.
Replaces a game in the database.
game | valid pointer to a Game object with the new data. |
replaced | valid gamenumT of the game to be replaced |
Implemented in CodecNative< Derived >, CodecNative< CodecMemory >, and CodecNative< CodecSCID4 >.
|
pure virtual |
Replaces a game's IndexEntry (which contains the header data of a game).
ie | reference to the IndexEntry with the new data. |
replaced | valid gamenumT of the game to be replaced |
Implemented in CodecNative< Derived >, CodecNative< CodecMemory >, and CodecNative< CodecSCID4 >.