core: Extend ConfigFile to support passing a parsed ConfigSection
Change-Id: I955220c08d8e6ed07c77d82149f6ff3ae48b2b12
Refs: #2495
diff --git a/core/config-file.cpp b/core/config-file.cpp
index 5887c2b..1079666 100644
--- a/core/config-file.cpp
+++ b/core/config-file.cpp
@@ -109,6 +109,13 @@
}
void
+ConfigFile::parse(const ConfigSection& config, bool isDryRun, const std::string& filename)
+{
+ m_global = config;
+ process(isDryRun, filename);
+}
+
+void
ConfigFile::process(bool isDryRun, const std::string& filename)
{
BOOST_ASSERT(!filename.empty());
diff --git a/core/config-file.hpp b/core/config-file.hpp
index b7dd886..9991484 100644
--- a/core/config-file.hpp
+++ b/core/config-file.hpp
@@ -91,7 +91,7 @@
/**
* \param input configuration (as a string) to parse
* \param isDryRun true if performing a dry run of configuration, false otherwise
- * \param filename optional convenience argument to provide more detailed error messages
+ * \param filename logical filename of the config file, can appear in error messages
* \throws ConfigFile::Error if file not found
* \throws ConfigFile::Error if parse error
*/
@@ -101,12 +101,21 @@
/**
* \param input stream to parse
* \param isDryRun true if performing a dry run of configuration, false otherwise
- * \param filename optional convenience argument to provide more detailed error messages
+ * \param filename logical filename of the config file, can appear in error messages
* \throws ConfigFile::Error if parse error
*/
void
parse(std::istream& input, bool isDryRun, const std::string& filename);
+ /**
+ * \param config ConfigSection that needs to be processed
+ * \param isDryRun true if performing a dry run of configuration, false otherwise
+ * \param filename logical filename of the config file, can appear in error messages
+ * \throws ConfigFile::Error if parse error
+ */
+ void
+ parse(const ConfigSection& config, bool isDryRun, const std::string& filename);
+
private:
void