Scid  4.7.0
Public Member Functions | Static 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 () const final
 Returns the Codec type. More...
 
std::vector< std::string > getFilenames () const final
 Returns the full path of the files used by the database. More...
 
errorT flush () final
 Writes all pending output to the files. More...
 
errorT open (const char *filename, fileModeT fmode)
 Opens/creates a PGN database. More...
 
errorT parseNext (Game &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 *game)
 Add a game into the database. More...
 
- Public 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 gameAdd (Game *)
 Adds a game into the database. More...
 
errorT gameSave (Game *, gamenumT)
 Replaces a game in the database. More...
 
- Public Member Functions inherited from CodecMemory
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 bytegetGameData (uint64_t offset, uint32_t length) override
 Fetches the data of a game (excluding index info), encoded in native format. 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, 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 ICodecDatabase
virtual ~ICodecDatabase ()
 

Static Public Member Functions

template<typename TCont >
static size_t encode (Game &game, TCont &dest)
 Encode a game into PGN format. More...
 
template<typename TCont >
static size_t encodeTags (Game &game, TCont &dest)
 
- Static Public Member Functions inherited from CodecProxy< CodecPgn >
static errorT parseGames (const TProgress &progress, TSource &src, TDestFn destFn)
 
- 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...
 

Additional Inherited Members

- Public Types inherited from ICodecDatabase
enum  Codec { MEMORY, SCID4, PGN }
 
- Protected Member Functions inherited from CodecNative< CodecMemory >
 CodecNative ()
 
- Protected Attributes inherited from CodecNative< CodecMemory >
Indexidx_
 
NameBasenb_
 
ByteBuffer bbuf_
 

Detailed Description

Definition at line 36 of file codec_pgn.h.

Member Function Documentation

◆ encode()

template<typename TCont >
static size_t CodecPgn::encode ( Game game,
TCont &  dest 
)
inlinestatic

Encode a game into PGN format.

Parameters
gamethe Game object to encode.
destthe container where the PGN Game will be appended.
Returns
the size of the tag pairs section.

Definition at line 180 of file codec_pgn.h.

◆ encodeTags()

template<typename TCont >
static size_t CodecPgn::encodeTags ( Game game,
TCont &  dest 
)
inlinestatic

Definition at line 197 of file codec_pgn.h.

◆ flush()

errorT CodecPgn::flush ( )
inlinefinalvirtual

Writes all pending output to the files.

Returns
OK if successful or an error code.

Reimplemented from CodecMemory.

Definition at line 52 of file codec_pgn.h.

◆ gameAdd()

errorT CodecPgn::gameAdd ( 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 152 of file codec_pgn.h.

◆ getFilenames()

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

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 48 of file codec_pgn.h.

◆ getType()

Codec CodecPgn::getType ( ) const
inlinefinalvirtual

Returns the Codec type.

Reimplemented from CodecMemory.

Definition at line 46 of file codec_pgn.h.

◆ open()

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

Opens/creates a PGN database.

After successfully opening/creating the file, the object is 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 66 of file codec_pgn.h.

◆ parseErrors()

const char* CodecPgn::parseErrors ( )
inline

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

Definition at line 144 of file codec_pgn.h.

◆ parseNext()

errorT CodecPgn::parseNext ( Game game)
inline

Reads the next game.

Parameters
gamethe Game object where the data will be stored.
Returns
  • ERROR_NotFound if there are no more games to be read.
  • OK otherwise.

Definition at line 95 of file codec_pgn.h.

◆ parseProgress()

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 137 of file codec_pgn.h.


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