diff options
author | Max Kellermann <max@duempel.org> | 2015-12-18 09:50:48 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-12-18 09:53:02 +0100 |
commit | e939d667d9cbe459add98790c5c8b92d6aa5fa36 (patch) | |
tree | abb4fda3a28dd153439ccb544fabed33a2c438f1 /src/command/Request.hxx | |
parent | 8bb5a565cd9060b3b98bb7b9853fe99703fc18da (diff) |
protocol/Ack: add exception class wrapping enum ack
Diffstat (limited to 'src/command/Request.hxx')
-rw-r--r-- | src/command/Request.hxx | 79 |
1 files changed, 61 insertions, 18 deletions
diff --git a/src/command/Request.hxx b/src/command/Request.hxx index 1616b7045..cbc360370 100644 --- a/src/command/Request.hxx +++ b/src/command/Request.hxx @@ -22,6 +22,7 @@ #include "check.h" #include "protocol/ArgParser.hxx" +#include "Chrono.hxx" #include "util/ConstBuffer.hxx" #include <utility> @@ -44,30 +45,72 @@ public: : default_value; } - template<typename T, typename... Args> - bool Parse(unsigned idx, T &value_r, Response &r, - Args&&... args) { + gcc_pure + int ParseInt(unsigned idx) const { assert(idx < size); + return ParseCommandArgInt(data[idx]); + } - return ParseCommandArg(r, value_r, data[idx], - std::forward<Args>(args)...); + gcc_pure + int ParseInt(unsigned idx, int min_value, int max_value) const { + assert(idx < size); + return ParseCommandArgInt(data[idx], min_value, max_value); } - template<typename T, typename... Args> - bool ParseOptional(unsigned idx, T &value_r, Response &r, - Args&&... args) { - return idx >= size || - Parse(idx, value_r, r, - std::forward<Args>(args)...); + gcc_pure + int ParseUnsigned(unsigned idx) const { + assert(idx < size); + return ParseCommandArgUnsigned(data[idx]); } - template<typename T, typename... Args> - bool ParseShift(unsigned idx, T &value_r, Response &r, - Args&&... args) { - bool success = Parse(idx, value_r, r, - std::forward<Args>(args)...); - shift(); - return success; + gcc_pure + int ParseUnsigned(unsigned idx, unsigned max_value) const { + assert(idx < size); + return ParseCommandArgUnsigned(data[idx], max_value); + } + + gcc_pure + bool ParseBool(unsigned idx) const { + assert(idx < size); + return ParseCommandArgBool(data[idx]); + } + + gcc_pure + RangeArg ParseRange(unsigned idx) const { + assert(idx < size); + return ParseCommandArgRange(data[idx]); + } + + gcc_pure + float ParseFloat(unsigned idx) const { + assert(idx < size); + return ParseCommandArgFloat(data[idx]); + } + + gcc_pure + SongTime ParseSongTime(unsigned idx) const { + assert(idx < size); + return ParseCommandArgSongTime(data[idx]); + } + + gcc_pure + SignedSongTime ParseSignedSongTime(unsigned idx) const { + assert(idx < size); + return ParseCommandArgSignedSongTime(data[idx]); + } + + gcc_pure + int ParseOptional(unsigned idx, int default_value) const { + return idx < size + ? ParseInt(idx) + : default_value; + } + + gcc_pure + RangeArg ParseOptional(unsigned idx, RangeArg default_value) const { + return idx < size + ? ParseRange(idx) + : default_value; } }; |