| 295 | } |
| 296 | |
| 297 | tl::expected<double, std::string> |
| 298 | parse_double(const std::string& value) |
| 299 | { |
| 300 | size_t end; |
| 301 | double result; |
| 302 | bool failed = false; |
| 303 | try { |
| 304 | result = std::stod(value, &end); |
| 305 | } catch (const std::exception&) { |
| 306 | failed = true; |
| 307 | } |
| 308 | |
| 309 | if (failed || end != value.size()) { |
| 310 | return tl::unexpected(FMT("invalid floating point: \"{}\"", value)); |
| 311 | } else { |
| 312 | return result; |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | tl::expected<std::chrono::milliseconds, std::string> |
| 317 | parse_duration(std::string_view duration) |
no test coverage detected