aboutsummaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-08-11 22:34:22 +0200
committerMax Kellermann <max@duempel.org>2015-08-11 22:43:10 +0200
commit9231f420c199a7c12cb8aad17bcca80a0aaca6ad (patch)
tree474755c86ced85b966a03bd79dfffbce48c17f43 /src/command
parent0f92d021a1dc2992352b635846428229d2c9ffbb (diff)
downloadmpd-9231f420c199a7c12cb8aad17bcca80a0aaca6ad.tar.gz
mpd-9231f420c199a7c12cb8aad17bcca80a0aaca6ad.tar.xz
mpd-9231f420c199a7c12cb8aad17bcca80a0aaca6ad.zip
protocol/ArgParser: overload as ParseCommandArg(), pass references
Diffstat (limited to 'src/command')
-rw-r--r--src/command/OtherCommands.cxx4
-rw-r--r--src/command/OutputCommands.cxx6
-rw-r--r--src/command/PlayerCommands.cxx36
-rw-r--r--src/command/PlaylistCommands.cxx8
-rw-r--r--src/command/QueueCommands.cxx41
-rw-r--r--src/command/TagCommands.cxx4
6 files changed, 42 insertions, 57 deletions
diff --git a/src/command/OtherCommands.cxx b/src/command/OtherCommands.cxx
index e5696e696..4fc7e56f6 100644
--- a/src/command/OtherCommands.cxx
+++ b/src/command/OtherCommands.cxx
@@ -309,7 +309,7 @@ CommandResult
handle_setvol(Client &client, Request args)
{
unsigned level;
- if (!check_unsigned(client, &level, args.front()))
+ if (!ParseCommandArg(client, level, args.front()))
return CommandResult::ERROR;
if (level > 100) {
@@ -330,7 +330,7 @@ CommandResult
handle_volume(Client &client, Request args)
{
int relative;
- if (!check_int(client, &relative, args.front()))
+ if (!ParseCommandArg(client, relative, args.front()))
return CommandResult::ERROR;
if (relative < -100 || relative > 100) {
diff --git a/src/command/OutputCommands.cxx b/src/command/OutputCommands.cxx
index b562dc406..885144168 100644
--- a/src/command/OutputCommands.cxx
+++ b/src/command/OutputCommands.cxx
@@ -34,7 +34,7 @@ handle_enableoutput(Client &client, Request args)
assert(args.size == 1);
unsigned device;
- if (!check_unsigned(client, &device, args.front()))
+ if (!ParseCommandArg(client, device, args.front()))
return CommandResult::ERROR;
if (!audio_output_enable_index(client.partition.outputs, device)) {
@@ -52,7 +52,7 @@ handle_disableoutput(Client &client, Request args)
assert(args.size == 1);
unsigned device;
- if (!check_unsigned(client, &device, args.front()))
+ if (!ParseCommandArg(client, device, args.front()))
return CommandResult::ERROR;
if (!audio_output_disable_index(client.partition.outputs, device)) {
@@ -70,7 +70,7 @@ handle_toggleoutput(Client &client, Request args)
assert(args.size == 1);
unsigned device;
- if (!check_unsigned(client, &device, args.front()))
+ if (!ParseCommandArg(client, device, args.front()))
return CommandResult::ERROR;
if (!audio_output_toggle_index(client.partition.outputs, device)) {
diff --git a/src/command/PlayerCommands.cxx b/src/command/PlayerCommands.cxx
index c2a42bbf9..ac7fdecfd 100644
--- a/src/command/PlayerCommands.cxx
+++ b/src/command/PlayerCommands.cxx
@@ -61,9 +61,9 @@ CommandResult
handle_play(Client &client, Request args)
{
int song = -1;
-
- if (!args.IsEmpty() && !check_int(client, &song, args.front()))
+ if (!args.IsEmpty() && !ParseCommandArg(client, song, args.front()))
return CommandResult::ERROR;
+
PlaylistResult result = client.partition.PlayPosition(song);
return print_playlist_result(client, result);
}
@@ -72,8 +72,7 @@ CommandResult
handle_playid(Client &client, Request args)
{
int id = -1;
-
- if (!args.IsEmpty() && !check_int(client, &id, args.front()))
+ if (!args.IsEmpty() && !ParseCommandArg(client, id, args.front()))
return CommandResult::ERROR;
PlaylistResult result = client.partition.PlayId(id);
@@ -99,7 +98,7 @@ handle_pause(Client &client, Request args)
{
if (!args.IsEmpty()) {
bool pause_flag;
- if (!check_bool(client, &pause_flag, args.front()))
+ if (!ParseCommandArg(client, pause_flag, args.front()))
return CommandResult::ERROR;
client.player_control.SetPause(pause_flag);
@@ -250,7 +249,7 @@ CommandResult
handle_repeat(Client &client, Request args)
{
bool status;
- if (!check_bool(client, &status, args.front()))
+ if (!ParseCommandArg(client, status, args.front()))
return CommandResult::ERROR;
client.partition.SetRepeat(status);
@@ -261,7 +260,7 @@ CommandResult
handle_single(Client &client, Request args)
{
bool status;
- if (!check_bool(client, &status, args.front()))
+ if (!ParseCommandArg(client, status, args.front()))
return CommandResult::ERROR;
client.partition.SetSingle(status);
@@ -272,7 +271,7 @@ CommandResult
handle_consume(Client &client, Request args)
{
bool status;
- if (!check_bool(client, &status, args.front()))
+ if (!ParseCommandArg(client, status, args.front()))
return CommandResult::ERROR;
client.partition.SetConsume(status);
@@ -283,7 +282,7 @@ CommandResult
handle_random(Client &client, Request args)
{
bool status;
- if (!check_bool(client, &status, args.front()))
+ if (!ParseCommandArg(client, status, args.front()))
return CommandResult::ERROR;
client.partition.SetRandom(status);
@@ -304,7 +303,7 @@ handle_seek(Client &client, Request args)
unsigned song;
SongTime seek_time;
- if (!check_unsigned(client, &song, args[0]))
+ if (!ParseCommandArg(client, song, args[0]))
return CommandResult::ERROR;
if (!ParseCommandArg(client, seek_time, args[1]))
return CommandResult::ERROR;
@@ -319,8 +318,7 @@ handle_seekid(Client &client, Request args)
{
unsigned id;
SongTime seek_time;
-
- if (!check_unsigned(client, &id, args[0]))
+ if (!ParseCommandArg(client, id, args[0]))
return CommandResult::ERROR;
if (!ParseCommandArg(client, seek_time, args[1]))
return CommandResult::ERROR;
@@ -348,11 +346,10 @@ CommandResult
handle_crossfade(Client &client, Request args)
{
unsigned xfade_time;
-
- if (!check_unsigned(client, &xfade_time, args.front()))
+ if (!ParseCommandArg(client, xfade_time, args.front()))
return CommandResult::ERROR;
- client.player_control.SetCrossFade(xfade_time);
+ client.player_control.SetCrossFade(xfade_time);
return CommandResult::OK;
}
@@ -360,11 +357,10 @@ CommandResult
handle_mixrampdb(Client &client, Request args)
{
float db;
-
- if (!check_float(client, &db, args.front()))
+ if (!ParseCommandArg(client, db, args.front()))
return CommandResult::ERROR;
- client.player_control.SetMixRampDb(db);
+ client.player_control.SetMixRampDb(db);
return CommandResult::OK;
}
@@ -372,9 +368,9 @@ CommandResult
handle_mixrampdelay(Client &client, Request args)
{
float delay_secs;
-
- if (!check_float(client, &delay_secs, args.front()))
+ if (!ParseCommandArg(client, delay_secs, args.front()))
return CommandResult::ERROR;
+
client.player_control.SetMixRampDelay(delay_secs);
return CommandResult::OK;
diff --git a/src/command/PlaylistCommands.cxx b/src/command/PlaylistCommands.cxx
index 56da71078..f6f610d7a 100644
--- a/src/command/PlaylistCommands.cxx
+++ b/src/command/PlaylistCommands.cxx
@@ -146,8 +146,7 @@ handle_playlistdelete(Client &client, Request args)
{
const char *const name = args[0];
unsigned from;
-
- if (!check_unsigned(client, &from, args[1]))
+ if (!ParseCommandArg(client, from, args[1]))
return CommandResult::ERROR;
Error error;
@@ -161,10 +160,9 @@ handle_playlistmove(Client &client, Request args)
{
const char *const name = args.front();
unsigned from, to;
-
- if (!check_unsigned(client, &from, args[1]))
+ if (!ParseCommandArg(client, from, args[1]))
return CommandResult::ERROR;
- if (!check_unsigned(client, &to, args[2]))
+ if (!ParseCommandArg(client, to, args[2]))
return CommandResult::ERROR;
Error error;
diff --git a/src/command/QueueCommands.cxx b/src/command/QueueCommands.cxx
index c11af26bb..634510cc8 100644
--- a/src/command/QueueCommands.cxx
+++ b/src/command/QueueCommands.cxx
@@ -105,7 +105,7 @@ handle_addid(Client &client, Request args)
if (args.size == 2) {
unsigned to;
- if (!check_unsigned(client, &to, args[1]))
+ if (!ParseCommandArg(client, to, args[1]))
return CommandResult::ERROR;
PlaylistResult result = client.partition.MoveId(added_id, to);
if (result != PlaylistResult::SUCCESS) {
@@ -155,7 +155,7 @@ CommandResult
handle_rangeid(Client &client, Request args)
{
unsigned id;
- if (!check_unsigned(client, &id, args.front()))
+ if (!ParseCommandArg(client, id, args.front()))
return CommandResult::ERROR;
SongTime start, end;
@@ -188,8 +188,7 @@ CommandResult
handle_deleteid(Client &client, Request args)
{
unsigned id;
-
- if (!check_unsigned(client, &id, args.front()))
+ if (!ParseCommandArg(client, id, args.front()))
return CommandResult::ERROR;
PlaylistResult result = client.partition.DeleteId(id);
@@ -269,7 +268,7 @@ handle_playlistid(Client &client, Request args)
{
if (!args.IsEmpty()) {
unsigned id;
- if (!check_unsigned(client, &id, args.front()))
+ if (!ParseCommandArg(client, id, args.front()))
return CommandResult::ERROR;
bool ret = playlist_print_id(client, client.playlist, id);
@@ -315,8 +314,7 @@ handle_prio(Client &client, Request args)
{
const char *const priority_string = args.shift();
unsigned priority;
-
- if (!check_unsigned(client, &priority, priority_string))
+ if (!ParseCommandArg(client, priority, priority_string))
return CommandResult::ERROR;
if (priority > 0xff) {
@@ -346,8 +344,7 @@ handle_prioid(Client &client, Request args)
{
const char *const priority_string = args.shift();
unsigned priority;
-
- if (!check_unsigned(client, &priority, priority_string))
+ if (!ParseCommandArg(client, priority, priority_string))
return CommandResult::ERROR;
if (priority > 0xff) {
@@ -358,7 +355,7 @@ handle_prioid(Client &client, Request args)
for (const char *i : args) {
unsigned song_id;
- if (!check_unsigned(client, &song_id, i))
+ if (!ParseCommandArg(client, song_id, i))
return CommandResult::ERROR;
PlaylistResult result =
@@ -376,9 +373,8 @@ handle_move(Client &client, Request args)
RangeArg range;
int to;
- if (!ParseCommandArg(client, range, args[0]))
- return CommandResult::ERROR;
- if (!check_int(client, &to, args[1]))
+ if (!ParseCommandArg(client, range, args[0]) ||
+ !ParseCommandArg(client, to, args[1]))
return CommandResult::ERROR;
PlaylistResult result =
@@ -391,11 +387,10 @@ handle_moveid(Client &client, Request args)
{
unsigned id;
int to;
-
- if (!check_unsigned(client, &id, args[0]))
- return CommandResult::ERROR;
- if (!check_int(client, &to, args[1]))
+ if (!ParseCommandArg(client, id, args[0]) ||
+ !ParseCommandArg(client, to, args[1]))
return CommandResult::ERROR;
+
PlaylistResult result = client.partition.MoveId(id, to);
return print_playlist_result(client, result);
}
@@ -404,10 +399,8 @@ CommandResult
handle_swap(Client &client, Request args)
{
unsigned song1, song2;
-
- if (!check_unsigned(client, &song1, args[0]))
- return CommandResult::ERROR;
- if (!check_unsigned(client, &song2, args[1]))
+ if (!ParseCommandArg(client, song1, args[0]) ||
+ !ParseCommandArg(client, song2, args[1]))
return CommandResult::ERROR;
PlaylistResult result =
@@ -419,10 +412,8 @@ CommandResult
handle_swapid(Client &client, Request args)
{
unsigned id1, id2;
-
- if (!check_unsigned(client, &id1, args[0]))
- return CommandResult::ERROR;
- if (!check_unsigned(client, &id2, args[1]))
+ if (!ParseCommandArg(client, id1, args[0]) ||
+ !ParseCommandArg(client, id2, args[1]))
return CommandResult::ERROR;
PlaylistResult result = client.partition.SwapIds(id1, id2);
diff --git a/src/command/TagCommands.cxx b/src/command/TagCommands.cxx
index 8997c84c3..aa8cf139d 100644
--- a/src/command/TagCommands.cxx
+++ b/src/command/TagCommands.cxx
@@ -32,7 +32,7 @@ CommandResult
handle_addtagid(Client &client, Request args)
{
unsigned song_id;
- if (!check_unsigned(client, &song_id, args.front()))
+ if (!ParseCommandArg(client, song_id, args.front()))
return CommandResult::ERROR;
const char *const tag_name = args[1];
@@ -57,7 +57,7 @@ CommandResult
handle_cleartagid(Client &client, Request args)
{
unsigned song_id;
- if (!check_unsigned(client, &song_id, args.front()))
+ if (!ParseCommandArg(client, song_id, args.front()))
return CommandResult::ERROR;
TagType tag_type = TAG_NUM_OF_ITEM_TYPES;