| 250 | |
| 251 | |
| 252 | template <typename T> std::optional<T> parse_vector(std::string_view s) |
| 253 | { |
| 254 | std::regex rx("[\\s+,|:]"); |
| 255 | std::cregex_token_iterator it{ s.data(), s.data() + s.size(), rx, -1 }, last; |
| 256 | |
| 257 | T value; uint8_t dim = 0; |
| 258 | for (; it != last; ++it) |
| 259 | { |
| 260 | if (it->length() == 0) |
| 261 | continue; |
| 262 | |
| 263 | if (dim >= T::DIM) |
| 264 | return std::optional<T>(); |
| 265 | |
| 266 | if (auto v = parse<decltype(value.x)>(std::string_view({ it->first, (size_t)it->length() }))) |
| 267 | value[dim++] = *v; |
| 268 | else |
| 269 | return std::optional<T>(); |
| 270 | } |
| 271 | return dim == T::DIM ? value : std::optional<T>(); |
| 272 | } |
| 273 | |
| 274 | template <typename T> std::optional<T> parse_vector(std::string const& s) |
| 275 | { |