json_parser_utils: Add parseUint16
Add new parseUint16() function to the json_parser_utils namespace. The
function parses a uint16_t value within a JSON element.
Tested:
* Ran automated test cases.
Change-Id: Id7c7c63f7a944a1910818927c3c70cb579f07dbd
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/json_parser_utils.hpp b/json_parser_utils.hpp
index 06ac19f..fa5e5c9 100644
--- a/json_parser_utils.hpp
+++ b/json_parser_utils.hpp
@@ -229,6 +229,21 @@
const std::map<std::string, std::string>& variables = NO_VARIABLES);
/**
+ * Parses a JSON element containing a 16-bit unsigned integer.
+ *
+ * Returns the corresponding C++ uint16_t value.
+ *
+ * Throws an exception if parsing fails.
+ *
+ * @param element JSON element
+ * @param variables variables map used to expand variables in element value
+ * @return uint16_t value
+ */
+uint16_t parseUint16(
+ const nlohmann::json& element,
+ const std::map<std::string, std::string>& variables = NO_VARIABLES);
+
+/**
* Parses a JSON element containing an unsigned integer.
*
* Returns the corresponding C++ unsigned int value.