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

#include <index.h>

Public Member Functions

 Index ()
 
 Index (const Index &)
 
Indexoperator= (const Index &)
 
 ~Index ()
 
errorT Open (const char *filename, fileModeT fmode)
 
errorT ReadEntireFile (NameBase *nb, const Progress &progress)
 
errorT Create (const char *filename)
 
errorT Close ()
 
const IndexEntryGetEntry (gamenumT g) const
 
int GetBadNameIdCount () const
 GetBadNameIdCount() - return the number of invalid name handles. More...
 
void calcNameFreq (const NameBase &nb, std::vector< int >(&resVec)[NUM_NAME_TYPES]) const
 calcNameFreq() - calculate the usage of NameBase's names : the NameBase linked to this Index : an array of std::vectors where the stats will be stored. More...
 
gamenumT GetNumGames () const
 Header getter functions. More...
 
uint GetType () const
 
versionT GetVersion () const
 
const char * GetDescription () const
 
const char * GetCustomFlagDesc (byte c) const
 
gamenumT GetAutoLoad () const
 
errorT copyHeaderInfo (const Index &src)
 Header setter functions. More...
 
errorT SetType (uint t)
 
errorT SetDescription (const char *str)
 
errorT SetCustomFlagDesc (byte c, const char *str)
 
errorT SetAutoLoad (gamenumT gnum)
 
IndexEntryFetchEntry (gamenumT g)
 FetchEntry() - return a modifiable pointer to a game's IndexEntry. More...
 
errorT WriteEntry (const IndexEntry *ie, gamenumT idx, bool flush=true)
 WriteEntry() - modify a game in the Index. More...
 
errorT AddGame (const IndexEntry *ie)
 AddGame() - add a game to the Index : valid pointer to the IndexEntry object with data for the new game. More...
 
errorT flush ()
 flush() - writes all cached data to the file More...
 

Detailed Description

Definition at line 61 of file index.h.

Constructor & Destructor Documentation

Index::Index ( )
inline

Definition at line 88 of file index.h.

Index::Index ( const Index )
Index::~Index ( )
inline

Definition at line 91 of file index.h.

Member Function Documentation

errorT Index::AddGame ( const IndexEntry ie)
inline

AddGame() - add a game to the Index : valid pointer to the IndexEntry object with data for the new game.

For performance reasons this function can cache the changes and they are automatically written to file when the object is destroyed or closed. However, for maximum security against power loss, crash, etc, it is recommended to call the function flush() after using this function.

Definition at line 232 of file index.h.

void Index::calcNameFreq ( const NameBase nb,
std::vector< int >(&)  resVec[NUM_NAME_TYPES] 
) const
inline

calcNameFreq() - calculate the usage of NameBase's names : the NameBase linked to this Index : an array of std::vectors where the stats will be stored.

This functions counts how many times every names contained in is used and store the result into a corresponding record in

Definition at line 122 of file index.h.

errorT Index::Close ( )
inline

Definition at line 96 of file index.h.

errorT Index::copyHeaderInfo ( const Index src)
inline

Header setter functions.

Definition at line 156 of file index.h.

errorT Index::Create ( const char *  filename)

Definition at line 55 of file index.cpp.

IndexEntry* Index::FetchEntry ( gamenumT  g)
inline

FetchEntry() - return a modifiable pointer to a game's IndexEntry.

The pointer returned by this function allow to modify the IndexEntry informations of a game. If modified, the IndexEntry object must be passed to WriteEntry() to write the changes to the disks. This functions is very error prone. For example: IndexEntry* ie = FetchEntry(0); ie->SetWhiteName(nb, "New player with white"); oops(); // the function oops() may call GetEntry(0) and get a messy object. ie->SetBlackName(nb, "New player with black");

A safer alternative is to create a temporary copy of the IndexEntry object returned by GetEntry() and then write all the changes in a single step

Definition at line 209 of file index.h.

errorT Index::flush ( )
inline

flush() - writes all cached data to the file

Definition at line 239 of file index.h.

gamenumT Index::GetAutoLoad ( ) const
inline

Definition at line 149 of file index.h.

int Index::GetBadNameIdCount ( ) const
inline

GetBadNameIdCount() - return the number of invalid name handles.

To save space, avoiding duplicates, the index keep handles to strings stored in the namebase file. If one of the two files is corrupted, the index may have handles to strings that do not exists. This functions returns the number of invalid name handles.

Definition at line 112 of file index.h.

const char* Index::GetCustomFlagDesc ( byte  c) const
inline

Definition at line 145 of file index.h.

const char* Index::GetDescription ( ) const
inline

Definition at line 144 of file index.h.

const IndexEntry* Index::GetEntry ( gamenumT  g) const
inline

Definition at line 98 of file index.h.

gamenumT Index::GetNumGames ( ) const
inline

Header getter functions.

Definition at line 141 of file index.h.

uint Index::GetType ( ) const
inline

Definition at line 142 of file index.h.

versionT Index::GetVersion ( ) const
inline

Definition at line 143 of file index.h.

errorT Index::Open ( const char *  filename,
fileModeT  fmode 
)

Definition at line 79 of file index.cpp.

Index& Index::operator= ( const Index )
errorT Index::ReadEntireFile ( NameBase nb,
const Progress progress 
)

Definition at line 137 of file index.cpp.

errorT Index::SetAutoLoad ( gamenumT  gnum)
inline

Definition at line 187 of file index.h.

errorT Index::SetCustomFlagDesc ( byte  c,
const char *  str 
)
inline

Definition at line 178 of file index.h.

errorT Index::SetDescription ( const char *  str)
inline

Definition at line 171 of file index.h.

errorT Index::SetType ( uint  t)
inline

Definition at line 165 of file index.h.

errorT Index::WriteEntry ( const IndexEntry ie,
gamenumT  idx,
bool  flush = true 
)
inline

WriteEntry() - modify a game in the Index.

Definition at line 217 of file index.h.

Member Data Documentation

gamenumT Index::autoLoad

Definition at line 79 of file index.h.

uint Index::baseType

Definition at line 77 of file index.h.

char Index::customFlagDesc[CUSTOM_FLAG_MAX][CUSTOM_FLAG_DESC_LENGTH+1]

Definition at line 83 of file index.h.

char Index::description[SCID_DESC_LENGTH+1]

Definition at line 81 of file index.h.

bool Index::dirty_

Definition at line 84 of file index.h.

char Index::magic[9]

Definition at line 75 of file index.h.

gamenumT Index::numGames

Definition at line 78 of file index.h.

versionT Index::version

Definition at line 76 of file index.h.


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