| 81 | } // namespace |
| 82 | |
| 83 | std::optional<OptionMatch> find_option_match( |
| 84 | const std::unordered_map<std::string, std::string> & options, |
| 85 | std::initializer_list<std::string_view> keys) { |
| 86 | std::optional<OptionMatch> match; |
| 87 | for (const std::string_view key : keys) { |
| 88 | const auto it = options.find(std::string(key)); |
| 89 | if (it != options.end() && !it->second.empty()) { |
| 90 | if (match.has_value()) { |
| 91 | if (match->value != it->second) { |
| 92 | throw std::runtime_error( |
| 93 | "conflicting option values for " + match->key + " and " + std::string(key)); |
| 94 | } |
| 95 | continue; |
| 96 | } |
| 97 | match = OptionMatch{std::string(key), it->second}; |
| 98 | } |
| 99 | } |
| 100 | return match; |
| 101 | } |
| 102 | |
| 103 | std::optional<std::string> find_option( |
| 104 | const std::unordered_map<std::string, std::string> & options, |
no test coverage detected