mgmt: TablesConfigSection constructor accepts Forwarder&
refs #2181
Change-Id: I1a87dd573f25f3806bc1b1f3c60ec9eef0eca4e3
diff --git a/core/config-file.cpp b/core/config-file.cpp
index 19bf1cb..b9f40b1 100644
--- a/core/config-file.cpp
+++ b/core/config-file.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2016, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -59,10 +59,10 @@
}
bool
-ConfigFile::parseYesNo(const ConfigSection::value_type& option,
+ConfigFile::parseYesNo(const ConfigSection& node, const std::string& key,
const std::string& sectionName)
{
- auto value = option.second.get_value<std::string>();
+ auto value = node.get_value<std::string>();
if (value == "yes") {
return true;
@@ -72,7 +72,7 @@
}
BOOST_THROW_EXCEPTION(Error("Invalid value \"" + value + "\" for option \"" +
- option.first + "\" in \"" + sectionName + "\" section"));
+ key + "\" in \"" + sectionName + "\" section"));
}
void
@@ -85,14 +85,10 @@
void
ConfigFile::parse(const std::string& filename, bool isDryRun)
{
- std::ifstream inputFile;
- inputFile.open(filename.c_str());
- if (!inputFile.good() || !inputFile.is_open())
- {
- std::string msg = "Failed to read configuration file: ";
- msg += filename;
- BOOST_THROW_EXCEPTION(Error(msg));
- }
+ std::ifstream inputFile(filename);
+ if (!inputFile.good() || !inputFile.is_open()) {
+ BOOST_THROW_EXCEPTION(Error("Failed to read configuration file: " + filename));
+ }
parse(inputFile, isDryRun, filename);
inputFile.close();
}
@@ -107,18 +103,16 @@
void
ConfigFile::parse(std::istream& input, bool isDryRun, const std::string& filename)
{
- try
- {
- boost::property_tree::read_info(input, m_global);
- }
- catch (const boost::property_tree::info_parser_error& error)
- {
- std::stringstream msg;
- msg << "Failed to parse configuration file";
- msg << " " << filename;
- msg << " " << error.message() << " line " << error.line();
- BOOST_THROW_EXCEPTION(Error(msg.str()));
- }
+ try {
+ boost::property_tree::read_info(input, m_global);
+ }
+ catch (const boost::property_tree::info_parser_error& error) {
+ std::stringstream msg;
+ msg << "Failed to parse configuration file";
+ msg << " " << filename;
+ msg << " " << error.message() << " line " << error.line();
+ BOOST_THROW_EXCEPTION(Error(msg.str()));
+ }
process(isDryRun, filename);
}
@@ -144,7 +138,7 @@
for (const auto& i : m_global) {
try {
- ConfigSectionHandler subscriber = m_subscriptions.at(i.first);
+ const ConfigSectionHandler& subscriber = m_subscriptions.at(i.first);
subscriber(i.second, isDryRun, filename);
}
catch (const std::out_of_range&) {
@@ -153,4 +147,4 @@
}
}
-}
+} // namespace nfd