Spaces:
Running
Running
Download src/arguments.hpp from pgg-engineering/pulsefold: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/spaces/pgg-engineering/pulsefold/resolve/main/src/arguments.hpp
- Command line
-
hf download hf://spaces/pgg-engineering/pulsefold/src/arguments.hpp
-
curl -L -o arguments.hpp https://huggingface.co/spaces/pgg-engineering/pulsefold/resolve/main/src/arguments.hpp
1.18 kB
| namespace arguments { | |
| using Time = std::uint64_t; | |
| using Id = std::uint32_t; | |
| inline Time integer(std::string_view text) { | |
| Time value; | |
| const auto parsed = std::from_chars(text.data(), text.data() + text.size(), value); | |
| if (parsed.ec != std::errc() || parsed.ptr != text.data() + text.size()) | |
| throw std::invalid_argument("expected an unsigned decimal integer"); | |
| return value; | |
| } | |
| inline Id feed_count(std::string_view text) { | |
| const auto value = integer(text); | |
| if (value == 0 || value > std::numeric_limits<Id>::max()) | |
| throw std::invalid_argument("feed count outside 1..UINT32_MAX"); | |
| return static_cast<Id>(value); | |
| } | |
| inline std::vector<Time> thresholds(std::string_view text) { | |
| std::vector<Time> values; | |
| while (true) { | |
| const auto comma = text.find(','); | |
| values.push_back(integer(text.substr(0, comma))); | |
| if (comma == text.npos) return values; | |
| text.remove_prefix(comma + 1); | |
| } | |
| } | |
| } // namespace arguments | |