IODA Bundle
StringTool.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 1996-2012 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 /// \file StringTool.h
12 ///
13 /// @author Piotr Kuchta, ECMWF, Oct 2010
14 
15 #ifndef StringTool_H
16 #define StringTool_H
17 
18 #include "eckit/eckit.h"
19 #include "odc/api/ColumnType.h"
20 
21 
22 namespace eckit { class PathName; class CodeLocation; }
23 
24 namespace odc {
25 
26 class StringTool {
27 
28  typedef int(*ctypeFun)(int);
29 
30 public:
31 
32  static std::string readFile(const eckit::PathName fileName, bool logging = false);
33  static std::vector<std::string> readLines(const eckit::PathName fileName, bool logging = false);
34 
35  static void trimInPlace(std::string &);
36 
37  static bool match(const std::string& regex, const std::string&);
38  static bool matchAny(const std::vector<std::string>& regs, const std::string&);
39 
40  static bool check(const std::string&, ctypeFun);
41  static bool isInQuotes(const std::string &);
42  static std::string unQuote(const std::string &);
43 
44  static double cast_as_double(const std::string &);
45  static std::string double_as_string(double);
46  //static std::string stringAsDouble(double v)
47 
48  static std::string int_as_double2string(double);
49 
50  static int shell(std::string cmd, const eckit::CodeLocation &where, bool assertSuccess = true);
51 
52  static double translate(const std::string& v);
53  static std::string valueAsString(double, api::ColumnType);
54 
55  static std::string patchTimeForMars(const std::string& v);
56 
57  static bool isSelectStatement(const std::string&);
58 
59 
60 };
61 
62 std::ostream& operator<<(std::ostream&, const std::vector<std::string>&);
63 
64 } // namespace odc
65 
66 #endif
67 
static bool match(const std::string &regex, const std::string &)
Definition: StringTool.cc:140
static void trimInPlace(std::string &)
Definition: StringTool.cc:138
static int shell(std::string cmd, const eckit::CodeLocation &where, bool assertSuccess=true)
Definition: StringTool.cc:64
static std::string readFile(const eckit::PathName fileName, bool logging=false)
Definition: StringTool.cc:40
static bool isInQuotes(const std::string &)
Definition: StringTool.cc:90
static std::string unQuote(const std::string &)
Definition: StringTool.cc:97
int(* ctypeFun)(int)
Definition: StringTool.h:28
static bool isSelectStatement(const std::string &)
Definition: StringTool.cc:196
static double translate(const std::string &v)
Definition: StringTool.cc:133
static bool matchAny(const std::vector< std::string > &regs, const std::string &)
Definition: StringTool.cc:145
static bool check(const std::string &, ctypeFun)
Definition: StringTool.cc:82
static std::string patchTimeForMars(const std::string &v)
Definition: StringTool.cc:182
static std::string double_as_string(double)
Definition: StringTool.cc:106
static std::vector< std::string > readLines(const eckit::PathName fileName, bool logging=false)
Definition: StringTool.cc:34
static std::string int_as_double2string(double)
Definition: StringTool.cc:125
static double cast_as_double(const std::string &)
Definition: StringTool.cc:114
static std::string valueAsString(double, api::ColumnType)
Definition: StringTool.cc:163
Definition: ColumnInfo.h:23
ostream & operator<<(ostream &o, const Block &b)
Definition: Block.cc:34