Kea  1.9.9-git
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 
14 namespace isc {
15 namespace data {
16 
42 template<typename T>
43 class ElementValue {
44 public:
45 
51  return (static_cast<T>(el->intValue()));
52  }
53 };
54 
56 template<>
57 class ElementValue<double> {
58 public:
59 
64  double operator()(ConstElementPtr el) const {
65  return (el->doubleValue());
66  }
67 };
68 
70 template<>
71 class ElementValue<bool> {
72 public:
73 
78  bool operator()(ConstElementPtr el) const {
79  return (el->boolValue());
80  }
81 
82 };
83 
85 template<>
86 class ElementValue<std::string> {
87 public:
88 
93  std::string operator()(ConstElementPtr el) const {
94  return (el->stringValue());
95  }
96 };
97 
99 template<>
100 class ElementValue<asiolink::IOAddress> {
101 public:
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
double operator()(ConstElementPtr el) const
Function operator extracting an Element value as double.
Definition: element_value.h:64
STL namespace.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
Defines the logger used by the top-level component of kea-dhcp-ddns.
bool operator()(ConstElementPtr el) const
Function operator extracting an Element value as boolean.
Definition: element_value.h:78
T operator()(ConstElementPtr el) const
Function operator extracting an Element value as integer.
Definition: element_value.h:50
std::string operator()(ConstElementPtr el) const
Function operator extracting an Element value as string.
Definition: element_value.h:93
Template class for converting a value encapsulated in the Element object into a simple type...
Definition: element_value.h:43