Kea 2.7.5
|
This class represents a named configuration parameter, e.g. More...
#include <stamped_value.h>
Public Member Functions | |
StampedValue (const std::string &name) | |
Constructor creating a null value. | |
StampedValue (const std::string &name, const ElementPtr &value) | |
Constructor creating a value from the Element . | |
StampedValue (const std::string &name, const std::string &value) | |
Constructor creating a string value. | |
bool | amNull () const |
Checks if the value is null. | |
bool | getBoolValue () const |
Returns value as a boolean. | |
double | getDoubleValue () const |
Returns value as a real number. | |
ConstElementPtr | getElementValue () const |
Returns the value as Element . | |
int64_t | getIntegerValue () const |
Returns value as signed integer. | |
std::string | getName () const |
Returns value name. | |
int | getType () const |
Returns a type of the value. | |
std::string | getValue () const |
Returns value as string. | |
Public Member Functions inherited from isc::data::StampedElement | |
StampedElement () | |
Constructor. | |
void | delServerTag (const std::string &server_tag) |
Deletes server tag. | |
isc::data::ElementPtr | getMetadata () const |
Returns an object representing metadata to be returned with objects from the configuration backend. | |
std::set< ServerTag > | getServerTags () const |
Returns server tags. | |
bool | hasAllServerTag () const |
Checks if the element has 'all' server tag. | |
bool | hasServerTag (const ServerTag &server_tag) const |
Checks if the element has the given server tag. | |
void | setServerTag (const std::string &server_tag) |
Adds new server tag. | |
Public Member Functions inherited from isc::data::BaseStampedElement | |
BaseStampedElement () | |
Constructor. | |
uint64_t | getId () const |
Returns element's database identifier. | |
boost::posix_time::ptime | getModificationTime () const |
Returns timestamp. | |
void | setId (const uint64_t id) |
Sets element's database identifier. | |
void | setModificationTime (const boost::posix_time::ptime ×tamp) |
Sets timestamp to the explicitly provided value. | |
void | updateModificationTime () |
Sets timestamp to the current time. | |
Static Public Member Functions | |
static StampedValuePtr | create (const std::string &name) |
Factory function creating a null value. | |
static StampedValuePtr | create (const std::string &name, const ElementPtr &value) |
Factory function creating a value from the Element . | |
static StampedValuePtr | create (const std::string &name, const std::string &value) |
Factory function creating a string value. | |
static StampedValuePtr | create (const std::string &name, const std::string &value, Element::types type) |
Factory function which attempts to convert provided string value to a given type. | |
Additional Inherited Members | |
Protected Attributes inherited from isc::data::BaseStampedElement | |
uint64_t | id_ |
Database identifier of the configuration element. | |
boost::posix_time::ptime | timestamp_ |
Holds timestamp value. | |
This class represents a named configuration parameter, e.g.
global parameter of the DHCP server.
Global configuration elements having simple types, e.g. DHCP timers, need to be associated with modification timestamps. This association is made by deriving from StampedElement
. The values can be strings, integers, booleans or real numbers.
Because the strings are more flexible, configuration elements are always held as strings in the configuration backends. This class reflects a single value held in the database. The value can be return in its orginal type or can be returned as a string. Also the null values are allowed.
Definition at line 41 of file stamped_value.h.
isc::data::StampedValue::StampedValue | ( | const std::string & | name | ) |
Constructor creating a null value.
name | Name of the value. |
Definition at line 16 of file stamped_value.cc.
isc::data::StampedValue::StampedValue | ( | const std::string & | name, |
const ElementPtr & | value ) |
Constructor creating a value from the Element
.
name | Name of the value. |
value | Value encapsulated in the Element object. |
BadValue | if the value is null. |
TypeError | if the value is neither a string, integer, bool, real or a map with only one element of these types. |
Definition at line 20 of file stamped_value.cc.
isc::data::StampedValue::StampedValue | ( | const std::string & | name, |
const std::string & | value ) |
Constructor creating a string value.
Creates stamped value from a string.
name | Name of the value. |
value | Value to be set. |
Definition at line 25 of file stamped_value.cc.
|
inline |
Checks if the value is null.
Definition at line 135 of file stamped_value.h.
|
static |
Factory function creating a null value.
name | Name of the value. |
Definition at line 31 of file stamped_value.cc.
References StampedValue().
Referenced by create().
|
static |
Factory function creating a value from the Element
.
name | Name of the value. |
value | Value encapsulated in the Element object. |
BadValue | if the value is null. |
TypeError | if the value is neither a string, integer, bool, real or a map with only one element of these types. |
Definition at line 36 of file stamped_value.cc.
References StampedValue().
|
static |
Factory function creating a string value.
Creates stamped value from a string.
name | Name of the value. |
value | Value to be set. |
Definition at line 41 of file stamped_value.cc.
References StampedValue().
|
static |
Factory function which attempts to convert provided string value to a given type.
This factory function is useful in cases when the value is read as a string from a database. The string value has to be converted to the appropriate data type. The type is also known from the database.
name | Name of the value. |
value | Value given as string to be converted. |
type | Type of the value to convert to. |
Definition at line 46 of file stamped_value.cc.
References isc::data::Element::boolean, isc::data::Element::create(), create(), isc::data::Element::integer, isc_throw, isc::data::Element::real, isc::data::Element::string, and isc::data::Element::typeToName().
bool isc::data::StampedValue::getBoolValue | ( | ) | const |
Returns value as a boolean.
TypeError | if the value is not of Element::boolean type. |
Definition at line 148 of file stamped_value.cc.
References isc::data::Element::boolean.
double isc::data::StampedValue::getDoubleValue | ( | ) | const |
Returns value as a real number.
TypeError | if the value is not of Element::real type. |
Definition at line 154 of file stamped_value.cc.
References isc::data::Element::real.
|
inline |
Returns the value as Element
.
Definition at line 161 of file stamped_value.h.
int64_t isc::data::StampedValue::getIntegerValue | ( | ) | const |
Returns value as signed integer.
TypeError | if the value is not of Element::integer type. |
Definition at line 142 of file stamped_value.cc.
References isc::data::Element::integer.
|
inline |
int isc::data::StampedValue::getType | ( | ) | const |
Returns a type of the value.
Element::getType()
output. InvalidOperation | if the value is null. |
Definition at line 96 of file stamped_value.cc.
References isc_throw.
std::string isc::data::StampedValue::getValue | ( | ) | const |
Returns value as string.
It is allowed to call this function for all supported data types. They are converted to a string. For example, a real number of 1.4 will be returned as "1.4". The boolean true value will be returned as "1" etc.
InvalidOperation | if the value is null. |
Definition at line 107 of file stamped_value.cc.
References isc::data::Element::boolean, isc::data::Element::integer, isc_throw, isc::data::Element::real, and isc::data::Element::string.