protocol/RangeArg: add static method OpenEnded()

This commit is contained in:
Max Kellermann 2021-02-15 19:55:55 +01:00
parent 103194e32d
commit 6e1940e930
2 changed files with 9 additions and 2 deletions

View File

@ -94,7 +94,7 @@ ParseCommandArgRange(const char *s)
s);
if (test == test2)
value = std::numeric_limits<int>::max();
return RangeArg::OpenEnded(range.start);
if (value < 0)
throw FormatProtocolError(ACK_ERROR_ARG,

View File

@ -25,8 +25,15 @@
struct RangeArg {
unsigned start, end;
/**
* Construct an open-ended range starting at the given index.
*/
static constexpr RangeArg OpenEnded(unsigned start) noexcept {
return { start, std::numeric_limits<unsigned>::max() };
}
static constexpr RangeArg All() noexcept {
return { 0, std::numeric_limits<unsigned>::max() };
return OpenEnded(0);
}
constexpr bool operator==(RangeArg other) const noexcept {