| 382 | } |
| 383 | |
| 384 | void 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 | |
| 425 | bool Config::isOptionValid(const OptionProto& option) |
| 426 | { |
nothing calls this directly
no test coverage detected