rutz::assoc_array_base Class Reference

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

#include <rutz/assocarray.h>

Collaboration diagram for rutz::assoc_array_base:
Collaboration graph
[legend]

List of all members.

Classes

struct  impl

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.

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.


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.

rutz::assoc_array_base::~assoc_array_base (  ) 

Virtual destructor.

Definition at line 99 of file assocarray.cc.

References clear().


Member Function Documentation

void rutz::assoc_array_base::clear ( void   ) 

Clear all entries, calling the kill function for each.

Definition at line 145 of file assocarray.cc.

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.

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.

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.

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(), and rutz::sfmt().

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


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:31:12 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3