#include <template.h>
Public Member Functions | |
~symtab () | |
symtab () | |
symtab (const symtab &arg) | |
symtab & | operator= (const symtab &arg) |
void | clear () |
value_type_t | get (const nstring &key) const |
nstring | query_fuzzy (const nstring &key) const |
value_type_t * | query (string_ty *key) const |
value_type_t * | query (const nstring &key) const |
value_type_t * | query (const nstring_list &key_list) const |
void | assign (string_ty *key, value_type_t *value) |
void | assign (const nstring &key, value_type_t *value) |
void | assign (const nstring &key, const value_type_t &value) |
void | remove (const nstring &key) |
void | dump (const char *caption) const |
void | set_reaper () |
bool | empty () const |
size_t | size () const |
void | keys (nstring_list &result) const |
Private Member Functions | |
void | copy (const symtab &arg) |
Static Private Member Functions | |
static void | reaper (void *p) |
Private Attributes | |
symtab_ty * | stp |
This template is intended as a very thin veneer over the underlying functionality. For this reason all of the methods are inline. If you add more methods, make sure they are also inline.
Definition at line 43 of file template.h.
The destructor. It is not virtual, do not derive from this class.
Definition at line 50 of file template.h.
The default constructor.
Definition at line 62 of file template.h.
symtab< value_type_t >::symtab | ( | const symtab< value_type_t > & | arg | ) | [inline] |
The copy constructor.
Definition at line 70 of file template.h.
symtab& symtab< value_type_t >::operator= | ( | const symtab< value_type_t > & | arg | ) | [inline] |
The assignment operator.
Definition at line 79 of file template.h.
void symtab< value_type_t >::clear | ( | void | ) | [inline] |
The clear method is used to delete all entries from the symbol table.
Definition at line 93 of file template.h.
value_type_t symtab< value_type_t >::get | ( | const nstring & | key | ) | const [inline] |
The get method is used to look for a particular key in the symbol table. If the value is not present, a default instance of the value type is returned.
key | The symbol table entry to look for. |
Definition at line 108 of file template.h.
nstring symtab< value_type_t >::query_fuzzy | ( | const nstring & | key | ) | const [inline] |
The query_fuzzy method may be used to search for a variable.
key | The row name to search for. |
Definition at line 130 of file template.h.
value_type_t* symtab< value_type_t >::query | ( | string_ty * | key | ) | const [inline] |
The query method is used to locate the given key in the symbol table.
key | The symbol table entry to look for. |
Definition at line 145 of file template.h.
value_type_t* symtab< value_type_t >::query | ( | const nstring & | key | ) | const [inline] |
The query method is used to locate the given key in the symbol table.
key | The symbol table entry to look for. |
Definition at line 160 of file template.h.
value_type_t* symtab< value_type_t >::query | ( | const nstring_list & | key_list | ) | const [inline] |
The query method is used to locate the given key in the symbol table.
key_list | The symbol table entries to look for. The first found is returned. |
Definition at line 176 of file template.h.
void symtab< value_type_t >::assign | ( | string_ty * | key, | |
value_type_t * | value | |||
) | [inline] |
The assign method is used to associate a value with a key.
key | The symbol table entry to set. | |
value | The value to assign. Note that it is always a pointer. If you have called the set_reaper method, it will have operator delete called on it (non array) when the symbol table destructor is run. |
Definition at line 198 of file template.h.
void symtab< value_type_t >::assign | ( | const nstring & | key, | |
value_type_t * | value | |||
) | [inline] |
The assign mentod is used to associate a value with a key.
key | The symbol table entry to set. | |
value | The value to assign. Note that it is always a pointer. If you have called the set_reaper method, it will have operator delete called on it (non array) when the symbol table destructor is run. |
Definition at line 217 of file template.h.
void symtab< value_type_t >::assign | ( | const nstring & | key, | |
const value_type_t & | value | |||
) | [inline] |
The assign method is used to associate a value with a key.
key | The symbol table entry to set. | |
value | The value to assign. A copy will be made in dynamic memory. You need to call set_reaper to ensure there is no memory leak when the symbol table destructor is run. |
Definition at line 235 of file template.h.
The remove method is used to remove a value (and its key) from a symbol table. It is not an error if it has already been removed.
key | The symbol table entry to look for. |
Definition at line 252 of file template.h.
void symtab< value_type_t >::dump | ( | const char * | caption | ) | const [inline] |
The dump method is used during debugging to print the contents of a symbol table.
caption | The heading to print before the contents. |
Definition at line 266 of file template.h.
void symtab< value_type_t >::set_reaper | ( | ) | [inline] |
The set_reaper method is used to set the reper function of the inner symtab_ty. This not done by default, because not all symbol tables need their contents deleted when they are deleted.
Definition at line 279 of file template.h.
bool symtab< value_type_t >::empty | ( | ) | const [inline] |
The empty method may be used to determine if there symbol table is empty (i.e. there are no rows).
Definition at line 291 of file template.h.
size_t symtab< value_type_t >::size | ( | ) | const [inline] |
The size method may be used to determine how many rows there are in the symbol table.
Definition at line 302 of file template.h.
void symtab< value_type_t >::keys | ( | nstring_list & | result | ) | const [inline] |
The keys method may be used to extract the list of row names from the symbol table.
result | Where to put the row names. It is cleared before any row names are placed in it. It is not sorted. |
This method has O(n) execution time.
Definition at line 323 of file template.h.
static void symtab< value_type_t >::reaper | ( | void * | p | ) | [inline, static, private] |
The reaper class methos is used to delete symbol table contents when assigned over, and when the symbol table destructor is run.
Definition at line 343 of file template.h.
void symtab< value_type_t >::copy | ( | const symtab< value_type_t > & | arg | ) | [inline, private] |
The copy method is used to copy the contents of one symbol table into another.
Definition at line 350 of file template.h.
The stp instance variable is used to remember the location of the dynamically allocated symbol table.
Definition at line 337 of file template.h.