| 254 | } |
| 255 | |
| 256 | bool OnlyHasDefaultSectionSetting(const Settings& settings, const std::string& section, const std::string& name) |
| 257 | { |
| 258 | bool has_default_section_setting = false; |
| 259 | bool has_other_setting = false; |
| 260 | MergeSettings(settings, section, name, [&](SettingsSpan span, Source source) { |
| 261 | if (span.empty()) return; |
| 262 | else if (source == Source::CONFIG_FILE_DEFAULT_SECTION) has_default_section_setting = true; |
| 263 | else has_other_setting = true; |
| 264 | }); |
| 265 | // If a value is set in the default section and not explicitly overwritten by the |
| 266 | // user on the command line or in a different section, then we want to enable |
| 267 | // warnings about the value being ignored. |
| 268 | return has_default_section_setting && !has_other_setting; |
| 269 | } |
| 270 | |
| 271 | SettingsSpan::SettingsSpan(const std::vector<SettingsValue>& vec) noexcept : SettingsSpan(vec.data(), vec.size()) {} |
| 272 | const SettingsValue* SettingsSpan::begin() const { return data + negated(); } |