Browse Source

[5126] Shared getUint* in simple_parser.h

Francis Dupont 8 years ago
parent
commit
ab3d0a4825

+ 0 - 26
src/bin/dhcp4/json_config_parser.cc

@@ -342,32 +342,6 @@ public:
         uint16_t dhcp4o6_port = getUint16(global, "dhcp4o6-port");
         uint16_t dhcp4o6_port = getUint16(global, "dhcp4o6-port");
         cfg->setDhcp4o6Port(dhcp4o6_port);
         cfg->setDhcp4o6Port(dhcp4o6_port);
     }
     }
-
-private:
-
-    /// @brief Returns a value converted to uint32_t
-    ///
-    /// Instantiation of getIntType() to uint32_t
-    ///
-    /// @param scope specified parameter will be extracted from this scope
-    /// @param name name of the parameter
-    /// @return an uint32_t value
-    uint32_t getUint32(isc::data::ConstElementPtr scope,
-                       const std::string& name) {
-        return (getIntType<uint32_t>(scope, name));
-    }
-
-    /// @brief Returns a value converted to uint16_t
-    ///
-    /// Instantiation of getIntType() to uint16_t
-    ///
-    /// @param scope specified parameter will be extracted from this scope
-    /// @param name name of the parameter
-    /// @return an uint16_t value
-    uint16_t getUint16(isc::data::ConstElementPtr scope,
-                       const std::string& name) {
-        return (getIntType<uint16_t>(scope, name));
-    }
 };
 };
 
 
 } // anonymous namespace
 } // anonymous namespace

+ 0 - 38
src/bin/dhcp6/json_config_parser.cc

@@ -212,18 +212,6 @@ public:
 
 
 private:
 private:
 
 
-    /// @brief Get an uint8_t value
-    ///
-    /// Instantiation of getIntType() to uint8_t
-    ///
-    /// @param scope specified parameter will be extracted from this scope
-    /// @param name name of the parameter
-    /// @return uint8_t value
-    /// @throw isc::dhcp::DhcpConfigError when it is not an uint8_t
-    uint8_t getUint8(ConstElementPtr scope, const std::string& name) {
-        return (getIntType<uint8_t>(scope, name));
-    }
-
     /// Pointer to the created pool object.
     /// Pointer to the created pool object.
     isc::dhcp::Pool6Ptr pool_;
     isc::dhcp::Pool6Ptr pool_;
 
 
@@ -548,32 +536,6 @@ public:
         uint16_t dhcp4o6_port = getUint16(global, "dhcp4o6-port");
         uint16_t dhcp4o6_port = getUint16(global, "dhcp4o6-port");
         srv_config->setDhcp4o6Port(dhcp4o6_port);
         srv_config->setDhcp4o6Port(dhcp4o6_port);
     }
     }
-
-private:
-
-    /// @brief Returns a value converted to uint32_t
-    ///
-    /// Instantiation of getIntType() to uint32_t
-    ///
-    /// @param scope specified parameter will be extracted from this scope
-    /// @param name name of the parameter
-    /// @return an uint32_t value
-    uint32_t getUint32(isc::data::ConstElementPtr scope,
-                       const std::string& name) {
-        return (getIntType<uint32_t>(scope, name));
-    }
-
-    /// @brief Returns a value converted to uint16_t
-    ///
-    /// Instantiation of getIntType() to uint16_t
-    ///
-    /// @param scope specified parameter will be extracted from this scope
-    /// @param name name of the parameter
-    /// @return an uint16_t value
-    uint16_t getUint16(isc::data::ConstElementPtr scope,
-                       const std::string& name) {
-        return (getIntType<uint16_t>(scope, name));
-    }
 };
 };
 
 
 } // anonymous namespace
 } // anonymous namespace

+ 38 - 0
src/lib/cc/simple_parser.h

@@ -203,6 +203,44 @@ protected:
                       << "' (" << getPosition(name, scope) << ")");
                       << "' (" << getPosition(name, scope) << ")");
         }
         }
     }
     }
