2
* stringparsing.h is part of Brewtarget, and is Copyright Philip G. Lee
3
* (rocketman768@gmail.com), 2009.
5
* Brewtarget 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 3 of the License, or
8
* (at your option) any later version.
10
* Brewtarget 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.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19
#ifndef _STRINGPARSING_H
20
#define _STRINGPARSING_H
28
int parseInt( const std::string &str );
29
long parseLong( const std::string &str );
30
double parseDouble( const std::string &str );
31
bool parseBool( const std::string &str );
32
std::string doubleToString( double num );
33
std::string doubleToStringPrec( double num, unsigned int prec );
34
std::string intToString( int num );
35
std::string boolToString( bool b );
37
std::string& trim( std::string &str );
38
void iterateUntilDelimiter( std::string::const_iterator &iter );
39
void iterateUntilNotDelimiter( std::string::const_iterator &iter );
40
void iterateUntilCharFound( std::string::const_iterator &iter, char c );
41
bool isWhiteSpace( char c );
43
//==========================ParseException======================================
44
class ParseException : std::exception
48
virtual const char* what() const throw()
50
return std::string("Error in parsing: " + _err + "\n").c_str();
54
ParseException( std::string error )
59
~ParseException() throw() {}
64
#endif /* _STRINGPARSING_H */