ArgParser.hxx 1.79 KB
Newer Older
1
/*
2
 * Copyright 2003-2016 The Music Player Daemon Project
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 * http://www.musicpd.org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

Max Kellermann's avatar
Max Kellermann committed
20 21
#ifndef MPD_PROTOCOL_ARGPARSER_HXX
#define MPD_PROTOCOL_ARGPARSER_HXX
22 23

#include "check.h"
24
#include "Compiler.h"
25

26 27
#include <limits>

28 29
#include <stdint.h>

30 31
class SongTime;
class SignedSongTime;
32

33 34 35
gcc_pure
uint32_t
ParseCommandArgU32(const char *s);
36

37 38 39
gcc_pure
int
ParseCommandArgInt(const char *s, int min_value, int max_value);
40

41 42 43
gcc_pure
int
ParseCommandArgInt(const char *s);
44

45 46 47 48 49
struct RangeArg {
	unsigned start, end;

	void SetAll() {
		start = 0;
50
		end = std::numeric_limits<unsigned>::max();
51
	}
52 53 54 55

	static constexpr RangeArg All() {
		return { 0, std::numeric_limits<unsigned>::max() };
	}
56 57
};

58 59 60
gcc_pure
RangeArg
ParseCommandArgRange(const char *s);
61

62 63 64
gcc_pure
unsigned
ParseCommandArgUnsigned(const char *s, unsigned max_value);
65

66 67 68
gcc_pure
unsigned
ParseCommandArgUnsigned(const char *s);
69

70
gcc_pure
71
bool
72
ParseCommandArgBool(const char *s);
73

74 75 76
gcc_pure
float
ParseCommandArgFloat(const char *s);
77

78 79 80
gcc_pure
SongTime
ParseCommandArgSongTime(const char *s);
81

82 83 84
gcc_pure
SignedSongTime
ParseCommandArgSignedSongTime(const char *s);
85

86
#endif