MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / checkOptionValid

Method checkOptionValid

lib/config/config.cc:384–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

382}
383
384void Config::checkOptionValid(const OptionProto& option)
385{
386 for (const auto& req : option.prerequisite())
387 {
388 bool matched = false;
389 try
390 {
391 auto value = get(req.key());
392 for (auto requiredValue : req.value())
393 matched |= (requiredValue == value);
394 }
395 catch (const ProtoPathNotFoundException e)
396 {
397 /* This field isn't available, therefore it
398 * cannot match. */
399 }
400
401 if (!matched)
402 {
403 std::stringstream ss;
404 ss << '[';
405 bool first = true;
406 for (auto requiredValue : req.value())
407 {
408 if (!first)
409 ss << ", ";
410 ss << quote(requiredValue);
411 first = false;
412 }
413 ss << ']';
414
415 throw InapplicableOptionException(
416 fmt::format("option '{}' is inapplicable to this configuration "
417 "because {}={} could not be met",
418 option.name(),
419 req.key(),
420 ss.str()));
421 }
422 }
423}
424
425bool Config::isOptionValid(const OptionProto& option)
426{

Callers

nothing calls this directly

Calls 4

quoteFunction · 0.85
keyMethod · 0.80
valueMethod · 0.45

Tested by

no test coverage detected