]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#490,!284] Renamed ElementExtractor to ElementValue.
authorMarcin Siodelski <marcin@isc.org>
Wed, 27 Mar 2019 19:11:28 +0000 (20:11 +0100)
committerMarcin Siodelski <marcin@isc.org>
Wed, 27 Mar 2019 19:45:14 +0000 (20:45 +0100)
Per review comments.

src/lib/cc/Makefile.am
src/lib/cc/element_value.h [moved from src/lib/cc/element_extractor.h with 87% similarity]
src/lib/cc/tests/Makefile.am
src/lib/cc/tests/element_extractor_unittests.cc [deleted file]
src/lib/cc/tests/element_value_unittests.cc [new file with mode: 0644]
src/lib/dhcpsrv/network.h

index 3f98f79adf34ab5a5fa16eb87dacc73682c6a6b1..134b62c5d0630ef178c5670d59ec2b173c8075d6 100644 (file)
@@ -6,7 +6,7 @@ AM_CXXFLAGS = $(KEA_CXXFLAGS)
 
 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
@@ -29,7 +29,7 @@ libkea_cc_include_HEADERS = \
        command_interpreter.h \
        data.h \
        dhcp_config_error.h \
-       element_extractor.h \
+       element_value.h \
        json_feed.h \
        simple_parser.h \
        stamped_element.h \
similarity index 87%
rename from src/lib/cc/element_extractor.h
rename to src/lib/cc/element_value.h
index ac8158ff1f6ee9dfcbb793071e1de9b75c56581a..964fd0ee9293502b8d2435c8582864389ec2d0ec 100644 (file)
@@ -4,8 +4,8 @@
 // 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>
@@ -39,7 +39,7 @@ namespace data {
 ///
 /// @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
@@ -51,9 +51,9 @@ public:
     }
 };
 
-/// @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
@@ -65,9 +65,9 @@ public:
     }
 };
 
-/// @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
@@ -80,9 +80,9 @@ public:
 
 };
 
-/// @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
@@ -97,4 +97,4 @@ public:
 } // end of namespace isc::data
 } // end of namespace isc
 
-#endif // ELEMENT_EXTRACTOR_H
+#endif // ELEMENT_VALUE_H
index 2682c5a15d2acb88197278a79109a5b199909d96..31a5d5e25d956ff7a97c905e271164a3f4758cc7 100644 (file)
@@ -17,7 +17,7 @@ TESTS += run_unittests
 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
diff --git a/src/lib/cc/tests/element_extractor_unittests.cc b/src/lib/cc/tests/element_extractor_unittests.cc
deleted file mode 100644 (file)
index da327a4..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-// 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);
-}
-
-}
diff --git a/src/lib/cc/tests/element_value_unittests.cc b/src/lib/cc/tests/element_value_unittests.cc
new file mode 100644 (file)
index 0000000..e284440
--- /dev/null
@@ -0,0 +1,43 @@
+// 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);
+}
+
+}
index 9a0f8701be9281ad6eb32f511cdfd78934493a55..1793baf81bf30d724865daa4d30301e64969e544 100644 (file)
@@ -10,7 +10,7 @@
 #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>
@@ -28,9 +28,9 @@
 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
@@ -519,7 +519,7 @@ protected:
                     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));
                     }
                 }
             }