diff options
author | Max Kellermann <max@musicpd.org> | 2021-02-15 19:55:55 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2021-02-15 20:29:34 +0100 |
commit | 6e1940e93060ea8e1b83bea932447bdd693a598e (patch) | |
tree | a83bc51d3ea6fa50b08ba8f6f777f49bb56bbaeb /src/protocol | |
parent | 103194e32d1d86042ac41a581386289834469e20 (diff) |
protocol/RangeArg: add static method OpenEnded()
Diffstat (limited to 'src/protocol')
-rw-r--r-- | src/protocol/ArgParser.cxx | 2 | ||||
-rw-r--r-- | src/protocol/RangeArg.hxx | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/protocol/ArgParser.cxx b/src/protocol/ArgParser.cxx index 98cf74150..deaa8f08f 100644 --- a/src/protocol/ArgParser.cxx +++ b/src/protocol/ArgParser.cxx @@ -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, diff --git a/src/protocol/RangeArg.hxx b/src/protocol/RangeArg.hxx index a55a2755c..ab00dc990 100644 --- a/src/protocol/RangeArg.hxx +++ b/src/protocol/RangeArg.hxx @@ -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 { |