MPD  0.20.6
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 #include "Compiler.h"
25 
26 #include <limits>
27 
28 #include <stdint.h>
29 
30 class SongTime;
31 class SignedSongTime;
32 
34 uint32_t
35 ParseCommandArgU32(const char *s);
36 
38 int
39 ParseCommandArgInt(const char *s, int min_value, int max_value);
40 
42 int
43 ParseCommandArgInt(const char *s);
44 
45 struct RangeArg {
46  unsigned start, end;
47 
48  void SetAll() {
49  start = 0;
50  end = std::numeric_limits<unsigned>::max();
51  }
52 
53  static constexpr RangeArg All() {
54  return { 0, std::numeric_limits<unsigned>::max() };
55  }
56 };
57 
60 ParseCommandArgRange(const char *s);
61 
63 unsigned
64 ParseCommandArgUnsigned(const char *s, unsigned max_value);
65 
67 unsigned
68 ParseCommandArgUnsigned(const char *s);
69 
71 bool
72 ParseCommandArgBool(const char *s);
73 
75 float
76 ParseCommandArgFloat(const char *s);
77 
80 ParseCommandArgSongTime(const char *s);
81 
84 ParseCommandArgSignedSongTime(const char *s);
85 
86 #endif
gcc_pure SignedSongTime ParseCommandArgSignedSongTime(const char *s)
A time stamp within a song.
Definition: Chrono.hxx:31
static constexpr RangeArg All()
Definition: ArgParser.hxx:53
unsigned start
Definition: ArgParser.hxx:46
gcc_pure bool ParseCommandArgBool(const char *s)
gcc_pure SongTime ParseCommandArgSongTime(const char *s)
gcc_pure int ParseCommandArgInt(const char *s, int min_value, int max_value)
unsigned end
Definition: ArgParser.hxx:46
A variant of SongTime that is based on a signed integer.
Definition: Chrono.hxx:115
gcc_pure uint32_t ParseCommandArgU32(const char *s)
void SetAll()
Definition: ArgParser.hxx:48
gcc_pure float ParseCommandArgFloat(const char *s)
#define gcc_pure
Definition: Compiler.h:116
gcc_pure unsigned ParseCommandArgUnsigned(const char *s, unsigned max_value)
gcc_pure RangeArg ParseCommandArgRange(const char *s)