Dv::StringMap< T > Class Template Reference

A utility class wrapper around std::map<std::string,std::string>. More...

#include <stringmap.h>

List of all members.

Public Types

typedef std::map< std::string, T > Map
 Implementation type.
typedef Map::const_iterator const_iterator
 Iterator type for StringMap.
typedef Dv::iomanip< StringMap
< T > > 
IoManip

Public Member Functions

const_iterator begin () const
const_iterator end () const
size_t size () const
const T * find (const std::string &key) const throw ()
 Find the value associated with a key.
const T * find_glb (const std::string &key) const throw ()
 Find the value associated with a key k such that.
StringMapset (const std::string &key, const T &value)
 Set the value for a key.
T & operator[] (const std::string &key)
 Access the value associated with a key.
void erase (const std::string &key)
 Remove a <key,value> pair from the map.
void clear ()
 Remove all <key,value> pairs from the map.
IoManip summary () const

Static Public Member Functions

static std::ostream & print_summary (std::ostream &os, const StringMap< T > &map)

Protected Attributes

std::map< std::string, T > map_
 Actual map.

Friends

std::ostream & operator<< (std::ostream &os, const StringMap< T > &map)
 Print a map to a stream.

Detailed Description

template<typename T>
class Dv::StringMap< T >

A utility class wrapper around std::map<std::string,std::string>.

Definition at line 15 of file stringmap.h.


Member Typedef Documentation

template<typename T>
typedef std::map<std::string,T> Dv::StringMap< T >::Map

Implementation type.

Definition at line 18 of file stringmap.h.

template<typename T>
typedef Map::const_iterator Dv::StringMap< T >::const_iterator

Iterator type for StringMap.

Definition at line 20 of file stringmap.h.

template<typename T>
typedef Dv::iomanip<StringMap<T> > Dv::StringMap< T >::IoManip

Definition at line 106 of file stringmap.h.


Member Function Documentation

template<typename T>
const_iterator Dv::StringMap< T >::begin (  )  const [inline]
Returns:
iterator refering to first <key,value> pair in map.

Definition at line 22 of file stringmap.h.

Referenced by Dv::StringMap< std::string >::find_glb(), and Dv::StringMap< std::string >::print_summary().

template<typename T>
const_iterator Dv::StringMap< T >::end (  )  const [inline]
Returns:
iterator pointing past the last <key,value> pair in map.

Definition at line 24 of file stringmap.h.

Referenced by Dv::StringMap< std::string >::find(), Dv::StringMap< std::string >::find_glb(), and Dv::StringMap< std::string >::print_summary().

template<typename T>
size_t Dv::StringMap< T >::size (  )  const [inline]
Returns:
number of <key,value> pairs in the map.

Definition at line 26 of file stringmap.h.

template<typename T>
const T* Dv::StringMap< T >::find ( const std::string &  key  )  const throw () [inline]

Find the value associated with a key.

Parameters:
key to find associated value for.
Returns:
the value associated with a key
0 if no value is associated with the key

Definition at line 33 of file stringmap.h.

Referenced by Dv::Props::Reference::defined(), and Dv::Props::Reference::get().

template<typename T>
const T* Dv::StringMap< T >::find_glb ( const std::string &  key  )  const throw () [inline]

Find the value associated with a key k such that.

 k = max { i | map_[i] defined and i <= key }

In words: find the value associated with the largest key k in the map such that k<=key.

Parameters:
key to find

Definition at line 50 of file stringmap.h.

template<typename T>
StringMap& Dv::StringMap< T >::set ( const std::string &  key,
const T &  value 
) [inline]

Set the value for a key.

Parameters:
key to associate the value with
value associated with key

Definition at line 64 of file stringmap.h.

template<typename T>
T& Dv::StringMap< T >::operator[] ( const std::string &  key  )  [inline]

Access the value associated with a key.

Note that if, before, there is no value associated with the key, after calling this function, the key will be associated with the empty string.

Parameters:
key to find associated value for
Returns:
associated value (possibly the empty string)

Definition at line 75 of file stringmap.h.

template<typename T>
void Dv::StringMap< T >::erase ( const std::string &  key  )  [inline]

Remove a <key,value> pair from the map.

Parameters:
key to remove

Definition at line 82 of file stringmap.h.

template<typename T>
void Dv::StringMap< T >::clear (  )  [inline]

Remove all <key,value> pairs from the map.

Definition at line 87 of file stringmap.h.

template<typename T>
IoManip Dv::StringMap< T >::summary (  )  const [inline]

Definition at line 109 of file stringmap.h.

template<typename T>
static std::ostream& Dv::StringMap< T >::print_summary ( std::ostream &  os,
const StringMap< T > &  map 
) [inline, static]

Definition at line 113 of file stringmap.h.

Referenced by Dv::StringMap< std::string >::summary().


Friends And Related Function Documentation

template<typename T>
std::ostream& operator<< ( std::ostream &  os,
const StringMap< T > &  map 
) [friend]

Print a map to a stream.

Each line has the form

 key: value
Parameters:
os stream to print to
map to print
Returns:
os

Reimplemented in Dv::Props.

Definition at line 100 of file stringmap.h.


Member Data Documentation

template<typename T>
std::map<std::string,T> Dv::StringMap< T >::map_ [protected]

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

dvutil-1.0.10 [ 5 December, 2009]