24 #ifndef CODEC_MEMORY_H 25 #define CODEC_MEMORY_H 38 LIMIT_GAMEOFFSET = 1ULL << 46,
39 LIMIT_GAMELEN = 1ULL << 18,
40 LIMIT_NUMGAMES = (1ULL << 32) - 2,
41 LIMIT_UNIQUENAMES = 1ULL << 28,
49 return std::vector<std::string>();
52 std::vector<std::pair<const char*, std::string>>
54 std::vector<std::pair<const char*, std::string>> res;
55 res.emplace_back(
"type", std::to_string(
idx_->
GetType()));
70 if (idx == 0 || nb == 0)
94 if (length >= LIMIT_GAMELEN)
97 auto offset = v_.
size();
99 if (capacity - offset < length)
101 if (offset >= LIMIT_GAMEOFFSET)
104 v_.
resize(offset + length);
106 std::copy_n(src, length, &v_[offset]);
120 return nb_->
addName(nt, name, LIMIT_NAMELEN, LIMIT_UNIQUENAMES);
130 if (nGames >= LIMIT_NUMGAMES)
Manages memory databases that do not have associated files.
const errorT ERROR_NumGamesLimit
std::pair< errorT, idNumberT > addName(nameT nt, const char *name, size_t MAX_LEN, idNumberT MAX_ID)
Add a name (string) to the NameBase.
void resize(size_t count)
const byte * getGameData(uint64_t offset, uint32_t length) override
Fetches the data of a game (excluding index info), encoded in native format.
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..)
const errorT ERROR_OffsetLimit
errorT dyn_open(fileModeT fMode, const char *, const Progress &, Index *idx, NameBase *nb) override
Opens/Creates a database.
gamenumT GetNumGames() const
Header getter functions.
This class stores the database's names (players, events, sites and rounds).
std::vector< std::string > getFilenames() const override
Returns the full path of the files used by the database.
errorT dyn_saveIndexEntry(const IndexEntry &ie, gamenumT replaced)
Replace an IndexEntry.
This class stores the pointers to the Index and NameBase objects used by a native codec...
size_t contiguous(size_t pos) const
std::pair< errorT, uint64_t > dyn_addGameData(const byte *src, size_t length)
Stores the data of a game into memory.
Implements CodecNative, which is used as base class by native codecs.
std::pair< errorT, idNumberT > dyn_addName(nameT nt, const char *name)
Given a name (string), retrieve the corresponding ID.
const errorT ERROR_GameLengthLimit
errorT WriteEntry(const IndexEntry *ie, gamenumT idx)
WriteEntry() - modify a game in the Index.
Codec getType() const override
Returns the Codec type.
errorT flush() override
Writes all pending output to the files.
errorT dyn_addIndexEntry(const IndexEntry &ie)
Add an IndexEntry to idx_.