* Find the index value of a ONEofMANY type in a string * @param str the current value of the setting for which a value needs found * @param many full domain of values the ONEofMANY setting can have * @return the integer index of the full-list, or std::nullopt if not found */
| 186 | * @return the integer index of the full-list, or std::nullopt if not found |
| 187 | */ |
| 188 | std::optional<uint32_t> OneOfManySettingDesc::ParseSingleValue(std::string_view str, std::span<const std::string_view> many) |
| 189 | { |
| 190 | StringConsumer consumer{str}; |
| 191 | auto digit = consumer.TryReadIntegerBase<uint32_t>(10); |
| 192 | /* check if it's an integer */ |
| 193 | if (digit.has_value()) return digit; |
| 194 | |
| 195 | auto it = std::ranges::find(many, str); |
| 196 | if (it == many.end()) return std::nullopt; |
| 197 | return static_cast<uint32_t>(it - many.begin()); |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * Find whether a string was a boolean true or a boolean false. |