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

Last change on this file since 1566 was 1487, checked in by Jari Häkkinen, 13 years ago

Addresses #436. GPL license copy reference should also be updated.

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