1
/* Copyright © 2005-2006 Roger Leigh <rleigh@debian.org>
3
* schroot is free software; you can redistribute it and/or modify it
4
* under the terms of the GNU General Public License as published by
5
* the Free Software Foundation; either version 2 of the License, or
6
* (at your option) any later version.
8
* schroot is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18
*********************************************************************/
20
#ifndef SBUILD_PARSE_VALUE_H
21
#define SBUILD_PARSE_VALUE_H
23
#include <sbuild/sbuild-parse-error.h>
24
#include <sbuild/sbuild-log.h>
33
* Parse a boolean value.
34
* @param value the value to parse.
35
* @param parsed_value the variable to store the parsed value.
36
* @returns true on success, false on failure.
39
parse_value (std::string const& value,
43
* Parse a string value.
44
* @param value the value to parse.
45
* @param parsed_value the variable to store the parsed value.
46
* @returns true on success, false on failure.
49
parse_value (std::string const& value,
50
std::string& parsed_value);
53
* Parse a value of type T.
54
* @param value the value to parse.
55
* @param parsed_value the variable to store the parsed value.
56
* @returns true on success, false on failure.
60
parse_value (std::string const& value,
63
std::istringstream is(value);
64
is.imbue(std::locale("C"));
68
parsed_value = tmpval;
69
log_debug(DEBUG_NOTICE) << "value=" << parsed_value << std::endl;
73
log_debug(DEBUG_NOTICE) << "parse error" << std::endl;
74
throw parse_error(parse_error::BAD_VALUE, value);
80
#endif /* SBUILD_PARSE_VALUE_H */