#include <StringTokenizer.h>
Public Member Functions | |
| StringTokenizer (const string &_str, const string &_delim) | |
| ~StringTokenizer () | |
| int | countTokens () |
| bool | hasMoreTokens () |
| std::string | nextToken () |
| int | nextIntToken () |
| double | nextFloatToken () |
| std::string | nextToken (const string &delim) |
| std::string | remainingString () |
| std::string | filterNextToken (const string &filterStr) |
Private Attributes | |
| string | token_str |
| string | delim |
|
||||||||||||
|
|
|
|
Definition at line 9 of file StringTokenizer.h. 00009 {};
|
|
|
Definition at line 48 of file StringTokenizer.cpp. References delim, and token_str. 00049 {
00050
00051 unsigned int prev_pos = 0;
00052 int num_tokens = 0;
00053
00054
00055 if (token_str.length() > 0) {
00056 num_tokens = 0;
00057
00058 unsigned int curr_pos = 0;
00059 while (true) {
00060 if ((curr_pos = token_str.find(delim, curr_pos)) != std::string::npos) {
00061 num_tokens++;
00062 prev_pos = curr_pos;
00063 curr_pos += delim.length();
00064 } else
00065 break;
00066 }
00067 return ++num_tokens;
00068 } else {
00069 return 0;
00070 }
00071
00072 };
|
|
|
|
|
|
Definition at line 75 of file StringTokenizer.cpp. References token_str. 00076 {
00077 return (token_str.length() > 0);
00078 };
|
|
|
Definition at line 108 of file StringTokenizer.cpp. References nextToken(). 00109 {
00110 return atof(nextToken().c_str());
00111 };
|
|
|
Definition at line 102 of file StringTokenizer.cpp. References nextToken(). 00103 {
00104 return atoi(nextToken().c_str());
00105 };
|
|
|
|
|
|
Definition at line 81 of file StringTokenizer.cpp. References delim, and token_str. Referenced by nextFloatToken(), and nextIntToken(). 00082 {
00083
00084 if (token_str.length() == 0)
00085 return "";
00086
00087 std::string tmp_str = "";
00088 unsigned int pos = token_str.find(delim, 0);
00089
00090 if (pos != std::string::npos) {
00091 tmp_str = token_str.substr(0, pos);
00092 token_str = token_str.substr(pos + delim.length(), token_str.length() - pos);
00093 } else {
00094 tmp_str = token_str.substr(0, token_str.length());
00095 token_str = "";
00096 }
00097
00098 return tmp_str;
00099 };
|
|
|
Definition at line 134 of file StringTokenizer.cpp. References token_str. 00135 {
00136 return token_str;
00137 };
|
|
|
Definition at line 23 of file StringTokenizer.h. Referenced by countTokens(), and nextToken(). |
|
|
Definition at line 22 of file StringTokenizer.h. Referenced by countTokens(), hasMoreTokens(), nextToken(), and remainingString(). |
1.4.2