Scid  4.7.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Friends | 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 Create (const char *filename)
 
errorT Close ()
 
const IndexEntryGetEntry (gamenumT g) const
 
int GetBadNameIdCount () const
 GetBadNameIdCount() - return the number of invalid name handles. More...
 
std::array< std::vector< int >, NUM_NAME_TYPEScalcNameFreq (const NameBase &nb) const
 Counts how many times every names contained in nb is used. 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)
 WriteEntry() - modify a game in the Index. More...
 
errorT flush ()
 flush() - writes all cached data to the file More...
 

Friends

class CodecSCID4
 

Detailed Description

Definition at line 58 of file index.h.

Constructor & Destructor Documentation

◆ Index() [1/2]

Index::Index ( )
inline

Definition at line 86 of file index.h.

◆ Index() [2/2]

Index::Index ( const Index )

◆ ~Index()

Index::~Index ( )
inline

Definition at line 89 of file index.h.

Member Function Documentation

◆ calcNameFreq()

std::array<std::vector<int>, NUM_NAME_TYPES> Index::calcNameFreq ( const NameBase nb) const
inline

Counts how many times every names contained in nb is used.

Parameters
nbthe NameBase linked to this Index
Returns
an array of std::vectors containing the count of each name.

Definition at line 117 of file index.h.

◆ Close()

errorT Index::Close ( )
inline

Definition at line 93 of file index.h.

◆ copyHeaderInfo()

errorT Index::copyHeaderInfo ( const Index src)
inline

Header setter functions.

Definition at line 151 of file index.h.

◆ Create()

errorT Index::Create ( const char *  filename)

Definition at line 56 of file index.cpp.

◆ FetchEntry()

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 204 of file index.h.

◆ flush()

errorT Index::flush ( )
inline

flush() - writes all cached data to the file

Definition at line 217 of file index.h.

◆ GetAutoLoad()

gamenumT Index::GetAutoLoad ( ) const
inline

Definition at line 144 of file index.h.

◆ GetBadNameIdCount()

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 109 of file index.h.

◆ GetCustomFlagDesc()

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

Definition at line 140 of file index.h.

◆ GetDescription()

const char* Index::GetDescription ( ) const
inline

Definition at line 139 of file index.h.

◆ GetEntry()

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

Definition at line 95 of file index.h.

◆ GetNumGames()

gamenumT Index::GetNumGames ( ) const
inline

Header getter functions.

Definition at line 136 of file index.h.

◆ GetType()

uint Index::GetType ( ) const
inline

Definition at line 137 of file index.h.

◆ GetVersion()

versionT Index::GetVersion ( ) const
inline

Definition at line 138 of file index.h.

◆ Open()

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

Definition at line 80 of file index.cpp.

◆ operator=()

Index& Index::operator= ( const Index )

◆ SetAutoLoad()

errorT Index::SetAutoLoad ( gamenumT  gnum)
inline

Definition at line 182 of file index.h.

◆ SetCustomFlagDesc()

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

Definition at line 173 of file index.h.

◆ SetDescription()

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

Definition at line 166 of file index.h.

◆ SetType()

errorT Index::SetType ( uint  t)
inline

Definition at line 160 of file index.h.

◆ WriteEntry()

errorT Index::WriteEntry ( const IndexEntry ie,
gamenumT  idx 
)

WriteEntry() - modify a game in the Index.

Definition at line 160 of file index.cpp.

Friends And Related Function Documentation

◆ CodecSCID4

friend class CodecSCID4
friend

Definition at line 83 of file index.h.

Member Data Documentation

◆ autoLoad

gamenumT Index::autoLoad

Definition at line 75 of file index.h.

◆ baseType

uint Index::baseType

Definition at line 73 of file index.h.

◆ customFlagDesc

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

Definition at line 79 of file index.h.

◆ description

char Index::description[SCID_DESC_LENGTH+1]

Definition at line 77 of file index.h.

◆ dirty_

bool Index::dirty_

Definition at line 80 of file index.h.

◆ numGames

gamenumT Index::numGames

Definition at line 74 of file index.h.

◆ version

versionT Index::version

Definition at line 72 of file index.h.


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