* Find the set-integer value MANYofMANY type in a string * @param many full domain of values the MANYofMANY setting can have * @param str the current string value of the setting, each individual * of separated by a whitespace, tab or | character * @return the 'fully' set integer, or std::nullopt if a set is not found */
| 219 | * @return the 'fully' set integer, or std::nullopt if a set is not found |
| 220 | */ |
| 221 | static std::optional<uint32_t> LookupManyOfMany(std::span<const std::string_view> many, std::string_view str) |
| 222 | { |
| 223 | static const std::string_view separators{" \t|"}; |
| 224 | |
| 225 | uint32_t res = 0; |
| 226 | StringConsumer consumer{str}; |
| 227 | while (consumer.AnyBytesLeft()) { |
| 228 | /* skip "whitespace" */ |
| 229 | consumer.SkipUntilCharNotIn(separators); |
| 230 | |
| 231 | std::string_view value = consumer.ReadUntilCharIn(separators); |
| 232 | if (value.empty()) break; |
| 233 | |
| 234 | auto r = OneOfManySettingDesc::ParseSingleValue(value, many); |
| 235 | if (!r.has_value()) return r; |
| 236 | |
| 237 | SetBit(res, *r); // value found, set it |
| 238 | } |
| 239 | return res; |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * Parse a string into a vector of uint32s. |
no test coverage detected