Kea 2.7.6
|
Template class for converting a value encapsulated in the Element
object into a simple type.
More...
#include <element_value.h>
Public Member Functions | |
T | operator() (ConstElementPtr el) const |
Function operator extracting an Element value as integer. | |
Template class for converting a value encapsulated in the Element
object into a simple type.
The Element
object provides a set of accessors to retrieve values of different types it encapsulates. These methods however can't be always used in template methods and classes.
Consider a template function which returns a value of a type specified as template argument. In order to convert a value held in the Element
object it would have to conditionally call this object's accessors to return the value of the appropriate type. This would however fail to compile because the compiler would check for all possible value types returned by the Element
accessors and report an error for those that don't cast to the returned type.
This class provides a mechanism to extract the value of the appropriate type from the Element
object within the template function. It comes with a number of class specializations for various data types to be returned. The default implementation calls Element::intValue
and casts it to the returned type. There are class specializations for double
, bool
and string
.
T | Type of the value to be extracted. |
Definition at line 43 of file element_value.h.
|
inline |
Function operator extracting an Element
value as integer.
el | Element holding a value to be extracted. |
Definition at line 50 of file element_value.h.