A utility class wrapper around std::map<std::string,std::string>. More...
#include <stringmap.h>
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. | |
StringMap & | set (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. |
A utility class wrapper around std::map<std::string,std::string>.
Definition at line 15 of file stringmap.h.
typedef std::map<std::string,T> Dv::StringMap< T >::Map |
Implementation type.
Definition at line 18 of file stringmap.h.
typedef Map::const_iterator Dv::StringMap< T >::const_iterator |
Iterator type for StringMap.
Definition at line 20 of file stringmap.h.
typedef Dv::iomanip<StringMap<T> > Dv::StringMap< T >::IoManip |
Definition at line 106 of file stringmap.h.
const_iterator Dv::StringMap< T >::begin | ( | ) | const [inline] |
Definition at line 22 of file stringmap.h.
Referenced by Dv::StringMap< std::string >::find_glb(), and Dv::StringMap< std::string >::print_summary().
const_iterator Dv::StringMap< T >::end | ( | ) | const [inline] |
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().
size_t Dv::StringMap< T >::size | ( | ) | const [inline] |
Definition at line 26 of file stringmap.h.
const T* Dv::StringMap< T >::find | ( | const std::string & | key | ) | const throw () [inline] |
Find the value associated with a key.
key | to find associated value for. |
Definition at line 33 of file stringmap.h.
Referenced by Dv::Props::Reference::defined(), and Dv::Props::Reference::get().
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.
key | to find |
Definition at line 50 of file stringmap.h.
StringMap& Dv::StringMap< T >::set | ( | const std::string & | key, | |
const T & | value | |||
) | [inline] |
Set the value for a key.
key | to associate the value with | |
value | associated with key |
Definition at line 64 of file stringmap.h.
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.
key | to find associated value for |
Definition at line 75 of file stringmap.h.
void Dv::StringMap< T >::erase | ( | const std::string & | key | ) | [inline] |
Remove a <key,value> pair from the map.
key | to remove |
Definition at line 82 of file stringmap.h.
void Dv::StringMap< T >::clear | ( | ) | [inline] |
Remove all <key,value> pairs from the map.
Definition at line 87 of file stringmap.h.
IoManip Dv::StringMap< T >::summary | ( | ) | const [inline] |
Definition at line 109 of file stringmap.h.
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().
std::ostream& operator<< | ( | std::ostream & | os, | |
const StringMap< T > & | map | |||
) | [friend] |
Print a map to a stream.
Each line has the form
key: value
os | stream to print to | |
map | to print |
Reimplemented in Dv::Props.
Definition at line 100 of file stringmap.h.
std::map<std::string,T> Dv::StringMap< T >::map_ [protected] |
Actual map.
Definition at line 124 of file stringmap.h.
Referenced by Dv::StringMap< std::string >::begin(), Dv::StringMap< std::string >::clear(), Dv::StringMap< std::string >::end(), Dv::StringMap< std::string >::erase(), Dv::StringMap< std::string >::find(), Dv::StringMap< std::string >::find_glb(), Dv::Props::Reference::operator const std::string &(), Dv::Props::Reference::operator std::string &(), Dv::Props::operator==(), Dv::StringMap< std::string >::operator[](), Dv::StringMap< std::string >::set(), and Dv::StringMap< std::string >::size().
dvutil-1.0.10 | [ 5 December, 2009] |