MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / parse_vector

Function parse_vector

include/donut/core/string_utils.h:252–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 3

lengthMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected