Definition at line 10 of file StringTool.h.
| Public Types | |
| typedef std::vector< std::string > | t_args | 
| Static Public Member Functions | |
| static long | readInt (const char *text, bool *ok) | 
| Convert string to number. | |
| static std::string | toString (long value) | 
| Convert long to string. | |
| static bool | startsWith (const std::string &str, const std::string &prefix) | 
| static void | replace (std::string &buffer, const std::string &pattern, const std::string &newstring) | 
| Replace one substring with another. | |
| static t_args | split (const std::string &str, char separator) | 
| Split string. | |
| 
 | 
| 
 Definition at line 12 of file StringTool.h. | 
| 
 | ||||||||||||
| Convert string to number. 
 
 
 Definition at line 21 of file StringTool.cpp. 00022 {
00023     long result = 0;
00024     *ok = false;
00025 
00026     if (strNum != NULL) {
00027         char *endptr;
00028         result = strtol(strNum, &endptr, 0);
00029         if (strNum[0] != '\0' && endptr[0] == '\0') {
00030             *ok = true;
00031         }
00032     }
00033 
00034     if (!ok) {
00035         result = 0;
00036     }
00037 
00038     return result;
00039 }
 | 
| 
 | ||||||||||||||||
| Replace one substring with another. 
 
 Definition at line 67 of file StringTool.cpp. 00069 {
00070     std::string::size_type pos = buffer.find(pattern);
00071     while (pos != std::string::npos) {
00072         buffer.replace(pos, pattern.size(), newstring);
00073         pos = buffer.find(pattern, pos + newstring.size());
00074     }
00075 }
 | 
| 
 | ||||||||||||
| Split string. 
 
 Definition at line 82 of file StringTool.cpp. 00083 {
00084     std::string remain = str;
00085     t_args args;
00086 
00087     std::string::size_type pos = remain.find(separator);
00088     while (pos != std::string::npos) {
00089         args.push_back(remain.substr(0, pos));
00090         remain.erase(0, pos + 1);
00091 
00092         pos = remain.find(separator);
00093     }
00094     if (remain.size() > 0) {
00095         args.push_back(remain);
00096     }
00097 
00098     return args;
00099 }
 | 
| 
 | ||||||||||||
| 
 Definition at line 54 of file StringTool.cpp. 00056 {
00057     return prefix == str.substr(0, prefix.size());
00058 }
 | 
| 
 | 
| Convert long to string. 
 
 Definition at line 46 of file StringTool.cpp. 00047 {
00048     std::ostringstream buffer;
00049     buffer << value;
00050     return buffer.str();
00051 }
 | 
 1.4.2
 1.4.2