Kea  1.9.9-git
isc::data::ElementValue< T > Class Template Reference

Template class for converting a value encapsulated in the Element object into a simple type. More...

#include <element_value.h>

Public Member Functions

operator() (ConstElementPtr el) const
 Function operator extracting an Element value as integer. More...
 

Detailed Description

template<typename T>
class isc::data::ElementValue< T >

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.

Template Parameters
TType of the value to be extracted.

Definition at line 43 of file element_value.h.

Member Function Documentation

template<typename T >
T isc::data::ElementValue< T >::operator() ( ConstElementPtr  el) const
inline

Function operator extracting an Element value as integer.

Parameters
elElement holding a value to be extracted.

Definition at line 50 of file element_value.h.


The documentation for this class was generated from the following file: