Fawkes API  Fawkes Development Version
string_conversions.h
1 
2 /***************************************************************************
3  * string_conversions.h - string conversions
4  *
5  * Created: Thu Oct 12 12:03:49 2006
6  * Copyright 2006 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _UTILS_MISC_STRINGTOOLS_H_
25 #define _UTILS_MISC_STRINGTOOLS_H_
26 
27 #include <string>
28 #include <vector>
29 
30 namespace fawkes {
31 
32 class StringConversions
33 {
34 public:
35  static std::string to_upper(std::string str);
36  static std::string to_lower(std::string str);
37 
38  static std::string to_string(unsigned int i);
39  static std::string to_string(int i);
40  static std::string to_string(long int i);
41  static std::string to_string(float f);
42  static std::string to_string(double d);
43  static std::string to_string(bool b);
44 
45  /** No-op conversion of string.
46  * @param s value to convert
47  * @return string the very same string
48  */
49  static std::string
50  to_string(const std::string &s)
51  {
52  return s;
53  }
54 
55  static unsigned int to_uint(std::string s);
56  static int to_int(std::string s);
57  static long to_long(std::string s);
58  static float to_float(std::string s);
59  static double to_double(std::string s);
60  static bool to_bool(std::string s);
61 
62  static void trim_inplace(std::string &s);
63  static std::string trim(const std::string &s);
64 
65  static std::string resolve_path(std::string s);
66  static std::vector<std::string> resolve_paths(std::vector<std::string> s);
67 
68 private:
69  // may not be instantiated!
71 };
72 
73 } // end namespace fawkes
74 
75 #endif
fawkes::StringConversions::trim
static std::string trim(const std::string &s)
Trim spring.
Definition: string_conversions.cpp:252
fawkes::StringConversions::resolve_paths
static std::vector< std::string > resolve_paths(std::vector< std::string > s)
Resolves vector of path-string with @...@ tags.
Definition: string_conversions.cpp:291
fawkes::StringConversions::to_uint
static unsigned int to_uint(std::string s)
Convert string to an unsigned int value.
Definition: string_conversions.cpp:173
fawkes::StringConversions::to_string
static std::string to_string(unsigned int i)
Convert unsigned int value to a string.
Definition: string_conversions.cpp:73
fawkes::StringConversions::resolve_path
static std::string resolve_path(std::string s)
Resolves path-string with @...@ tags.
Definition: string_conversions.cpp:265
fawkes::StringConversions::to_int
static int to_int(std::string s)
Convert string to an int value.
Definition: string_conversions.cpp:184
fawkes::StringConversions::to_lower
static std::string to_lower(std::string str)
Convert string to all-lowercase string.
Definition: string_conversions.cpp:60
fawkes::StringConversions
Definition: string_conversions.h:38
fawkes
fawkes::StringConversions::to_bool
static bool to_bool(std::string s)
Convert string to a bool value.
Definition: string_conversions.cpp:224
fawkes::StringConversions::to_long
static long to_long(std::string s)
Convert string to a long int value.
Definition: string_conversions.cpp:194
fawkes::StringConversions::to_upper
static std::string to_upper(std::string str)
Convert string to all-uppercase string.
Definition: string_conversions.cpp:47
fawkes::StringConversions::to_double
static double to_double(std::string s)
Convert string to a double value.
Definition: string_conversions.cpp:214
fawkes::StringConversions::trim_inplace
static void trim_inplace(std::string &s)
Trim string.
Definition: string_conversions.cpp:238
fawkes::StringConversions::to_float
static float to_float(std::string s)
Convert string to a float value.
Definition: string_conversions.cpp:204