Kea 2.7.6
element_value.h
Go to the documentation of this file.
1// Copyright (C) 2019 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef ELEMENT_VALUE_H
8#define ELEMENT_VALUE_H
9
10#include <asiolink/io_address.h>
11#include <cc/data.h>
12#include <string>
13
14namespace isc {
15namespace data {
16
42template<typename T>
44public:
45
51 return (static_cast<T>(el->intValue()));
52 }
53};
54
56template<>
57class ElementValue<double> {
58public:
59
64 double operator()(ConstElementPtr el) const {
65 return (el->doubleValue());
66 }
67};
68
70template<>
71class ElementValue<bool> {
72public:
73
78 bool operator()(ConstElementPtr el) const {
79 return (el->boolValue());
80 }
81
82};
83
85template<>
86class ElementValue<std::string> {
87public:
88
93 std::string operator()(ConstElementPtr el) const {
94 return (el->stringValue());
95 }
96};
97
99template<>
100class ElementValue<asiolink::IOAddress> {
101public:
102
110 return (asiolink::IOAddress(el->stringValue()));
111 }
112};
113
114} // end of namespace isc::data
115} // end of namespace isc
116
117#endif // ELEMENT_VALUE_H
bool operator()(ConstElementPtr el) const
Function operator extracting an Element value as boolean.
double operator()(ConstElementPtr el) const
Function operator extracting an Element value as double.
std::string operator()(ConstElementPtr el) const
Function operator extracting an Element value as string.
Template class for converting a value encapsulated in the Element object into a simple type.
T operator()(ConstElementPtr el) const
Function operator extracting an Element value as integer.
boost::shared_ptr< const Element > ConstElementPtr
Definition data.h:29
Defines the logger used by the top-level component of kea-lfc.