pseq: Add variable support to config file parser
Add template variable support to the functions that parse the
phosphor-power-sequencer configuration file.
Tested:
* Ran automated tests.
Change-Id: I649d66de520e9138fc3a5dc34de61cc4cb03fe53
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
diff --git a/phosphor-power-sequencer/src/config_file_parser.hpp b/phosphor-power-sequencer/src/config_file_parser.hpp
index a57083e..0f5fe3c 100644
--- a/phosphor-power-sequencer/src/config_file_parser.hpp
+++ b/phosphor-power-sequencer/src/config_file_parser.hpp
@@ -86,9 +86,11 @@
* Throws an exception if parsing fails.
*
* @param element JSON element
+ * @param variables variables map used to expand variables in element value
* @return GPIO object
*/
-GPIO parseGPIO(const nlohmann::json& element);
+GPIO parseGPIO(const nlohmann::json& element,
+ const std::map<std::string, std::string>& variables);
/**
* Parses a JSON element containing an i2c_interface object.
@@ -113,9 +115,12 @@
* Throws an exception if parsing fails.
*
* @param element JSON element
+ * @param variables variables map used to expand variables in element value
* @return Rail object
*/
-std::unique_ptr<Rail> parseRail(const nlohmann::json& element);
+std::unique_ptr<Rail> parseRail(
+ const nlohmann::json& element,
+ const std::map<std::string, std::string>& variables);
/**
* Parses a JSON element containing an array of rails.
@@ -125,10 +130,12 @@
* Throws an exception if parsing fails.
*
* @param element JSON element
+ * @param variables variables map used to expand variables in element value
* @return vector of Rail objects
*/
std::vector<std::unique_ptr<Rail>> parseRailArray(
- const nlohmann::json& element);
+ const nlohmann::json& element,
+ const std::map<std::string, std::string>& variables);
/**
* Parses the JSON root element of the entire configuration file.