| 209 | } |
| 210 | |
| 211 | std::vector<SettingsValue> GetSettingsList(const Settings& settings, |
| 212 | const std::string& section, |
| 213 | const std::string& name, |
| 214 | bool ignore_default_section_config) |
| 215 | { |
| 216 | std::vector<SettingsValue> result; |
| 217 | bool done = false; // Done merging any more settings sources. |
| 218 | bool prev_negated_empty = false; |
| 219 | MergeSettings(settings, section, name, [&](SettingsSpan span, Source source) { |
| 220 | // Weird behavior preserved for backwards compatibility: Apply config |
| 221 | // file settings even if negated on command line. Negating a setting on |
| 222 | // command line will ignore earlier settings on the command line and |
| 223 | // ignore settings in the config file, unless the negated command line |
| 224 | // value is followed by non-negated value, in which case config file |
| 225 | // settings will be brought back from the dead (but earlier command |
| 226 | // line settings will still be ignored). |
| 227 | const bool add_zombie_config_values = |
| 228 | (source == Source::CONFIG_FILE_NETWORK_SECTION || source == Source::CONFIG_FILE_DEFAULT_SECTION) && |
| 229 | !prev_negated_empty; |
| 230 | |
| 231 | // Ignore settings in default config section if requested. |
| 232 | if (ignore_default_section_config && source == Source::CONFIG_FILE_DEFAULT_SECTION) return; |
| 233 | |
| 234 | // Add new settings to the result if isn't already complete, or if the |
| 235 | // values are zombies. |
| 236 | if (!done || add_zombie_config_values) { |
| 237 | for (const auto& value : span) { |
| 238 | if (value.isArray()) { |
| 239 | result.insert(result.end(), value.getValues().begin(), value.getValues().end()); |
| 240 | } else { |
| 241 | result.push_back(value); |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | // If a setting was negated, or if a setting was forced, set |
| 247 | // done to true to ignore any later lower priority settings. |
| 248 | done |= span.negated() > 0 || source == Source::FORCED; |
| 249 | |
| 250 | // Update the negated and empty state used for the zombie values check. |
| 251 | prev_negated_empty |= span.last_negated() && result.empty(); |
| 252 | }); |
| 253 | return result; |
| 254 | } |
| 255 | |
| 256 | bool OnlyHasDefaultSectionSetting(const Settings& settings, const std::string& section, const std::string& name) |
| 257 | { |