Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

rutz::assoc_array_base Class Reference

#include <rutz/assocarray.h>

Collaboration diagram for rutz::assoc_array_base:

Collaboration graph
[legend]
List of all members.

Detailed Description

A non-typesafe wrapper around std::map<string, void*>.

The use must provide a pointer to a function that knows how to properly destroy the actual contained objects according to their true type.

Definition at line 48 of file assocarray.h.

Public Types

typedef void( kill_func_t )(void *)
 Function type for destroying elements.

Public Member Functions

 assoc_array_base (kill_func_t *f, const char *descr, bool nocase)
 Default constructor.
 ~assoc_array_base ()
 Virtual destructor.
rutz::fstring get_known_keys (const char *sep) const
 Get a list of known keys, separated by sep.
void throw_for_key (const char *key, const rutz::file_pos &pos) const
 Raise an exception reporting an unknown key.
void throw_for_key (const rutz::fstring &key, const rutz::file_pos &pos) const
 Raise an exception reporting an unknown key.
void * get_value_for_key (const rutz::fstring &name) const
 Retrieve the object associated with the tag name.
void * get_value_for_key (const char *name) const
 Retrieve the object associated with the tag name.
void set_value_for_key (const char *name, void *ptr)
 Associate the object at ptr with the tag name.
void clear ()
 Clear all entries, calling the kill function for each.

Classes

struct  impl


Member Typedef Documentation

typedef void( rutz::assoc_array_base::kill_func_t)(void *)
 

Function type for destroying elements.

Definition at line 52 of file assocarray.h.


Constructor & Destructor Documentation

rutz::assoc_array_base::assoc_array_base kill_func_t f,
const char *  descr,
bool  nocase
 

Default constructor.

Parameters:
descr a human-readable description of what this array's keys represent; this is used in error messages, e.g. if descr is "frobnicator", then error messages would include "unknown frobnicator"
nocase true if the array should use case-insensitive string comparisons (default is false, giving normal case-sensitive string comparisons)

Definition at line 91 of file assocarray.cc.

References GVX_TRACE.

rutz::assoc_array_base::~assoc_array_base  ) 
 

Virtual destructor.

Definition at line 99 of file assocarray.cc.

References clear(), and GVX_TRACE.


Member Function Documentation

void rutz::assoc_array_base::clear  ) 
 

Clear all entries, calling the kill function for each.

Definition at line 145 of file assocarray.cc.

References GVX_TRACE, rutz::assoc_array_base::impl::kill_func, and rutz::assoc_array_base::impl::values.

Referenced by ~assoc_array_base().

rutz::fstring rutz::assoc_array_base::get_known_keys const char *  sep  )  const
 

Get a list of known keys, separated by sep.

Definition at line 106 of file assocarray.cc.

References first, and rutz::assoc_array_base::impl::values.

Referenced by rutz::assoc_array< rutz::creator_base< base_t > >::get_known_keys(), and throw_for_key().

void * rutz::assoc_array_base::get_value_for_key const char *  name  )  const
 

Retrieve the object associated with the tag name.

Definition at line 165 of file assocarray.cc.

References get_value_for_key().

void * rutz::assoc_array_base::get_value_for_key const rutz::fstring name  )  const
 

Retrieve the object associated with the tag name.

Definition at line 159 of file assocarray.cc.

References GVX_TRACE, and rutz::assoc_array_base::impl::values.

Referenced by rutz::assoc_array< rutz::creator_base< base_t > >::get_ptr_for_key(), and get_value_for_key().

void rutz::assoc_array_base::set_value_for_key const char *  name,
void *  ptr
 

Associate the object at ptr with the tag name.

Definition at line 170 of file assocarray.cc.

References GVX_TRACE, rutz::assoc_array_base::impl::kill_func, and rutz::assoc_array_base::impl::values.

Referenced by rutz::assoc_array< rutz::creator_base< base_t > >::set_ptr_for_key().

void rutz::assoc_array_base::throw_for_key const rutz::fstring key,
const rutz::file_pos pos
const
 

Raise an exception reporting an unknown key.

Definition at line 140 of file assocarray.cc.

References rutz::fstring::c_str(), and throw_for_key().

void rutz::assoc_array_base::throw_for_key const char *  key,
const rutz::file_pos pos
const
 

Raise an exception reporting an unknown key.

Definition at line 130 of file assocarray.cc.

References rutz::fstring::c_str(), get_known_keys(), rutz::assoc_array_base::impl::key_description, and rutz::sfmt().

Referenced by rutz::assoc_array< rutz::creator_base< base_t > >::throw_for_key(), and throw_for_key().


The documentation for this class was generated from the following files:
Generated on Sun Nov 22 13:51:42 2009 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4