Per review comments.
lib_LTLIBRARIES = libkea-cc.la
libkea_cc_la_SOURCES = data.cc data.h
-libkea_cc_la_SOURCES += element_extractor.h
+libkea_cc_la_SOURCES += element_value.h
libkea_cc_la_SOURCES += cfg_to_element.h dhcp_config_error.h
libkea_cc_la_SOURCES += command_interpreter.cc command_interpreter.h
libkea_cc_la_SOURCES += json_feed.cc json_feed.h
command_interpreter.h \
data.h \
dhcp_config_error.h \
- element_extractor.h \
+ element_value.h \
json_feed.h \
simple_parser.h \
stamped_element.h \
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef ELEMENT_EXTRACTOR_H
-#define ELEMENT_EXTRACTOR_H
+#ifndef ELEMENT_VALUE_H
+#define ELEMENT_VALUE_H
#include <cc/data.h>
#include <string>
///
/// @tparam T Type of the value to be extracted.
template<typename T>
-class ElementExtractor {
+class ElementValue {
public:
/// @brief Function operator extracting an @c Element value as
}
};
-/// @brief The @c ElementExtractor specialization for double.
+/// @brief The @c ElementValue specialization for double.
template<>
-class ElementExtractor<double> {
+class ElementValue<double> {
public:
/// @brief Function operator extracting an @c Element value as
}
};
-/// @brief The @c ElementExtractor specialization for boolean.
+/// @brief The @c ElementValue specialization for boolean.
template<>
-class ElementExtractor<bool> {
+class ElementValue<bool> {
public:
/// @brief Function operator extracting an @c Element value as
};
-/// @brief The @c ElementExtractor specialization for string.
+/// @brief The @c ElementValue specialization for string.
template<>
-class ElementExtractor<std::string> {
+class ElementValue<std::string> {
public:
/// @brief Function operator extracting an @c Element value as
} // end of namespace isc::data
} // end of namespace isc
-#endif // ELEMENT_EXTRACTOR_H
+#endif // ELEMENT_VALUE_H
run_unittests_SOURCES = command_interpreter_unittests.cc
run_unittests_SOURCES += data_unittests.cc
run_unittests_SOURCES += data_file_unittests.cc
-run_unittests_SOURCES += element_extractor_unittests.cc
+run_unittests_SOURCES += element_value_unittests.cc
run_unittests_SOURCES += json_feed_unittests.cc
run_unittests_SOURCES += simple_parser_unittest.cc
run_unittests_SOURCES += stamped_element_unittest.cc
+++ /dev/null
-// Copyright (C) 2019 Internet Systems Consortium, Inc. ("ISC")
-//
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this
-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#include <config.h>
-#include <cc/element_extractor.h>
-#include <gtest/gtest.h>
-
-using namespace isc::data;
-
-namespace {
-
-// This test verifies that integer value can be extracted.
-TEST(ElementExtractor, intValue) {
- EXPECT_EQ(5, ElementExtractor<int>()(Element::create(5)));
- EXPECT_THROW(ElementExtractor<int>()(Element::create("hola!")),
- TypeError);
-}
-
-// This test verifies that double value can be extracted.
-TEST(ElementExtractor, doubleValue) {
- EXPECT_EQ(1.4, ElementExtractor<double>()(Element::create(1.4)));
- EXPECT_THROW(ElementExtractor<double>()(Element::create("hola!")),
- TypeError);
-}
-
-// This test verifies that boolean value can be extracted.
-TEST(ElementExtractor, boolValue) {
- EXPECT_TRUE(ElementExtractor<bool>()(Element::create(true)));
- EXPECT_THROW(ElementExtractor<bool>()(Element::create("hola!")),
- TypeError);
-}
-
-// This test verifies that string value can be extracted.
-TEST(ElementExtractor, stringValue) {
- EXPECT_EQ("hola!", ElementExtractor<std::string>()(Element::create("hola!")));
- EXPECT_THROW(ElementExtractor<std::string>()(Element::create(false)),
- TypeError);
-}
-
-}
--- /dev/null
+// Copyright (C) 2019 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include <config.h>
+#include <cc/element_value.h>
+#include <gtest/gtest.h>
+
+using namespace isc::data;
+
+namespace {
+
+// This test verifies that integer value can be extracted.
+TEST(ElementValue, intValue) {
+ EXPECT_EQ(5, ElementValue<int>()(Element::create(5)));
+ EXPECT_THROW(ElementValue<int>()(Element::create("hola!")),
+ TypeError);
+}
+
+// This test verifies that double value can be extracted.
+TEST(ElementValue, doubleValue) {
+ EXPECT_EQ(1.4, ElementValue<double>()(Element::create(1.4)));
+ EXPECT_THROW(ElementValue<double>()(Element::create("hola!")),
+ TypeError);
+}
+
+// This test verifies that boolean value can be extracted.
+TEST(ElementValue, boolValue) {
+ EXPECT_TRUE(ElementValue<bool>()(Element::create(true)));
+ EXPECT_THROW(ElementValue<bool>()(Element::create("hola!")),
+ TypeError);
+}
+
+// This test verifies that string value can be extracted.
+TEST(ElementValue, stringValue) {
+ EXPECT_EQ("hola!", ElementValue<std::string>()(Element::create("hola!")));
+ EXPECT_THROW(ElementValue<std::string>()(Element::create(false)),
+ TypeError);
+}
+
+}
#include <asiolink/io_address.h>
#include <cc/cfg_to_element.h>
#include <cc/data.h>
-#include <cc/element_extractor.h>
+#include <cc/element_value.h>
#include <cc/stamped_element.h>
#include <cc/user_context.h>
#include <dhcp/classify.h>
namespace isc {
namespace data {
-/// @brief The @c ElementExtractor specialization for IOAddress.
+/// @brief The @c ElementValue specialization for IOAddress.
template<>
-class ElementExtractor<asiolink::IOAddress> {
+class ElementValue<asiolink::IOAddress> {
public:
/// @brief Function operator extracting an @c Element value as
if (global_param) {
// If there is a global parameter, convert it to the
// optional value of the given type and return.
- return (data::ElementExtractor<typename ReturnType::ValueType>()(global_param));
+ return (data::ElementValue<typename ReturnType::ValueType>()(global_param));
}
}
}