36 std::vector<std::string> filenames_;
38 char gamecache_[1ULL << 17];
41 LIMIT_GAMEOFFSET = 1ULL << 32,
42 LIMIT_GAMELEN = 1ULL << 17,
43 LIMIT_NUMGAMES = 16777214ULL,
55 std::vector<std::string>
getFilenames() const final {
return filenames_; };
57 std::vector<std::pair<const char*, std::string>>
59 std::vector<std::pair<const char*, std::string>> res;
60 res.emplace_back(
"type", std::to_string(
idx_->
GetType()));
63 res.emplace_back(
"flag1",
65 res.emplace_back(
"flag2",
67 res.emplace_back(
"flag3",
69 res.emplace_back(
"flag4",
71 res.emplace_back(
"flag5",
73 res.emplace_back(
"flag6",
79 if (offset >= gfile_.
size())
81 if (length >= LIMIT_GAMELEN)
86 if (gfile_.
sgetn(gamecache_, length) != std::streamsize(length))
89 return reinterpret_cast<const byte*
>(gamecache_);
111 const char*
data =
reinterpret_cast<const char*
>(src);
113 if (length >= LIMIT_GAMELEN)
117 uint64_t offset = gfile_.
size();
118 if (offset >= LIMIT_GAMEOFFSET - length)
124 uint64_t blockSpace = LIMIT_GAMELEN - (offset % LIMIT_GAMELEN);
125 if (blockSpace < length) {
128 return std::make_pair(err, 0);
129 offset += blockSpace;
133 return std::make_pair(err, offset);
152 return nb_->
addName(nt, name, LIMIT_NAMELEN, MAX_ID[nt]);
162 if (nGames >= LIMIT_NUMGAMES)
const char * GetCustomFlagDesc(byte c) const
errorT append(const char_type *s, std::streamsize count)
Writes, at the end of the file, count characters from the character array whose first element is poin...
const errorT ERROR_NumGamesLimit
errorT dyn_addIndexEntry(const IndexEntry &ie)
Add an IndexEntry to idx_.
std::pair< errorT, idNumberT > addName(nameT nt, const char *name, size_t MAX_LEN, idNumberT MAX_ID)
Add a name (string) to the NameBase.
std::streamoff pubseekpos(std::streamoff pos)
Repositions the internal buffer or invoke filebuf::seekpos().
std::pair< errorT, idNumberT > dyn_addName(nameT nt, const char *name)
Given a name (string), retrieve the corresponding ID.
Codec getType() const final
Returns the Codec type.
const errorT ERROR_OffsetLimit
gamenumT GetNumGames() const
Header getter functions.
gamenumT GetAutoLoad() const
This class manages databases encoded in SCID format v4.
std::vector< std::string > getFilenames() const final
Returns the full path of the three files (index, namebase and gamefile) used by the database...
std::pair< errorT, uint64_t > dyn_addGameData(const byte *src, size_t length)
Stores the data into the .sg4 file.
unsigned long long size() const
Returns the size of the file.
errorT flush() final
Writes all pending output to the files.
This class stores the database's names (players, events, sites and rounds).
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...
Implements CodecNative, which is used as base class by native codecs.
const errorT ERROR_GameLengthLimit
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..)
errorT WriteEntry(const IndexEntry *ie, gamenumT idx)
WriteEntry() - modify a game in the Index.
Optimizes std::filebuf for random-access reading.
const byte * getGameData(uint64_t offset, uint32_t length) final
Fetches the data of a game (excluding index info), encoded in native format.
std::streamsize sgetn(char_type *s, std::streamsize count)
Invoke filebuf::xsgetn() and update filePos_.
errorT dyn_open(fileModeT, const char *, const Progress &, Index *, NameBase *) final
Opens/Creates a database.
const char * GetDescription() const
Extends the std:filebuf class with performance improvements.