+
+    /// @brief Returns a value converted to uint32_t
+    ///
+    /// Instantiation of getIntType() to uint32_t
+    ///
+    /// @param scope specified parameter will be extracted from this scope
+    /// @param name name of the parameter
+    /// @return an uint32_t value
+    /// @throw isc::dhcp::DhcpConfigError when it is not an uint32_t
+    uint32_t getUint32(isc::data::ConstElementPtr scope,
+                       const std::string& name) {
+        return (getIntType<uint32_t>(scope, name));
+    }
+
+    /// @brief Returns a value converted to uint16_t
+    ///
+    /// Instantiation of getIntType() to uint16_t
+    ///
+    /// @param scope specified parameter will be extracted from this scope
+    /// @param name name of the parameter
+    /// @return an uint16_t value
+    /// @throw isc::dhcp::DhcpConfigError when it is not an uint16_t
+    uint16_t getUint16(isc::data::ConstElementPtr scope,
+                       const std::string& name) {
+        return (getIntType<uint16_t>(scope, name));
+    }
+
+    /// @brief Get an uint8_t value
+    ///
+    /// Instantiation of getIntType() to uint8_t
+    ///
+    /// @param scope specified parameter will be extracted from this scope
+    /// @param name name of the parameter
+    /// @return uint8_t value
+    /// @throw isc::dhcp::DhcpConfigError when it is not an uint8_t
+    uint8_t getUint8(ConstElementPtr scope, const std::string& name) {
+        return (getIntType<uint8_t>(scope, name));
+    }
 };
 };
 
 
 };
 };

+ 3 - 8
src/lib/cc/tests/simple_parser_unittest.cc

@@ -58,14 +58,9 @@ public:
 
 
 class SimpleParserClassTest : public SimpleParser {
 class SimpleParserClassTest : public SimpleParser {
 public:
 public:
-    /// @brief Instantiation of getIntType for uint8_t
-    ///
-    /// @param scope specified parameter will be extracted from this scope
-    /// @param name name of the parameter for error report
-    /// @return an uint8_t value
-    uint8_t getUint8(ConstElementPtr scope, const std::string& name) {
-        return (getIntType<uint8_t>(scope, name));
-    }
+
+    /// Make getUint8 public
+    using SimpleParser::getUint8;
 
 
     /// @brief Instantiation of getAndConvert
     /// @brief Instantiation of getAndConvert
     ///
     ///

+ 0 - 6
src/lib/dhcpsrv/parsers/dhcp_parsers.cc

@@ -1065,12 +1065,6 @@ SubnetConfigParser::createSubnet(ConstElementPtr params) {
 
 
 //**************************** D2ClientConfigParser **********************
 //**************************** D2ClientConfigParser **********************
 
 
-uint32_t
-D2ClientConfigParser::getUint32(ConstElementPtr scope,
-                                const std::string& name) {
-    return (getIntType<uint32_t>(scope, name));
-}
-
 // Can't use a constructor as a function
 // Can't use a constructor as a function
 namespace {
 namespace {
 IOAddress buildIOAddress(const std::string& str) { return (IOAddress(str)); }
 IOAddress buildIOAddress(const std::string& str) { return (IOAddress(str)); }

+ 0 - 10
src/lib/dhcpsrv/parsers/dhcp_parsers.h

@@ -889,16 +889,6 @@ public:
 
 
 private:
 private:
 
 
-    /// @brief Returns a value converted to uint32_t
-    ///
-    /// Instantiation of getIntType() to uint32_t
-    ///
-    /// @param scope specified parameter will be extracted from this scope
-    /// @param name name of the parameter
-    /// @return an uint32_t value
-    uint32_t
-    getUint32(isc::data::ConstElementPtr scope, const std::string& name);
-
     /// @brief Returns a value converted to IOAddress
     /// @brief Returns a value converted to IOAddress
     ///
     ///
     /// Instantiation of getAndConvert() to IOAddress
     /// Instantiation of getAndConvert() to IOAddress