string_utils.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef PLANCK_STRING_UTILS_H
00033 #define PLANCK_STRING_UTILS_H
00034
00035 #include <vector>
00036 #include <map>
00037 #include "datatypes.h"
00038
00039
00040
00041
00042
00043 std::string trim (const std::string &orig);
00044
00045
00046
00047 template<typename T> std::string dataToString(const T &x);
00048 template<> std::string dataToString (const bool &x);
00049 template<> std::string dataToString (const std::string &x);
00050 template<> std::string dataToString (const float &x);
00051 template<> std::string dataToString (const double &x);
00052 template<> std::string dataToString (const long double &x);
00053
00054
00055
00056 std::string intToString(int64 x, tsize width);
00057
00058
00059 template<typename T> void stringToData (const std::string &x, T &value);
00060 template<> void stringToData (const std::string &x, std::string &value);
00061 template<> void stringToData (const std::string &x, bool &value);
00062
00063
00064 template<typename T> inline T stringToData (const std::string &x)
00065 { T result; stringToData(x,result); return result; }
00066
00067
00068 void parse_file (const std::string &filename,
00069 std::map<std::string,std::string> &dict);
00070
00071 void parse_cmdline_classic (int argc, const char **argv,
00072 const std::vector<std::string> &leading_args,
00073 std::map<std::string,std::string> &dict);
00074
00075 void parse_cmdline_classic (int argc, const char **argv,
00076 std::map<std::string,std::string> &dict);
00077
00078 void parse_cmdline_equalsign (int argc, const char **argv,
00079 const std::vector<std::string> &leading_args,
00080 std::map<std::string,std::string> &dict);
00081
00082 void parse_cmdline_equalsign (int argc, const char **argv,
00083 std::map<std::string,std::string> &dict);
00084
00085
00086
00087
00088 bool equal_nocase (const std::string &a, const std::string &b);
00089
00090
00091 std::string tolower(const std::string &input);
00092
00093
00094
00095 template<typename T> void split (const std::string &inp, std::vector<T> &list);
00096
00097
00098
00099 void tokenize (const std::string &inp, char delim,
00100 std::vector<std::string> &list);
00101
00102
00103
00104 void parse_words_from_file (const std::string &filename,
00105 std::vector<std::string> &words);
00106
00107
00108
00109 #endif