ConfigDB::StringPool Class Reference

Pool for string data. More...

#include <Pool.h>

Inheritance diagram for ConfigDB::StringPool:
Collaboration diagram for ConfigDB::StringPool:

Public Member Functions

 StringPool ()
 
 ~StringPool ()
 
StringId find (const CountedString &string) const
 Search for a string. More...
 
StringId add (const CountedString &string)
 
StringId findOrAdd (const CountedString &string)
 
CountedString operator[] (StringId ref) const
 
const char * getBuffer () const
 
- Public Member Functions inherited from ConfigDB::PoolData
 PoolData (size_t itemSize)
 
 PoolData (const PoolData &other)
 
 PoolData (PoolData &&other)
 
PoolDataoperator= (const PoolData &other)
 
size_t getCount () const
 
size_t getCapacity () const
 
size_t getItemSize () const
 
size_t getItemSize (size_t count) const
 
void * operator[] (unsigned index)
 
const void * operator[] (unsigned index) const
 
void clear ()
 
bool ensureCapacity (size_t capacity)
 
size_t usage () const
 

Additional Inherited Members

- Protected Member Functions inherited from ConfigDB::PoolData
void * allocate (size_t itemCount)
 
void deallocate (size_t itemCount)
 
void * getItemPtr (unsigned index)
 
const void * getItemPtr (unsigned index) const
 
- Protected Attributes inherited from ConfigDB::PoolData
void * buffer {}
 
uint16_t count {0}
 
uint8_t space {0}
 
uint8_t itemSize
 

Detailed Description

Pool for string data.

We store all string data in a single buffer. A StringId references a string item by position, and is always > 0. Strings are appended but never removed.

To support binary data we use counted strings. Strings of 128 (0x80) or fewer characters use a single byte prefix containing the length. Longer strings require a second byte which is combined with the first. For example:

0x82 0x00 0x0200 0x80 0x0080 0x81 0x00 0x0100

Storing large amounts of binary data is not advisable. Instead, configuration should store a filename or reference to some external storage.

Note: We might consider implementing some kind of 'load on demand' feature in ConfigDB so that externally stored data can be transparently fetched.

Constructor & Destructor Documentation

◆ StringPool()

ConfigDB::StringPool::StringPool ( )
inline

◆ ~StringPool()

ConfigDB::StringPool::~StringPool ( )
inline

Member Function Documentation

◆ add()

StringId ConfigDB::StringPool::add ( const CountedString string)

◆ find()

StringId ConfigDB::StringPool::find ( const CountedString string) const

Search for a string.

Return values
StringId0 if string is not found

◆ findOrAdd()

StringId ConfigDB::StringPool::findOrAdd ( const CountedString string)
inline

◆ getBuffer()

const char* ConfigDB::StringPool::getBuffer ( ) const
inline

◆ operator[]()

CountedString ConfigDB::StringPool::operator[] ( StringId  ref) const
inline

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