command/Request: add parser methods

Wrapper for protocol/ArgParser.cxx.
This commit is contained in:
Max Kellermann
2015-08-11 22:18:40 +02:00
parent e118e958f7
commit b1480167be
9 changed files with 96 additions and 67 deletions

View File

@@ -32,7 +32,6 @@
#include "tag/TagHandler.hxx"
#include "TimePrint.hxx"
#include "decoder/DecoderPrint.hxx"
#include "protocol/ArgParser.hxx"
#include "protocol/Result.hxx"
#include "ls.hxx"
#include "mixer/Volume.hxx"
@@ -116,7 +115,7 @@ CommandResult
handle_listfiles(Client &client, Request args)
{
/* default is root directory */
const char *const uri = args.IsEmpty() ? "" : args.front();
const auto uri = args.GetOptional(0, "");
if (memcmp(uri, "file:///", 8) == 0)
/* list local directory */
@@ -155,7 +154,7 @@ CommandResult
handle_lsinfo(Client &client, Request args)
{
/* default is root directory */
const char *const uri = args.IsEmpty() ? "" : args.front();
const auto uri = args.GetOptional(0, "");
if (memcmp(uri, "file:///", 8) == 0) {
/* print information about an arbitrary local file */
@@ -309,7 +308,7 @@ CommandResult
handle_setvol(Client &client, Request args)
{
unsigned level;
if (!ParseCommandArg(client, level, args.front(), 100))
if (!args.Parse(0, level, client, 100))
return CommandResult::ERROR;
if (!volume_level_change(client.partition.outputs, level)) {
@@ -325,7 +324,7 @@ CommandResult
handle_volume(Client &client, Request args)
{
int relative;
if (!ParseCommandArg(client, relative, args.front(), -100, 100))
if (!args.Parse(0, relative, client, -100, 100))
return CommandResult::ERROR;
const int old_volume = volume_level_get(client.partition.outputs);