symtab< value_type_t > Class Template Reference
[Symtab]

#include <template.h>


Public Member Functions

 ~symtab ()
 symtab ()
 symtab (const symtab &arg)
symtaboperator= (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_tystp


Detailed Description

template<class value_type_t>
class symtab< value_type_t >

The symtab template class is used to provide a type-safe interface to the generic symtab_* API.

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.


Constructor & Destructor Documentation

template<class value_type_t>
symtab< value_type_t >::~symtab (  )  [inline]

The destructor. It is not virtual, do not derive from this class.

Definition at line 50 of file template.h.

template<class value_type_t>
symtab< value_type_t >::symtab (  )  [inline]

The default constructor.

Definition at line 62 of file template.h.

template<class value_type_t>
symtab< value_type_t >::symtab ( const symtab< value_type_t > &  arg  )  [inline]

The copy constructor.

Definition at line 70 of file template.h.


Member Function Documentation

template<class value_type_t>
symtab& symtab< value_type_t >::operator= ( const symtab< value_type_t > &  arg  )  [inline]

The assignment operator.

Definition at line 79 of file template.h.

template<class value_type_t>
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.

template<class value_type_t>
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.

Parameters:
key The symbol table entry to look for.

Definition at line 108 of file template.h.

template<class value_type_t>
nstring symtab< value_type_t >::query_fuzzy ( const nstring key  )  const [inline]

The query_fuzzy method may be used to search for a variable.

Parameters:
key The row name to search for.
Returns:
The NULL pointer if there is no row of that name and no row with a similar name, otherwise returns a pointer to the most similar name.
Note:
This method has O(n) execution time.

Definition at line 130 of file template.h.

template<class value_type_t>
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.

Parameters:
key The symbol table entry to look for.
Note:
This method will be DEPRECATED as soon as possible

Definition at line 145 of file template.h.

template<class value_type_t>
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.

Parameters:
key The symbol table entry to look for.

Definition at line 160 of file template.h.

template<class value_type_t>
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.

Parameters:
key_list The symbol table entries to look for. The first found is returned.

Definition at line 176 of file template.h.

template<class value_type_t>
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.

Parameters:
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.
Note:
This method will be DEPRECATED as soon as possible

Definition at line 198 of file template.h.

template<class value_type_t>
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.

Parameters:
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.

template<class value_type_t>
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.

Parameters:
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.

template<class value_type_t>
void symtab< value_type_t >::remove ( const nstring key  )  [inline]

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.

Parameters:
key The symbol table entry to look for.
Note:
If set_reaper has been called, the operator delete will be called for the value.

Definition at line 252 of file template.h.

template<class value_type_t>
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.

Parameters:
caption The heading to print before the contents.

Definition at line 266 of file template.h.

template<class value_type_t>
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.

template<class value_type_t>
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.

template<class value_type_t>
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.

template<class value_type_t>
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.

Parameters:
result Where to put the row names. It is cleared before any row names are placed in it. It is not sorted.
Note:
If you have used assign_push method, it is possible to have duplicates in the list of keys.

This method has O(n) execution time.

Definition at line 323 of file template.h.

template<class value_type_t>
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.

template<class value_type_t>
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.


Field Documentation

template<class value_type_t>
symtab_ty* symtab< value_type_t >::stp [private]

The stp instance variable is used to remember the location of the dynamically allocated symbol table.

Definition at line 337 of file template.h.


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

Generated on Wed Mar 12 23:37:45 2008 for Aegis by  doxygen 1.5.5