Map of strings to indices not freed till end of table life time.
More...
#include <symbolTable.hpp>
Map of strings to indices not freed till end of table life time.
- Note
- Suitable for symbol tables of languages (DSL)
strus::SymbolTable::~SymbolTable |
( |
| ) |
|
void* strus::SymbolTable::allocBlock |
( |
unsigned int |
blocksize, |
|
|
unsigned int |
elemsize |
|
) |
| |
Allocate a block in the context of the symbol table.
- Note
- Useful for building structures with symbols
- Parameters
-
[in] | blocksize | number of elements to allocate |
[in] | elemsize | size of one element to allocate in bytes |
- Returns
- the block allocated (not freed till end of symbol table life time)
void strus::SymbolTable::clear |
( |
| ) |
|
bool strus::SymbolTable::empty |
( |
| ) |
const |
|
inline |
Evaluate if the symbol table is empty, without any definitions.
- Returns
- true if yes
uint32_t strus::SymbolTable::get |
( |
const std::string & |
key | ) |
const |
Get handle associated with key or 0 if not defined.
- Parameters
-
- Returns
- the handle for the key or 0 if not defined
uint32_t strus::SymbolTable::get |
( |
const char * |
key, |
|
|
std::size_t |
keysize |
|
) |
| const |
Get handle associated with key or 0 if not defined.
- Parameters
-
[in] | key | key string poiner |
[in] | keysize | size of key in bytes |
- Returns
- the handle for the key or 0 if not defined
uint32_t strus::SymbolTable::getOrCreate |
( |
const std::string & |
key | ) |
|
Get handle ( >= 1) associated with key, create one if not defined.
- Parameters
-
- Returns
- the handle for the key or 0 on a memory allocation error
uint32_t strus::SymbolTable::getOrCreate |
( |
const char * |
key, |
|
|
std::size_t |
keysize |
|
) |
| |
Get handle ( >= 1) associated with key, create one if not defined.
- Parameters
-
[in] | key | key string poiner |
[in] | keysize | size of key in bytes |
- Returns
- the handle for the key or 0 on a memory allocation error
Get start iterator of inv.
bool strus::SymbolTable::isNew |
( |
| ) |
const |
|
inline |
Evaluate if the last symbol retrieved with getOrCreate was new.
- Returns
- true if the last symbol retrieved with getOrCreate was new
const char* strus::SymbolTable::key |
( |
const uint32_t & |
id | ) |
const |
Inverse lookup, get key of handle.
- Parameters
-
- Returns
- the key string
std::size_t strus::SymbolTable::size |
( |
| ) |
const |
|
inline |
Get number of elements defined.
- Returns
- the number of elements defined
The documentation for this class was generated from the following file: