mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-05 17:43:35 +03:00
Merge pull request #1469 from rainers/multi_config
Allow different configurations in the ldc2.conf
This commit is contained in:
commit
f68ebbf1ec
4 changed files with 44 additions and 5 deletions
|
@ -162,7 +162,7 @@ bool ConfigFile::locate() {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ConfigFile::read(const char *explicitConfFile) {
|
||||
bool ConfigFile::read(const char *explicitConfFile, const char* section) {
|
||||
// explicitly provided by user in command line?
|
||||
if (explicitConfFile) {
|
||||
const std::string clPath = explicitConfFile;
|
||||
|
@ -192,14 +192,21 @@ bool ConfigFile::read(const char *explicitConfFile) {
|
|||
return false;
|
||||
}
|
||||
|
||||
config_setting_t *root = nullptr;
|
||||
if (section && *section)
|
||||
root = config_lookup(cfg, section);
|
||||
|
||||
// make sure there's a default group
|
||||
config_setting_t *root = config_lookup(cfg, "default");
|
||||
if (!root) {
|
||||
section = "default";
|
||||
root = config_lookup(cfg, section);
|
||||
}
|
||||
if (!root) {
|
||||
std::cerr << "no default settings in configuration file" << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (!config_setting_is_group(root)) {
|
||||
std::cerr << "default is not a group" << std::endl;
|
||||
std::cerr << section << " is not a group" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue