configuration: initialize undefined variables after all files were parsed

master
Andrzej Rybczak 11 years ago
parent 27cd86e063
commit d7998ef144
  1. 2
      src/settings.cpp
  2. 7
      src/utility/option_parser.cpp
  3. 1
      src/utility/option_parser.h

@ -678,7 +678,7 @@ bool Configuration::read(const std::vector<std::string> &config_paths)
std::clog << "Reading configuration from " << config_path << "...\n";
return p.run(f);
}
);
) && p.initialize_undefined();
}
/* vim: set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab : */

@ -66,6 +66,11 @@ bool option_parser::run(std::istream &is)
}
}
}
return true;
}
bool option_parser::initialize_undefined()
{
for (auto &p : m_parsers)
{
if (!p.second.defined())
@ -73,7 +78,7 @@ bool option_parser::run(std::istream &is)
try {
p.second.run_default();
} catch (std::exception &e) {
std::cerr << "Error while finalizing option \"" << p.first << "\": " << e.what() << "\n";
std::cerr << "Error while initializing option \"" << p.first << "\": " << e.what() << "\n";
return false;
}
}

@ -140,6 +140,7 @@ struct option_parser
}
bool run(std::istream &is);
bool initialize_undefined();
private:
std::unordered_map<std::string, worker> m_parsers;

Loading…
Cancel
Save