69 |
11 Feb 06 |
jari |
// $Id$ |
69 |
11 Feb 06 |
jari |
2 |
|
95 |
05 Apr 06 |
jari |
3 |
/* |
95 |
05 Apr 06 |
jari |
Copyright (C) 2005 Jari Häkkinen, Markus Ringnér |
95 |
05 Apr 06 |
jari |
Copyright (C) 2006 Jari Häkkinen |
95 |
05 Apr 06 |
jari |
6 |
|
95 |
05 Apr 06 |
jari |
This file is part of the thep c++ tools library, |
95 |
05 Apr 06 |
jari |
http://lev.thep.lu.se/trac/c++_tools |
95 |
05 Apr 06 |
jari |
9 |
|
95 |
05 Apr 06 |
jari |
The c++ tools library is free software; you can redistribute it |
95 |
05 Apr 06 |
jari |
and/or modify it under the terms of the GNU General Public License |
824 |
26 Nov 08 |
jari |
as published by the Free Software Foundation; either version 3 of |
95 |
05 Apr 06 |
jari |
the License, or (at your option) any later version. |
95 |
05 Apr 06 |
jari |
14 |
|
95 |
05 Apr 06 |
jari |
The c++ tools library is distributed in the hope that it will be |
95 |
05 Apr 06 |
jari |
useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
95 |
05 Apr 06 |
jari |
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
95 |
05 Apr 06 |
jari |
General Public License for more details. |
95 |
05 Apr 06 |
jari |
19 |
|
95 |
05 Apr 06 |
jari |
You should have received a copy of the GNU General Public License |
824 |
26 Nov 08 |
jari |
along with WeNNI. If not, see <http://www.gnu.org/licenses/>. |
95 |
05 Apr 06 |
jari |
22 |
*/ |
95 |
05 Apr 06 |
jari |
23 |
|
69 |
11 Feb 06 |
jari |
24 |
#include <c++_tools/utility/utility.h> |
69 |
11 Feb 06 |
jari |
25 |
|
110 |
13 Jun 06 |
jari |
26 |
#include <c++_tools/utility/stl_utility.h> |
110 |
13 Jun 06 |
jari |
27 |
|
69 |
11 Feb 06 |
jari |
28 |
#include <sstream> |
69 |
11 Feb 06 |
jari |
29 |
#include <string> |
69 |
11 Feb 06 |
jari |
30 |
|
69 |
11 Feb 06 |
jari |
31 |
namespace theplu { |
69 |
11 Feb 06 |
jari |
32 |
namespace utility { |
69 |
11 Feb 06 |
jari |
33 |
|
110 |
13 Jun 06 |
jari |
34 |
bool is_double(const std::string& s) |
110 |
13 Jun 06 |
jari |
35 |
{ |
110 |
13 Jun 06 |
jari |
36 |
std::stringstream ss(s); |
110 |
13 Jun 06 |
jari |
37 |
double a; |
110 |
13 Jun 06 |
jari |
38 |
return (ss>>a); |
110 |
13 Jun 06 |
jari |
39 |
} |
110 |
13 Jun 06 |
jari |
40 |
|
69 |
11 Feb 06 |
jari |
41 |
bool is_float(const std::string& s) |
69 |
11 Feb 06 |
jari |
42 |
{ |
110 |
13 Jun 06 |
jari |
43 |
std::stringstream ss(s); |
110 |
13 Jun 06 |
jari |
44 |
float a; |
110 |
13 Jun 06 |
jari |
45 |
return (ss>>a); |
69 |
11 Feb 06 |
jari |
46 |
} |
69 |
11 Feb 06 |
jari |
47 |
|
69 |
11 Feb 06 |
jari |
48 |
bool is_int(const std::string& s) |
69 |
11 Feb 06 |
jari |
49 |
{ |
110 |
13 Jun 06 |
jari |
50 |
std::stringstream ss(s); |
110 |
13 Jun 06 |
jari |
51 |
int a; |
110 |
13 Jun 06 |
jari |
52 |
return (ss>>a); |
69 |
11 Feb 06 |
jari |
53 |
} |
69 |
11 Feb 06 |
jari |
54 |
|
110 |
13 Jun 06 |
jari |
55 |
bool is_nan(const std::string& s) |
110 |
13 Jun 06 |
jari |
56 |
{ |
110 |
13 Jun 06 |
jari |
57 |
std::stringstream ss(s); |
110 |
13 Jun 06 |
jari |
58 |
std::string s2; |
110 |
13 Jun 06 |
jari |
59 |
ss >> s2; // to trim surrounding whitespaces |
110 |
13 Jun 06 |
jari |
60 |
to_lower(s2); |
110 |
13 Jun 06 |
jari |
61 |
std::string nan("nan"); |
110 |
13 Jun 06 |
jari |
62 |
return (nan==s2); |
110 |
13 Jun 06 |
jari |
63 |
} |
69 |
11 Feb 06 |
jari |
64 |
|
69 |
11 Feb 06 |
jari |
65 |
}} // end of namespace utility and namespace thep |