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

#include <codec_pgn.h>

Inheritance diagram for CodecPgn:
Inheritance graph
[legend]
Collaboration diagram for CodecPgn:
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 files used by the database. More...
 
errorT flush () override
 Writes all pending output to the files. More...
 
errorT open (const char *filename, fileModeT fmode)
 Opens/creates a PGN database. More...
 
errorT parseNext (Game *g)
 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 dyn_addGame (Game *game)
 Add a game into the database. More...
 
- Public Member Functions inherited from CodecMemory
 CodecMemory ()
 
const bytegetGameData (uint32_t offset, uint32_t length) override
 Fetches the data of a game (excluding index info), encoded in native format. 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 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 Member Functions inherited from CodecProxy< CodecPgn >
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 dyn_addGame (Game *)
 Adds a game into the database. More...
 
errorT dyn_saveGame (Game *, gamenumT)
 Replaces a game in the database. More...
 
- Protected Member Functions inherited from CodecMemory
virtual std::pair< errorT, uint32_t > dyn_addGameData (const byte *src, size_t length)
 Stores the data of the game into the database. More...
 
- Protected Attributes inherited from CodecMemory
Indexidx_
 
NameBasenb_
 

Detailed Description

Definition at line 37 of file codec_pgn.h.

Member Function Documentation

errorT CodecPgn::dyn_addGame ( Game game)
inline

Add a game into the database.

The game is encoded in pgn format and appended at the end of file_.

Parameters
gamevalid pointer to a Game object with the new data.
Returns
OK in case of success, an errorT code otherwise.

Definition at line 121 of file codec_pgn.h.

errorT CodecPgn::flush ( )
inlineoverridevirtual

Writes all pending output to the files.

Returns
OK if successful or an error code.

Reimplemented from CodecMemory.

Definition at line 50 of file codec_pgn.h.

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

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.

Reimplemented from CodecMemory.

Definition at line 46 of file codec_pgn.h.

Codec CodecPgn::getType ( )
inlineoverridevirtual

Returns the Codec type.

Reimplemented from CodecMemory.

Definition at line 44 of file codec_pgn.h.

errorT CodecPgn::open ( const char *  filename,
fileModeT  fmode 
)
inline

Opens/creates a PGN database.

After successfully opening/creating the file, the PgnParser object parser_ is initialized to be ready for parseNext() calls.

Parameters
filenamefull path of the pgn file to be opened.
fModevalid file access mode.
Returns
OK in case of success, an errorT code otherwise.

Definition at line 63 of file codec_pgn.h.

const char* CodecPgn::parseErrors ( )
inline

Returns the list of errors produced by parseNext() calls.

Definition at line 110 of file codec_pgn.h.

errorT CodecPgn::parseNext ( Game g)
inline

Reads the next game.

Parameters
gvalid pointer to the Game object where the data will be stored.
Returns
  • OK on success.
  • ERROR_NotFound if there are no more games to be read.
  • ERROR code if the game cannot be read and was skipped.

Definition at line 94 of file codec_pgn.h.

std::pair<size_t, size_t> CodecPgn::parseProgress ( )
inline

Returns info about the parsing progress.

Returns
a pair<size_t, size_t> where first element is the quantity of data parsed and second one is the total amount of data of the database.

Definition at line 103 of file codec_pgn.h.


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