9 #ifndef _STRUS_BASE_SYMBOL_TABLE_HPP_INCLUDED 
   10 #define _STRUS_BASE_SYMBOL_TABLE_HPP_INCLUDED 
   22 class ErrorBufferInterface;
 
   24 class StringMapKeyBlockList;
 
   32                 :m_errorhnd(errorhnd_),m_blocks(createBlocks())
 
   36                         deleteBlocks( m_blocks);
 
   37                         throw std::bad_alloc();
 
   46         static StringMapKeyBlockList* createBlocks();
 
   47         static void deleteBlocks( StringMapKeyBlockList* ptr);
 
   51         StringMapKeyBlockList* m_blocks;
 
   62                 :m_errorhnd(errorhnd_),m_map(createInternalMap()),m_keystring_blocks(createKeystringBlocks()),m_isnew(false)
 
   64                 if (!m_keystring_blocks || !m_map)
 
   66                         if (!m_keystring_blocks) deleteKeystringBlocks( m_keystring_blocks);
 
   67                         if (!m_map) deleteInternalMap( m_map);
 
   68                         throw std::bad_alloc();
 
   80                 Key( 
const char* str_, std::size_t len_)
 
   89                         if (a.
len < b.
len) 
return true;
 
   90                         if (a.
len > b.
len) 
return false;
 
   91                         return std::memcmp( a.
str, b.
str, a.
len) < 0;
 
  126         uint32_t 
get( 
const std::string& 
key) 
const;
 
  131         uint32_t 
get( 
const char* 
key, std::size_t keysize) 
const;
 
  136         const char* 
key( 
const uint32_t& 
id) 
const;
 
  142                 return m_invmap.size();
 
  149                 return m_invmap.empty();
 
  157                 return m_invmap.begin();
 
  162                 return m_invmap.end();
 
  177         void* 
allocBlock( 
unsigned int blocksize, 
unsigned int elemsize);
 
  183 #if __cplusplus >= 201103L 
  190         static StringMapKeyBlockList* createKeystringBlocks();
 
  191         static void deleteKeystringBlocks( StringMapKeyBlockList* ptr);
 
  192         static InternalMap* createInternalMap();
 
  193         static void deleteInternalMap( InternalMap* ptr);
 
  196         ErrorBufferInterface* m_errorhnd;
 
  198         std::vector<const char*> m_invmap;
 
  199         StringMapKeyBlockList* m_keystring_blocks;
 
bool operator()(const Key &a, const Key &b) const 
Definition: symbolTable.hpp:87
void * allocBlock(unsigned int blocksize, unsigned int elemsize)
Allocate a block in the context of the symbol table. 
bool empty() const 
Evaluate if the symbol table is empty, without any definitions. 
Definition: symbolTable.hpp:147
static uint32_t calc(const char *blk, std::size_t blksize)
const_inv_iterator inv_end() const 
Get end iterator of inv. 
Definition: symbolTable.hpp:160
Key()
Definition: symbolTable.hpp:78
std::size_t len
Definition: symbolTable.hpp:76
Definition: symbolTable.hpp:101
std::size_t size() const 
Get number of elements defined. 
Definition: symbolTable.hpp:140
const char * str
Definition: symbolTable.hpp:75
int operator()(const Key &key) const 
Definition: symbolTable.hpp:103
void clear()
Free all keys allocated. 
const char * key(const uint32_t &id) const 
Inverse lookup, get key of handle. 
Interface for reporting and catching errors in modules. 
Definition: errorBufferInterface.hpp:24
Definition: symbolTable.hpp:94
Key of symbol table. 
Definition: symbolTable.hpp:73
Definition: symbolTable.hpp:85
Key(const char *str_, std::size_t len_)
Definition: symbolTable.hpp:80
Key(const Key &o)
Definition: symbolTable.hpp:82
SymbolTable(ErrorBufferInterface *errorhnd_)
Default constructor. 
Definition: symbolTable.hpp:61
Map of strings to indices not freed till end of table life time. 
Definition: symbolTable.hpp:57
const_inv_iterator inv_begin() const 
Get start iterator of inv. 
Definition: symbolTable.hpp:155
BlockAllocator(ErrorBufferInterface *errorhnd_)
Definition: symbolTable.hpp:31
bool isNew() const 
Evaluate if the last symbol retrieved with getOrCreate was new. 
Definition: symbolTable.hpp:167
~SymbolTable()
Destructor. 
bool operator()(const Key &a, const Key &b) const 
Definition: symbolTable.hpp:96
const char * allocStringCopy(const char *str, std::size_t size)
Definition: symbolTable.hpp:28
uint32_t getOrCreate(const std::string &key)
Get handle ( >= 1) associated with key, create one if not defined. 
std::vector< const char * >::const_iterator const_inv_iterator
Definition: symbolTable.hpp:152