#include <dht/name_value_map.h>
Public Types | |
typedef std::map< std::string, std::string > | container_type |
typedef container_type::iterator | iterator |
typedef container_type::const_iterator | const_iterator |
Public Member Functions | |
virtual | ~name_value_map () |
Destructor. | |
const std::string & | get (const std::string &key) const |
Obtains a reference to a stored value. | |
const std::string & | get (const std::string &key, const std::string &def) const |
Obtains a reference to a stored value. | |
void | set (const std::string &key, const std::string &value, bool error_if_set=false) |
Sets the value. | |
bool | exists (const std::string &key) const |
Checks if the key exists. | |
iterator | begin () |
stl style iterator accessors | |
const_iterator | begin () const |
stl style iterator accessors | |
iterator | end () |
stl style iterator accessors | |
const_iterator | end () const |
stl style iterator accessors |
A simple class wrapping a number of name/value pairs of strings to an easily accessable interface. Name is an unique identifier for a value: for each name only one value exists.
Stl style iterator is provided for going through all the name/value pairs contained within.
virtual dht::name_value_map::~name_value_map | ( | ) | [virtual] |
Destructor.
Frees all data contained in the object. References to the data obtained with get() or iterators are invalid.
const std::string& dht::name_value_map::get | ( | const std::string & | key | ) | const |
Obtains a reference to a stored value.
key | A string specifying the key |
const std::string& dht::name_value_map::get | ( | const std::string & | key, | |
const std::string & | def | |||
) | const |
Obtains a reference to a stored value.
key | A string specifying the key | |
def | If no value is found for the key, returns the string specified here. |
void dht::name_value_map::set | ( | const std::string & | key, | |
const std::string & | value, | |||
bool | error_if_set = false | |||
) |
Sets the value.
key | A string specifying the key | |
value | A string specifying the value | |
error_if_set | If true and there already exists a value for the key, throws an exception |
bool dht::name_value_map::exists | ( | const std::string & | key | ) | const [inline] |
Checks if the key exists.
name_value_map::iterator dht::name_value_map::begin | ( | ) | [inline] |
stl style iterator accessors
name_value_map::const_iterator dht::name_value_map::begin | ( | ) | const [inline] |
stl style iterator accessors
name_value_map::iterator dht::name_value_map::end | ( | ) | [inline] |
stl style iterator accessors
name_value_map::const_iterator dht::name_value_map::end | ( | ) | const [inline] |
stl style iterator accessors