From ab3d0a4825f188cb183abbcadc5d318a92da4d39 Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Fri, 10 Feb 2017 13:25:26 +0100 Subject: [PATCH] [5126] Shared getUint* in simple_parser.h --- src/bin/dhcp4/json_config_parser.cc | 26 --------------- src/bin/dhcp6/json_config_parser.cc | 38 ---------------------- src/lib/cc/simple_parser.h | 38 ++++++++++++++++++++++ src/lib/cc/tests/simple_parser_unittest.cc | 11 ++----- src/lib/dhcpsrv/parsers/dhcp_parsers.cc | 6 ---- src/lib/dhcpsrv/parsers/dhcp_parsers.h | 10 ------ 6 files changed, 41 insertions(+), 88 deletions(-) diff --git a/src/bin/dhcp4/json_config_parser.cc b/src/bin/dhcp4/json_config_parser.cc index 1ab22bfef8..adfbbad849 100644 --- a/src/bin/dhcp4/json_config_parser.cc +++ b/src/bin/dhcp4/json_config_parser.cc @@ -342,32 +342,6 @@ public: uint16_t dhcp4o6_port = getUint16(global, "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(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(scope, name)); - } }; } // anonymous namespace diff --git a/src/bin/dhcp6/json_config_parser.cc b/src/bin/dhcp6/json_config_parser.cc index 3521174b3e..7a51daf8b3 100644 --- a/src/bin/dhcp6/json_config_parser.cc +++ b/src/bin/dhcp6/json_config_parser.cc @@ -212,18 +212,6 @@ public: 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(scope, name)); - } - /// Pointer to the created pool object. isc::dhcp::Pool6Ptr pool_; @@ -548,32 +536,6 @@ public: uint16_t dhcp4o6_port = getUint16(global, "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(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(scope, name)); - } }; } // anonymous namespace diff --git a/src/lib/cc/simple_parser.h b/src/lib/cc/simple_parser.h index 524449806e..3ff60b7bb8 100644 --- a/src/lib/cc/simple_parser.h +++ b/src/lib/cc/simple_parser.h @@ -203,6 +203,44 @@ protected: << "' (" << 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(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(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(scope, name)); + } }; }; diff --git a/src/lib/cc/tests/simple_parser_unittest.cc b/src/lib/cc/tests/simple_parser_unittest.cc index dfe384c990..0a8bf57988 100644 --- a/src/lib/cc/tests/simple_parser_unittest.cc +++ b/src/lib/cc/tests/simple_parser_unittest.cc @@ -58,14 +58,9 @@ public: class SimpleParserClassTest : public SimpleParser { 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(scope, name)); - } + + /// Make getUint8 public + using SimpleParser::getUint8; /// @brief Instantiation of getAndConvert /// diff --git a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc index ad0d6de711..4730c95b91 100644 --- a/src/lib/dhcpsrv/parsers/dhcp_parsers.cc +++ b/src/lib/dhcpsrv/parsers/dhcp_parsers.cc @@ -1065,12 +1065,6 @@ SubnetConfigParser::createSubnet(ConstElementPtr params) { //**************************** D2ClientConfigParser ********************** -uint32_t -D2ClientConfigParser::getUint32(ConstElementPtr scope, - const std::string& name) { - return (getIntType(scope, name)); -} - // Can't use a constructor as a function namespace { IOAddress buildIOAddress(const std::string& str) { return (IOAddress(str)); } diff --git a/src/lib/dhcpsrv/parsers/dhcp_parsers.h b/src/lib/dhcpsrv/parsers/dhcp_parsers.h index 67f253a5bf..6d84cb731c 100644 --- a/src/lib/dhcpsrv/parsers/dhcp_parsers.h +++ b/src/lib/dhcpsrv/parsers/dhcp_parsers.h @@ -889,16 +889,6 @@ public: 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 /// /// Instantiation of getAndConvert() to IOAddress -- 2.47.2