From ef3ba12cb6a27cd668ec86840b78bd0184d0df32 Mon Sep 17 00:00:00 2001 From: scrawl Date: Fri, 30 Jan 2015 22:11:26 +0100 Subject: [PATCH] Add silent mode to ConfigurationManager, used by essimporter --- apps/essimporter/main.cpp | 2 +- components/files/configurationmanager.cpp | 12 ++++++++---- components/files/configurationmanager.hpp | 4 +++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/essimporter/main.cpp b/apps/essimporter/main.cpp index ae4b36ecd..a4ad114ec 100644 --- a/apps/essimporter/main.cpp +++ b/apps/essimporter/main.cpp @@ -45,7 +45,7 @@ int main(int argc, char** argv) bpo::notify(variables); - Files::ConfigurationManager cfgManager; + Files::ConfigurationManager cfgManager(true); cfgManager.readConfiguration(variables, desc); std::string essFile = variables["mwsave"].as(); diff --git a/components/files/configurationmanager.cpp b/components/files/configurationmanager.cpp index 942f47d4e..e321b5814 100644 --- a/components/files/configurationmanager.cpp +++ b/components/files/configurationmanager.cpp @@ -27,8 +27,9 @@ const char* const localToken = "?local?"; const char* const userDataToken = "?userdata?"; const char* const globalToken = "?global?"; -ConfigurationManager::ConfigurationManager() +ConfigurationManager::ConfigurationManager(bool silent) : mFixedPath(applicationName) + , mSilent(silent) { setupTokensMapping(); @@ -129,7 +130,8 @@ void ConfigurationManager::loadConfig(const boost::filesystem::path& path, cfgFile /= std::string(openmwCfgFile); if (boost::filesystem::is_regular_file(cfgFile)) { - std::cout << "Loading config file: " << cfgFile.string() << "... "; + if (!mSilent) + std::cout << "Loading config file: " << cfgFile.string() << "... "; boost::filesystem::ifstream configFileStream(cfgFile); if (configFileStream.is_open()) @@ -137,11 +139,13 @@ void ConfigurationManager::loadConfig(const boost::filesystem::path& path, boost::program_options::store(boost::program_options::parse_config_file( configFileStream, description, true), variables); - std::cout << "done." << std::endl; + if (!mSilent) + std::cout << "done." << std::endl; } else { - std::cout << "failed." << std::endl; + if (!mSilent) + std::cout << "failed." << std::endl; } } } diff --git a/components/files/configurationmanager.hpp b/components/files/configurationmanager.hpp index 35144fe04..b0b7fea9a 100644 --- a/components/files/configurationmanager.hpp +++ b/components/files/configurationmanager.hpp @@ -25,7 +25,7 @@ namespace Files */ struct ConfigurationManager { - ConfigurationManager(); + ConfigurationManager(bool silent=false); /// @param silent Emit log messages to cout? virtual ~ConfigurationManager(); void readConfiguration(boost::program_options::variables_map& variables, @@ -69,6 +69,8 @@ struct ConfigurationManager boost::filesystem::path mLogPath; TokensMappingContainer mTokensMapping; + + bool mSilent; }; } /* namespace Cfg */