00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef STRINGLIB_H
00018 #define STRINGLIB_H
00019
00020 #include <string>
00021 #include <stl_pair.h>
00022 using namespace std;
00023
00025 bool CompareNoCase(const string& string1, const string& string2);
00026
00028 string ToUpper(string::iterator start, string::iterator stop);
00029 string ToLower(string::iterator start, string::iterator stop);
00030
00032 int ParseInt (const string& string1);
00033 float ParseFloat(const string& string1);
00034
00036 int stoi(const string& rhs);
00037 float stof(const string& rhs);
00038
00040 string ReadFile(string& strIn, const string& filename);
00041 string ReadFile(string& strIn, istream& is);
00042
00044 string itos(const int n);
00045 string ftos(const double n, const int precision = 4);
00046
00048 string EatWhite(string::iterator start, string::iterator stop);
00049
00051 string Trim (string::iterator start, string::iterator stop);
00052 string RTrim(string::iterator start, string::iterator stop);
00053 string LTrim(string::iterator start, string::iterator stop);
00054
00056 pair<string, string>
00057 Split(const string& strIn, const string& delim);
00058
00060 string Space(size_t n = 1);
00061
00063 bool IsAllSpace(string::iterator start, string::iterator stop);
00064
00066 template <class List>
00067 List GetListItems(const string& strList,
00068 const string& delimiter = string(", "))
00069 {
00070 List tempList;
00071 char* charList = const_cast<char*>(strList.c_str()),
00072 * temp;
00073 const char* delim = delimiter.c_str();
00074
00075
00076 temp = strtok(charList, delim);
00077 if (!temp)
00078 return tempList;
00079
00080 tempList.push_back(temp);
00081 while ((temp = strtok(NULL, delim)) != 0)
00082 tempList.push_back(temp);
00083
00084 return tempList;
00085 }
00086 #endif