| 31 | //! specific logic for how to merge the sources. |
| 32 | template <typename Fn> |
| 33 | static void MergeSettings(const Settings& settings, const std::string& section, const std::string& name, Fn&& fn) |
| 34 | { |
| 35 | // Merge in the forced settings |
| 36 | if (auto* value = FindKey(settings.forced_settings, name)) { |
| 37 | fn(SettingsSpan(*value), Source::FORCED); |
| 38 | } |
| 39 | // Merge in the command-line options |
| 40 | if (auto* values = FindKey(settings.command_line_options, name)) { |
| 41 | fn(SettingsSpan(*values), Source::COMMAND_LINE); |
| 42 | } |
| 43 | // Merge in the read-write settings |
| 44 | if (const SettingsValue* value = FindKey(settings.rw_settings, name)) { |
| 45 | fn(SettingsSpan(*value), Source::RW_SETTINGS); |
| 46 | } |
| 47 | // Merge in the network-specific section of the config file |
| 48 | if (!section.empty()) { |
| 49 | if (auto* map = FindKey(settings.ro_config, section)) { |
| 50 | if (auto* values = FindKey(*map, name)) { |
| 51 | fn(SettingsSpan(*values), Source::CONFIG_FILE_NETWORK_SECTION); |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | // Merge in the default section of the config file |
| 56 | if (auto* map = FindKey(settings.ro_config, "")) { |
| 57 | if (auto* values = FindKey(*map, name)) { |
| 58 | fn(SettingsSpan(*values), Source::CONFIG_FILE_DEFAULT_SECTION); |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | } // namespace |
| 63 | |
| 64 | bool ReadSettings(const fs::path& path, std::map<std::string, SettingsValue>& values, std::vector<std::string>& errors) |
no test coverage detected