source: trunk/yat/utility/utility.cc @ 1746

Last change on this file since 1746 was 1746, checked in by Peter, 14 years ago

Merged patch release 0.4.3 to the trunk. Delta 0.4.3 - 0.4.2.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1// $Id: utility.cc 1746 2009-01-23 16:59:11Z peter $
2
3/*
4  Copyright (C) 2005, 2006 Jari Häkkinen, Markus Ringnér
5  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
6  Copyright (C) 2008 Peter Johansson
7
8  This file is part of the yat library, http://dev.thep.lu.se/yat
9
10  The yat library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License as
12  published by the Free Software Foundation; either version 3 of the
13  License, or (at your option) any later version.
14
15  The yat library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  General Public License for more details.
19
20  You should have received a copy of the GNU General Public License
21  along with yat. If not, see <http://www.gnu.org/licenses/>.
22*/
23
24#include "utility.h"
25
26#include "Matrix.h"
27#include "stl_utility.h"
28#include "VectorConstView.h"
29#include "yat/statistics/Averager.h"
30
31#include <sstream>
32#include <string>
33
34namespace theplu {
35namespace yat {
36namespace utility {
37
38  bool is_double(const std::string& s)
39  {
40    return is<double>(s);
41  }
42 
43
44  bool is_equal(std::string s, std::string other)
45  {
46    std::stringstream ss(s);
47    std::string s2;
48    ss >> s2; // to trim surrounding whitespaces
49    to_lower(s2);
50    // Check that nothing is left on stream
51    std::string s3;
52    ss >> s3;
53    if(s3.size())
54      return false;
55    return (other==s2);
56  }
57
58
59  bool is_float(const std::string& s)
60  {
61    return is<float>(s);
62  }
63
64
65  bool is_int(const std::string& s)
66  {
67    return is<int>(s);
68  }
69
70  bool is_nan(const std::string& s)
71  {
72    return is_equal(s, "nan");
73  }
74
75
76}}} // end of namespace utility, yat and thep
Note: See TracBrowser for help on using the repository browser.