| 177 | } |
| 178 | |
| 179 | std::vector<SettingsValue> GetSettingsList(const Settings& settings, |
| 180 | const std::string& section, |
| 181 | const std::string& name, |
| 182 | bool ignore_default_section_config) |
| 183 | { |
| 184 | std::vector<SettingsValue> result; |
| 185 | bool done = false; // Done merging any more settings sources. |
| 186 | bool prev_negated_empty = false; |
| 187 | MergeSettings(settings, section, name, [&](SettingsSpan span, Source source) { |
| 188 | // Weird behavior preserved for backwards compatibility: Apply config |
| 189 | // file settings even if negated on command line. Negating a setting on |
| 190 | // command line will ignore earlier settings on the command line and |
| 191 | // ignore settings in the config file, unless the negated command line |
| 192 | // value is followed by non-negated value, in which case config file |
| 193 | // settings will be brought back from the dead (but earlier command |
| 194 | // line settings will still be ignored). |
| 195 | const bool add_zombie_config_values = |
| 196 | (source == Source::CONFIG_FILE_NETWORK_SECTION || source == Source::CONFIG_FILE_DEFAULT_SECTION) && |
| 197 | !prev_negated_empty; |
| 198 | |
| 199 | // Ignore settings in default config section if requested. |
| 200 | if (ignore_default_section_config && source == Source::CONFIG_FILE_DEFAULT_SECTION) return; |
| 201 | |
| 202 | // Add new settings to the result if isn't already complete, or if the |
| 203 | // values are zombies. |
| 204 | if (!done || add_zombie_config_values) { |
| 205 | for (const auto& value : span) { |
| 206 | if (value.isArray()) { |
| 207 | result.insert(result.end(), value.getValues().begin(), value.getValues().end()); |
| 208 | } else { |
| 209 | result.push_back(value); |
| 210 | } |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | // If a setting was negated, or if a setting was forced, set |
| 215 | // done to true to ignore any later lower priority settings. |
| 216 | done |= span.negated() > 0 || source == Source::FORCED; |
| 217 | |
| 218 | // Update the negated and empty state used for the zombie values check. |
| 219 | prev_negated_empty |= span.last_negated() && result.empty(); |
| 220 | }); |
| 221 | return result; |
| 222 | } |
| 223 | |
| 224 | bool OnlyHasDefaultSectionSetting(const Settings& settings, const std::string& section, const std::string& name) |
| 225 | { |