MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetSettingsList

Function GetSettingsList

src/util/settings.cpp:179–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179std::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
224bool OnlyHasDefaultSectionSetting(const Settings& settings, const std::string& section, const std::string& name)
225{

Callers 4

CheckValuesFunction · 0.85
BOOST_FIXTURE_TEST_CASEFunction · 0.85
GetArgsMethod · 0.85
GetSettingsListMethod · 0.85

Calls 9

MergeSettingsFunction · 0.85
isArrayMethod · 0.80
negatedMethod · 0.80
last_negatedMethod · 0.80
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45

Tested by 2

CheckValuesFunction · 0.68
BOOST_FIXTURE_TEST_CASEFunction · 0.68