Scid  4.6.5
Public Member Functions | Protected Member Functions | List of all members
CodecScid4 Class Reference

This class manages databases encoded in Scid format v4. More...

#include <codec_scid4.h>

Inheritance diagram for CodecScid4:
Inheritance graph
[legend]
Collaboration diagram for CodecScid4:
Collaboration graph
[legend]

Public Member Functions

Codec getType () override
 Returns the Codec type. More...
 
std::vector< std::string > getFilenames () override
 Returns the full path of the three files (index, namebase and gamefile) used by the database. More...
 
const bytegetGameData (uint32_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...
 
- Public Member Functions inherited from CodecMemory
 CodecMemory ()
 
errorT addGame (IndexEntry *ie, const byte *src, size_t length) override
 Add a game to the database. More...
 
errorT saveGame (IndexEntry *ie, const byte *src, size_t length, gamenumT replaced) override
 Replaces a game in 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...
 
- Public Member Functions inherited from ICodecDatabase
virtual ~ICodecDatabase ()
 

Protected Member Functions

errorT dyn_open (fileModeT fMode, const char *filename, const Progress &progress, Index *idx, NameBase *nb) override
 Opens/Creates a database. More...
 
std::pair< errorT, uint32_t > dyn_addGameData (const byte *src, size_t length) override
 Stores the data of the game into the database. More...
 

Additional Inherited Members

- Public Types inherited from ICodecDatabase
enum  Codec { MEMORY, SCID4, PGN }
 
- Static Public Member Functions inherited from ICodecDatabase
static ICodecDatabasemake (Codec codec, errorT *err, fileModeT fMode, const char *filename, const Progress &progress, Index *idx, NameBase *nb)
 Creates a new object and calls the virtual function dyn_open(). More...
 
- Protected Attributes inherited from CodecMemory
Indexidx_
 
NameBasenb_
 

Detailed Description

This class manages databases encoded in Scid format v4.

Definition at line 39 of file codec_scid4.h.

Member Function Documentation

std::pair<errorT, uint32_t> CodecScid4::dyn_addGameData ( const byte src,
size_t  length 
)
inlineoverrideprotectedvirtual

Stores the data of the game into the database.

A derived class can override this function to store the data into a different container or file. In that case it must also override the virtual function getGameData().

Parameters
srcvalid pointer to a buffer that contains the game data (encoded in native format).
lengththe length of the buffer src (in bytes).
Returns
  • on success, a std::pair containing OK and the offset of the stored data (usable to retrieve the data with getGameData()).
  • on failure, a std::pair containing an error code and 0.

Reimplemented from CodecMemory.

Definition at line 118 of file codec_scid4.h.

errorT CodecScid4::dyn_open ( fileModeT  fMode,
const char *  filename,
const Progress progress,
Index idx,
NameBase nb 
)
inlineoverrideprotectedvirtual

Opens/Creates a database.

This virtual function is called only once immediately after the class constructor.

Parameters
fModea valid file mode.
filenamethe full path of the database to open.
progressa Progress object used for GUI communications.
idxvalid pointer to the Index object for this database.
nbvalid pointer to the NameBase object for this database.
Returns
  • OK: the object is ready to be used.
  • ERROR_NameDataLoss: some names are corrupted and cannot be recovered, however the object can still be used.
  • Other error codes: the operation failed (the object must be destroyed).

Reimplemented from CodecMemory.

Definition at line 92 of file codec_scid4.h.

errorT CodecScid4::flush ( )
inlineoverridevirtual

Writes all pending output to the files.

Returns
OK if successful or an error code.

Reimplemented from CodecMemory.

Definition at line 73 of file codec_scid4.h.

std::vector<std::string> CodecScid4::getFilenames ( )
inlineoverridevirtual

Returns the full path of the three files (index, namebase and gamefile) used by the database.

Reimplemented from CodecMemory.

Definition at line 51 of file codec_scid4.h.

const byte* CodecScid4::getGameData ( uint32_t  offset,
uint32_t  length 
)
inlineoverridevirtual

Fetches the data of a game (excluding index info), encoded in native format.

Parameters
offsetoffset of the requested game.
lengthlength of the game data (in bytes).
Returns
  • a pointer to the game data.
  • 0 (nullptr) on error.

Reimplemented from CodecMemory.

Definition at line 59 of file codec_scid4.h.

Codec CodecScid4::getType ( )
inlineoverridevirtual

Returns the Codec type.

Reimplemented from CodecMemory.

Definition at line 45 of file codec_scid4.h.


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