Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/compound-option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ void wf::config::update_compound_from_section(
value[0] = suffix;
for (size_t i = 0; i < entries.size(); ++i)
{
if (const auto & entry_option =
section->get_option_or(entries[i]->get_prefix() + suffix);
if (const auto & entry_option = section->get_option_or(entries[i]->get_prefix() + suffix);
entry_option && !should_ignore_option(entry_option))
{
entry_option->priv->could_be_compound = true;
if (entries[i]->is_parsable(entry_option->get_value_str()))
{
value[i + 1] = entry_option->get_value_str();
Expand All @@ -83,9 +83,6 @@ void wf::config::update_compound_from_section(
value[i + 1] = *default_value;
} else
{
LOGE("The option ",
section->get_name() + "/" + entries[i]->get_prefix() + suffix,
" is neither specified nor has a default value");
value.clear();
break;
}
Expand All @@ -94,6 +91,14 @@ void wf::config::update_compound_from_section(
if (!value.empty())
{
stored_value.push_back(std::move(value));
for (size_t i = 0; i < entries.size(); ++i)
{
if (auto entry_option = section->get_option_or(entries[i]->get_prefix() + suffix))
{
// The option was used as part of the compound option, do not issue warning for it!
entry_option->priv->is_part_compound = true;
}
}
}
}

Expand Down
25 changes: 25 additions & 0 deletions src/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ void wf::config::load_configuration_options_from_string(
for (auto opt : section->get_registered_options())
{
opt->priv->option_in_config_file = (reloaded.count(opt) > 0);

opt->priv->is_part_compound = false; // will be re-set when updating compound options
opt->priv->could_be_compound = false; // will be re-set when updating compound options

if (!opt->priv->option_in_config_file && !opt->is_locked())
{
opt->reset_to_default();
Expand All @@ -373,6 +377,27 @@ void wf::config::load_configuration_options_from_string(
}
}
}

for (auto section : config.get_all_sections())
{
for (auto opt : section->get_registered_options())
{
if (!opt->priv->xml && !opt->priv->is_part_compound)
{
if (opt->priv->could_be_compound)
{
LOGW("Option ", section->get_name(), "/", opt->get_name(),
" could not be parsed as part of a compound option: missing entries or wrong type!");
} else
{
LOGW("Loaded option ", section->get_name(), "/", opt->get_name(),
", which does not belong to any registered plugin, nor could be parsed as a part of ",
"a compound list option. Make sure all the relevant XML files are installed and "
"that the option name is spelled correctly!");
}
}
}
}
}

std::string wf::config::save_configuration_options_to_string(
Expand Down
35 changes: 20 additions & 15 deletions src/option-impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,6 @@
#include <libxml/tree.h>
#include <stdint.h>

struct wf::config::option_base_t::impl
{
std::string name;
wf::safe_list_t<updated_callback_t*> updated_handlers;

// Number of times the option has been locked
int32_t lock_count = 0;

// Associated XML node
xmlNode *xml;

// Is option in config file?
bool option_in_config_file = false;
};

namespace wf
{
namespace config
Expand All @@ -37,3 +22,23 @@ void update_compound_from_section(compound_option_t& option,
const std::shared_ptr<section_t>& section);
}
}

struct wf::config::option_base_t::impl
{
std::string name;
wf::safe_list_t<updated_callback_t*> updated_handlers;

// Number of times the option has been locked
int32_t lock_count = 0;

// Associated XML node
xmlNode *xml = nullptr;

// Is option in config file?
bool option_in_config_file = false;

// Is option part of a successfully parsed compound option?
bool is_part_compound = false;
// Does this option match a compound option in part at least?
bool could_be_compound = false;
};
4 changes: 4 additions & 0 deletions test/file_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ TEST_CASE("wf::config::load_configuration_options_from_string")
EXPECT_LINE(log, "Error in file test:5");
EXPECT_LINE(log, "Error in file test:20");
EXPECT_LINE(log, "Error in file test:21");

// reset logging state for subsequent tests
wf::log::initialize_logging(std::cout, wf::log::LOG_LEVEL_DEBUG,
wf::log::LOG_COLOR_MODE_OFF);
}

TEST_CASE("wf::config::load_configuration_options_from_string - "
Expand Down
Loading