ace::StringStore< _IndType > Class Template Reference

Class purpose is to store unique C-strings and let them be accessed (later) by unique numeral indices of given type (which shall be the smallest one unsigned type capable of store as much values as the number of C-strings expected). More...

#include <strings.h>

List of all members.

Public Types

typedef std::vector< const char * > table_t
 Typedef for container of pointers to stored strings which acts as conversion table: index -> pointer (to C-string).

Public Member Functions

 StringStore (size_t max_string_length)
 Constructs new StringStore.
void clear (void)
 Drops all stored strings.
bool is_full (void) const
const char * get (_IndType index) const
 Retrieves pointer to string instance tied to given index.
_IndType store (const char *str)
 Stores the string and returns string index within store.
size_t size (void) const

Private Types

typedef std::set< _IndType,
StringStoreLessComparator
< _IndType > > 
_index_t
 Typedef for set which is used as index above the conversion table.

Private Attributes

RandomSizedMemoryPool< char > _memory_pool
 Memory pool used to store the C-strings.
table_t _strings_table
 Container with pointers to string instances (conversion table).
_index_t _strings_index
 Container acts as index above strings pointers container.
StringStoreEqualComparator
< _IndType > 
_str_equal_comp
 Comparator needed for determination of two C-strings (un)equality.


Detailed Description

template<class _IndType>
class ace::StringStore< _IndType >

Class purpose is to store unique C-strings and let them be accessed (later) by unique numeral indices of given type (which shall be the smallest one unsigned type capable of store as much values as the number of C-strings expected).

The equality of strings is based just on their bitwise values (so "String" and "string" will be considered as two different strings). Class provides O(log N) when inserting new C-string and O(1) time when retrieving stored string (by accessing it by its index). Note that this concept of string storage has one advantage - when comparing two strings stored within same storage to determine if they are equal, one has only to compare the indices themself, not the strings they "point" to.

Parameters:
_IndType Type for string indices, can be any of unsigned types. When new string is inserted, overflow check is performed.

Member Typedef Documentation

template<class _IndType>
typedef std::vector<const char *> ace::StringStore< _IndType >::table_t

Typedef for container of pointers to stored strings which acts as conversion table: index -> pointer (to C-string).

template<class _IndType>
typedef std::set<_IndType, StringStoreLessComparator<_IndType> > ace::StringStore< _IndType >::_index_t [private]

Typedef for set which is used as index above the conversion table.


Constructor & Destructor Documentation

template<class _IndType>
ace::StringStore< _IndType >::StringStore ( size_t  max_string_length  )  [inline]

Constructs new StringStore.

Parameters:
max_string_length Maximum storable string length.


Member Function Documentation

template<class _IndType>
void ace::StringStore< _IndType >::clear ( void   )  [inline]

Drops all stored strings.

template<class _IndType>
bool ace::StringStore< _IndType >::is_full ( void   )  const [inline]

Returns:
True, if all available indices has been spent (overflow almost guaranteed).

template<class _IndType>
const char* ace::StringStore< _IndType >::get ( _IndType  index  )  const [inline]

Retrieves pointer to string instance tied to given index.

Note: No range checks are performed!

Parameters:
index Index of C-string to rietrieve.
Returns:
Pointer to stored C-string instance.

template<class _IndType>
_IndType ace::StringStore< _IndType >::store ( const char *  str  )  [inline]

Stores the string and returns string index within store.

Parameters:
str Pointer to C-string to store within.
Returns:
Index of stored copy.
Exceptions:
string_index_overflow When insertion of new string would cause overflow of _IndType.

template<class _IndType>
size_t ace::StringStore< _IndType >::size ( void   )  const [inline]

Returns:
Size of the store (number of unique strings within).


Member Data Documentation

template<class _IndType>
RandomSizedMemoryPool<char> ace::StringStore< _IndType >::_memory_pool [private]

Memory pool used to store the C-strings.

template<class _IndType>
table_t ace::StringStore< _IndType >::_strings_table [private]

Container with pointers to string instances (conversion table).

template<class _IndType>
_index_t ace::StringStore< _IndType >::_strings_index [private]

Container acts as index above strings pointers container.

template<class _IndType>
StringStoreEqualComparator<_IndType> ace::StringStore< _IndType >::_str_equal_comp [private]

Comparator needed for determination of two C-strings (un)equality.


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

Generated on Wed Aug 6 23:25:51 2008 for PACE by  doxygen 1.5.6