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
30namespace fawkes {
31
33{
34public:
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
68private:
69 // may not be instantiated!
71};
72
73} // end namespace fawkes
74
75#endif
Utility class that holds string methods.
static void trim_inplace(std::string &s)
Trim string.
static std::vector< std::string > resolve_paths(std::vector< std::string > s)
Resolves vector of path-string with @...@ tags.
static std::string to_upper(std::string str)
Convert string to all-uppercase string.
static float to_float(std::string s)
Convert string to a float value.
static double to_double(std::string s)
Convert string to a double value.
static unsigned int to_uint(std::string s)
Convert string to an unsigned int value.
static bool to_bool(std::string s)
Convert string to a bool value.
static long to_long(std::string s)
Convert string to a long int value.
static std::string to_string(const std::string &s)
No-op conversion of string.
static std::string trim(const std::string &s)
Trim spring.
static std::string to_string(unsigned int i)
Convert unsigned int value to a string.
static int to_int(std::string s)
Convert string to an int value.
static std::string resolve_path(std::string s)
Resolves path-string with @...@ tags.
static std::string to_lower(std::string str)
Convert string to all-lowercase string.
Fawkes library namespace.