This class stores the database's names (players, events, sites and rounds).
More...
#include <namebase.h>
|
|
idNumberT | namebase_add (nameT nt, std::string_view name, std::map< const char *, idNumberT, idxCmp >::iterator *hint=nullptr) |
| |
|
idNumberT | namebase_find_or_add (nameT nt, const char *name) |
| |
|
size_t | namebase_size (nameT nt) const |
| |
| bool | insert (const char *name, size_t nameLen, nameT nt, idNumberT id) |
| | DEPRECATED Add a name (string) and its associated id to the NameBase.
|
| |
|
void | Clear () |
| | Frees memory, leaving the object empty.
|
| |
| std::vector< idNumberT > | getFirstMatches (nameT nt, const char *str, size_t maxMatches) const |
| | Get the first few matches of a name prefix.
|
| |
| const char * | GetName (nameT nt, idNumberT id) const |
| | Retrieve a name.
|
| |
| const decltype(idx_) & | getNames () const |
| |
| idNumberT | GetNumNames (nameT nt) const |
| |
| scid::core::errorT | FindExactName (nameT nt, const char *str, idNumberT *idPtr) const |
| | Finds an exact full, case-sensitive name.
|
| |
| std::vector< uint32_t > | generateHashMap (nameT nt) const |
| | For every name generates a 32bit hash with the first 4 chars.
|
| |
| std::array< std::vector< int >, NUM_NAME_TYPES > | calcNameFreq (Index const &idx) const |
| | Counts how many times each name is used.
|
| |
|
size_t | count_invalid_ids (Index const &idx) const |
| | Counts how many invalid IDs (references to names that do not exist in this NameBase) are present in idx.
|
| |
This class stores the database's names (players, events, sites and rounds).
Assigns a idNumberT (which will be used as reference) to each name.
◆ calcNameFreq()
| std::array< std::vector< int >, NUM_NAME_TYPES > scid::database::NameBase::calcNameFreq |
( |
Index const & |
idx | ) |
const |
|
inline |
Counts how many times each name is used.
- Returns
- an array of std::vectors containing the count of each name.
◆ FindExactName()
| scid::core::errorT scid::database::NameBase::FindExactName |
( |
nameT |
nt, |
|
|
const char * |
str, |
|
|
idNumberT * |
idPtr |
|
) |
| const |
|
inline |
Finds an exact full, case-sensitive name.
- Parameters
-
| nt | nameT type of the name to be searched. |
| str | name to be be searched. |
| [out] | idPtr | pointer which will receive the ID of the name. |
- Returns
- scid::core::OK or scid::core::ERROR_NameNotFound if the name does not exists.
◆ generateHashMap()
| std::vector< uint32_t > scid::database::NameBase::generateHashMap |
( |
nameT |
nt | ) |
const |
|
inline |
For every name generates a 32bit hash with the first 4 chars.
- Parameters
-
| nt | nameT type of the names. |
- Returns
- a vector containing the hashes.
◆ getFirstMatches()
| std::vector< idNumberT > scid::database::NameBase::getFirstMatches |
( |
nameT |
nt, |
|
|
const char * |
str, |
|
|
size_t |
maxMatches |
|
) |
| const |
|
inline |
Get the first few matches of a name prefix.
- Parameters
-
| nt | nameT type of the name to be searched. |
| str | name prefix be searched. |
| maxMatches | the max number of ID to return |
- Returns
- a vector containing the ID of the matching names.
◆ GetName()
| const char * scid::database::NameBase::GetName |
( |
nameT |
nt, |
|
|
idNumberT |
id |
|
) |
| const |
|
inline |
Retrieve a name.
- Parameters
-
| nt | the valid nameT type of the name to retrieve. |
| id | the valid ID of the name to retrieve. |
- Returns
- the name corresponding to id.
◆ getNames()
| const decltype(idx_) & scid::database::NameBase::getNames |
( |
| ) |
const |
|
inline |
- Returns
- a reference to a container with all the names and IDs (given as std::pair<const char*, idNumberT>).
◆ GetNumNames()
| idNumberT scid::database::NameBase::GetNumNames |
( |
nameT |
nt | ) |
const |
|
inline |
- Parameters
-
- Returns
- the first invalid idNumberT (which is equal to the number of names stored).
◆ insert()
| bool scid::database::NameBase::insert |
( |
const char * |
name, |
|
|
size_t |
nameLen, |
|
|
nameT |
nt, |
|
|
idNumberT |
id |
|
) |
| |
|
inline |
DEPRECATED Add a name (string) and its associated id to the NameBase.
Return false if the name or the id already exists: the NameBase object is then no longer valid and should be destroyed. The caller should also ensure that before invoking any other object's function none of names_[nt] == nullptr.
◆ IsValidNameType()
| static bool scid::database::NameBase::IsValidNameType |
( |
nameT |
nt | ) |
|
|
inlinestatic |
Validate a nameT type.
- Parameters
-
| nt | nameT type to be validated. |
- Returns
- true if nt is valid.
◆ NameTypeFromString()
| static nameT scid::database::NameBase::NameTypeFromString |
( |
const char * |
str | ) |
|
|
inlinestatic |
Match a string to a nameT.
To match, the string should be a prefix of "player", "event", "site" or "round", or be a superstring of it, e.g. "player ...."
- Parameters
-
| str | the string to be matched. |
- Returns
- a valid nameT, or NAME_INVALID.
The documentation for this class was generated from the following file: