MPD  0.20.15
ArgParser.hxx
Go to the documentation of this file.
1 /*
2  * Copyright 2003-2017 The Music Player Daemon Project
3  * http://www.musicpd.org
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef MPD_PROTOCOL_ARGPARSER_HXX
21 #define MPD_PROTOCOL_ARGPARSER_HXX
22 
23 #include "check.h"
24 
25 #include <limits>
26 
27 #include <stdint.h>
28 
29 class SongTime;
30 class SignedSongTime;
31 
32 uint32_t
33 ParseCommandArgU32(const char *s);
34 
35 int
36 ParseCommandArgInt(const char *s, int min_value, int max_value);
37 
38 int
39 ParseCommandArgInt(const char *s);
40 
41 struct RangeArg {
42  unsigned start, end;
43 
44  void SetAll() {
45  start = 0;
46  end = std::numeric_limits<unsigned>::max();
47  }
48 
49  static constexpr RangeArg All() {
50  return { 0, std::numeric_limits<unsigned>::max() };
51  }
52 };
53 
55 ParseCommandArgRange(const char *s);
56 
57 unsigned
58 ParseCommandArgUnsigned(const char *s, unsigned max_value);
59 
60 unsigned
61 ParseCommandArgUnsigned(const char *s);
62 
63 bool
64 ParseCommandArgBool(const char *s);
65 
66 float
67 ParseCommandArgFloat(const char *s);
68 
70 ParseCommandArgSongTime(const char *s);
71 
73 ParseCommandArgSignedSongTime(const char *s);
74 
75 #endif
A time stamp within a song.
Definition: Chrono.hxx:31
static constexpr RangeArg All()
Definition: ArgParser.hxx:49
float ParseCommandArgFloat(const char *s)
unsigned start
Definition: ArgParser.hxx:42
SongTime ParseCommandArgSongTime(const char *s)
int ParseCommandArgInt(const char *s, int min_value, int max_value)
SignedSongTime ParseCommandArgSignedSongTime(const char *s)
uint32_t ParseCommandArgU32(const char *s)
unsigned ParseCommandArgUnsigned(const char *s, unsigned max_value)
unsigned end
Definition: ArgParser.hxx:42
RangeArg ParseCommandArgRange(const char *s)
A variant of SongTime that is based on a signed integer.
Definition: Chrono.hxx:115
bool ParseCommandArgBool(const char *s)
void SetAll()
Definition: ArgParser.hxx:44