Scid  4.7.0
Public 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 () const final
 Returns the Codec type. More...
 
std::vector< std::string > getFilenames () const final
 Returns the full path of the three files (index, namebase and gamefile) used by the database. More...
 
std::vector< std::pair< const char *, std::string > > getExtraInfo () const final
 Returns a vector of tag pairs containing extra information about the database (type, description, autoload, etc..) More...
 
const bytegetGameData (uint64_t offset, uint32_t length) final
 Fetches the data of a game (excluding index info), encoded in native format. More...
 
errorT flush () final
 Writes all pending output to the files. More...
 
errorT dyn_open (fileModeT, const char *, const Progress &, Index *, NameBase *) final
 Opens/Creates a database. More...
 
std::pair< errorT, uint64_t > dyn_addGameData (const byte *src, size_t length)
 Stores the data into the .sg4 file. More...
 
std::pair< errorT, idNumberTdyn_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...
 
- Public Member Functions inherited from CodecNative< CodecSCID4 >
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, idNumberTaddName (nameT nt, const char *name) override
 Adds a name (player, event, site or round) to the database. More...
 
- Public Member Functions inherited from ICodecDatabase
virtual ~ICodecDatabase ()
 

Additional Inherited Members

- Public Types inherited from ICodecDatabase
enum  Codec { MEMORY, SCID4, PGN }
 
- Static Public Member Functions inherited from ICodecDatabase
static std::pair< ICodecDatabase *, errorTopen (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...
 
- Protected Member Functions inherited from CodecNative< CodecSCID4 >
 CodecNative ()
 
- Protected Attributes inherited from CodecNative< CodecSCID4 >
Indexidx_
 
NameBasenb_
 
ByteBuffer bbuf_
 

Detailed Description

This class manages databases encoded in SCID format v4.

Definition at line 35 of file codec_scid4.h.

Member Function Documentation

◆ dyn_addGameData()

std::pair<errorT, uint64_t> CodecSCID4::dyn_addGameData ( const byte src,
size_t  length 
)
inline

Stores the data into the .sg4 file.

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 (needed for retrieving the data with getGameData()).
  • on failure, a std::pair containing an error code and 0.

Definition at line 108 of file codec_scid4.h.

◆ dyn_addIndexEntry()

errorT CodecSCID4::dyn_addIndexEntry ( const IndexEntry ie)
inline

Add an IndexEntry to idx_.

Parameters
iethe IndexEntry object to add.
Returns
OK if successful or an error code.

Definition at line 160 of file codec_scid4.h.

◆ dyn_addName()

std::pair<errorT, idNumberT> CodecSCID4::dyn_addName ( nameT  nt,
const char *  name 
)
inline

Given a name (string), retrieve the corresponding ID.

The name is added to nb_ if do not already exists in the NameBase.

Parameters
ntnameT type of the name to retrieve.
namethe name to retrieve.
Returns
  • on success, a std::pair containing OK and the ID.
  • on failure, a std::pair containing an error code and 0.

Definition at line 145 of file codec_scid4.h.

◆ dyn_open()

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

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).

Implements ICodecDatabase.

Definition at line 361 of file codec_scid4.cpp.

◆ dyn_saveIndexEntry()

errorT CodecSCID4::dyn_saveIndexEntry ( const IndexEntry ie,
gamenumT  replaced 
)
inline

Replace an IndexEntry.

Parameters
iethe IndexEntry with the new data.
replacedvalid gamenumT of the game to be replaced.
Returns
OK if successful or an error code.

Definition at line 174 of file codec_scid4.h.

◆ flush()

errorT CodecSCID4::flush ( )
finalvirtual

Writes all pending output to the files.

Returns
OK if successful or an error code.

Implements ICodecDatabase.

Definition at line 397 of file codec_scid4.cpp.

◆ getExtraInfo()

std::vector<std::pair<const char*, std::string> > CodecSCID4::getExtraInfo ( ) const
inlinefinalvirtual

Returns a vector of tag pairs containing extra information about the database (type, description, autoload, etc..)

Implements ICodecDatabase.

Definition at line 58 of file codec_scid4.h.

◆ getFilenames()

std::vector<std::string> CodecSCID4::getFilenames ( ) const
inlinefinalvirtual

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

Implements ICodecDatabase.

Definition at line 55 of file codec_scid4.h.

◆ getGameData()

const byte* CodecSCID4::getGameData ( uint64_t  offset,
uint32_t  length 
)
inlinefinalvirtual

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.

Implements ICodecDatabase.

Definition at line 78 of file codec_scid4.h.

◆ getType()

Codec CodecSCID4::getType ( ) const
inlinefinalvirtual

Returns the Codec type.

Implements ICodecDatabase.

Definition at line 49 of file codec_scid4.h.


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