diff options
author | Max Kellermann <max@duempel.org> | 2015-08-11 21:35:52 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-08-11 22:43:10 +0200 |
commit | cbdc3194cc20aa5abcce8b53c44d46a96002ad3a (patch) | |
tree | 04164bedb2ca82200ebcb4f4a01f658a4f79b016 /src/protocol | |
parent | 993df0fd289d4426c633fd6e6d12bffe6061599d (diff) | |
download | mpd-cbdc3194cc20aa5abcce8b53c44d46a96002ad3a.tar.gz mpd-cbdc3194cc20aa5abcce8b53c44d46a96002ad3a.tar.xz mpd-cbdc3194cc20aa5abcce8b53c44d46a96002ad3a.zip |
protocol/ArgParser: add struct RangeArg
Diffstat (limited to 'src/protocol')
-rw-r--r-- | src/protocol/ArgParser.cxx | 13 | ||||
-rw-r--r-- | src/protocol/ArgParser.hxx | 12 |
2 files changed, 16 insertions, 9 deletions
diff --git a/src/protocol/ArgParser.cxx b/src/protocol/ArgParser.cxx index b8837eeb4..b290b7138 100644 --- a/src/protocol/ArgParser.cxx +++ b/src/protocol/ArgParser.cxx @@ -65,8 +65,7 @@ check_int(Client &client, int *value_r, const char *s) } bool -check_range(Client &client, unsigned *value_r1, unsigned *value_r2, - const char *s) +ParseCommandArg(Client &client, RangeArg &value_r, const char *s) { char *test, *test2; long value; @@ -81,8 +80,8 @@ check_range(Client &client, unsigned *value_r1, unsigned *value_r2, if (value == -1 && *test == 0) { /* compatibility with older MPD versions: specifying "-1" makes MPD display the whole list */ - *value_r1 = 0; - *value_r2 = std::numeric_limits<int>::max(); + value_r.start = 0; + value_r.end = std::numeric_limits<int>::max(); return true; } @@ -98,7 +97,7 @@ check_range(Client &client, unsigned *value_r1, unsigned *value_r2, return false; } - *value_r1 = (unsigned)value; + value_r.start = (unsigned)value; if (*test == ':') { value = strtol(++test, &test2, 10); @@ -123,9 +122,9 @@ check_range(Client &client, unsigned *value_r1, unsigned *value_r2, return false; } - *value_r2 = (unsigned)value; + value_r.end = (unsigned)value; } else { - *value_r2 = (unsigned)value + 1; + value_r.end = (unsigned)value + 1; } return true; diff --git a/src/protocol/ArgParser.hxx b/src/protocol/ArgParser.hxx index 7df71d30b..7866b88d5 100644 --- a/src/protocol/ArgParser.hxx +++ b/src/protocol/ArgParser.hxx @@ -34,9 +34,17 @@ check_uint32(Client &client, uint32_t *dst, const char *s); bool check_int(Client &client, int *value_r, const char *s); +struct RangeArg { + unsigned start, end; + + void SetAll() { + start = 0; + end = unsigned(-1); + } +}; + bool -check_range(Client &client, unsigned *value_r1, unsigned *value_r2, - const char *s); +ParseCommandArg(Client &client, RangeArg &value_r, const char *s); bool check_unsigned(Client &client, unsigned *value_r, const char *s); |