#include <dht/value.h>
Inheritance diagram for dht::value:
Public Member Functions | |
value () | |
default constructor | |
value (const void *data, size_t len, bool aht=true) | |
constructs value from data | |
value (const char *str, bool aht=true) | |
constructs value from C-string | |
value (const std::string &str, bool aht=true) | |
constructs value from string | |
dht::name_value_map & | meta () |
returns reference to the meta data | |
const dht::name_value_map & | meta () const |
returns const reference to the meta data |
Represents a value that is stored/obtained to/from DHT with a key.
A value in DHT can, besides the actual value, contain meta data. Not all DHTs do, so supporting meta data is optional and implementation specific. If value is passed with meta data there is no guarantee the DHT implementation does anything with it.
By default the DHT is allowed to perform a one way hash to the value data to squeeze it into whatever bit size the DHT supports for values. This does not apply to meta data, which must be retrievable like it was stored or not at all.
dht::value::value | ( | ) | [inline] |
default constructor
Constructs an empty value.
dht::value::value | ( | const void * | data, | |
size_t | len, | |||
bool | aht = true | |||
) | [inline] |
constructs value from data
data | pointer to data | |
len | data length | |
aht | if true a one way hash to the data is allowed |
dht::value::value | ( | const char * | str, | |
bool | aht = true | |||
) | [inline] |
constructs value from C-string
str | NULL terminated string | |
aht | if true a one way hash to the data is allowed |
dht::value::value | ( | const std::string & | str, | |
bool | aht = true | |||
) | [inline] |
constructs value from string
str | string | |
aht | if true a one way hash to the data is allowed |
name_value_map & dht::value::meta | ( | ) | [inline] |
returns reference to the meta data
The meta data is stored as dht::name_value_map structure. The meta values can be set by obtaining the reference with this function to the name_value_map.
const name_value_map & dht::value::meta | ( | ) | const [inline] |
returns const reference to the meta data
The meta data is stored as dht::name_value_map structure.