From 9231f420c199a7c12cb8aad17bcca80a0aaca6ad Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 11 Aug 2015 22:34:22 +0200 Subject: protocol/ArgParser: overload as ParseCommandArg(), pass references --- src/protocol/ArgParser.cxx | 20 ++++++++++---------- src/protocol/ArgParser.hxx | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/protocol') diff --git a/src/protocol/ArgParser.cxx b/src/protocol/ArgParser.cxx index b290b7138..2c3e21f79 100644 --- a/src/protocol/ArgParser.cxx +++ b/src/protocol/ArgParser.cxx @@ -41,7 +41,7 @@ check_uint32(Client &client, uint32_t *dst, const char *s) } bool -check_int(Client &client, int *value_r, const char *s) +ParseCommandArg(Client &client, int &value_r, const char *s) { char *test; long value; @@ -60,7 +60,7 @@ check_int(Client &client, int *value_r, const char *s) return false; } - *value_r = (int)value; + value_r = (int)value; return true; } @@ -131,7 +131,7 @@ ParseCommandArg(Client &client, RangeArg &value_r, const char *s) } bool -check_unsigned(Client &client, unsigned *value_r, const char *s) +ParseCommandArg(Client &client, unsigned &value_r, const char *s) { unsigned long value; char *endptr; @@ -149,12 +149,12 @@ check_unsigned(Client &client, unsigned *value_r, const char *s) return false; } - *value_r = (unsigned)value; + value_r = (unsigned)value; return true; } bool -check_bool(Client &client, bool *value_r, const char *s) +ParseCommandArg(Client &client, bool &value_r, const char *s) { long value; char *endptr; @@ -166,12 +166,12 @@ check_bool(Client &client, bool *value_r, const char *s) return false; } - *value_r = !!value; + value_r = !!value; return true; } bool -check_float(Client &client, float *value_r, const char *s) +ParseCommandArg(Client &client, float &value_r, const char *s) { float value; char *endptr; @@ -183,7 +183,7 @@ check_float(Client &client, float *value_r, const char *s) return false; } - *value_r = value; + value_r = value; return true; } @@ -191,7 +191,7 @@ bool ParseCommandArg(Client &client, SongTime &value_r, const char *s) { float value; - bool success = check_float(client, &value, s) && value >= 0; + bool success = ParseCommandArg(client, value, s) && value >= 0; if (success) value_r = SongTime::FromS(value); @@ -202,7 +202,7 @@ bool ParseCommandArg(Client &client, SignedSongTime &value_r, const char *s) { float value; - bool success = check_float(client, &value, s); + bool success = ParseCommandArg(client, value, s); if (success) value_r = SignedSongTime::FromS(value); diff --git a/src/protocol/ArgParser.hxx b/src/protocol/ArgParser.hxx index 7866b88d5..d71894771 100644 --- a/src/protocol/ArgParser.hxx +++ b/src/protocol/ArgParser.hxx @@ -32,7 +32,7 @@ bool check_uint32(Client &client, uint32_t *dst, const char *s); bool -check_int(Client &client, int *value_r, const char *s); +ParseCommandArg(Client &client, int &value_r, const char *s); struct RangeArg { unsigned start, end; @@ -47,13 +47,13 @@ bool ParseCommandArg(Client &client, RangeArg &value_r, const char *s); bool -check_unsigned(Client &client, unsigned *value_r, const char *s); +ParseCommandArg(Client &client, unsigned &value_r, const char *s); bool -check_bool(Client &client, bool *value_r, const char *s); +ParseCommandArg(Client &client, bool &value_r, const char *s); bool -check_float(Client &client, float *value_r, const char *s); +ParseCommandArg(Client &client, float &value_r, const char *s); bool ParseCommandArg(Client &client, SongTime &value_r, const char *s); -- cgit v1.2.3