30 nextPos (_strParser.nextPos),
32 trimWhiteSpace (_strParser.trimWhiteSpace),
36 if (_strParser.whiteSpace)
37 whiteSpace =
STRDUP (_strParser.whiteSpace
);
46 trimWhiteSpace (
false),
58 trimWhiteSpace (
false),
70 trimWhiteSpace (
false),
100 trimWhiteSpace =
true;
113 while ((nextPos < len) && (strchr (whiteSpace, str[nextPos]) != NULL))
122 while (MoreTokens ())
123 tokens.push_back (
this->GetNextToken (delStr));
137 while ((nextPos < len) && (strchr (whiteSpace, str[nextPos]) != NULL))
147 char ch = str[endPos];
148 if ((ch ==
'\'') || (ch ==
'"'))
163 if ((ch ==
'\\') && (endPos < (len - 1)))
166 char ec = str[endPos];
169 case '\\': ch =
'\\';
break;
170 case '"': ch =
'"';
break;
171 case 'r': ch =
'\r';
break;
172 case 'n': ch =
'\n';
break;
173 case 't': ch =
'\t';
break;
188 nextPos = endPos + 1;
191 while ((nextPos < len) && (strchr (whiteSpace, str[nextPos]) != NULL))
195 if ((nextPos < len) && (strchr (delStr, str[nextPos]) != NULL))
197 lastDelimiter = str[nextPos];
207 bool delimeterFound =
false;
211 if (strchr (delStr, ch) != NULL)
214 delimeterFound =
true;
215 delimeterIdx = endPos;
225 while ((endPos >= startPos) && (strchr (whiteSpace, str[endPos]) != NULL))
231 nextPos = delimeterIdx + 1;
233 else if (endPos >= len)
237 nextPos = endPos + 1;
241 while ((nextPos < len) && (strchr (whiteSpace, str[nextPos]) != NULL))
264 while ((nextPos < len) && (strchr (whiteSpace, str[nextPosP]) != NULL))
274 char ch = str[endPos];
275 if ((ch ==
'\'') || (ch ==
'"'))
291 if ((ch ==
'\\') && (endPos < (len - 1)))
294 char ec = str[endPos];
297 case '"': ch =
'"';
break;
298 case '\\': ch =
'\\';
break;
299 case 'r': ch =
'\r';
break;
300 case 'n': ch =
'\n';
break;
301 case 't': ch =
'\t';
break;
316 if (strchr (delStr, ch) != NULL)
327 while ((endPos >= startPos) && (strchr (whiteSpace, str[endPos]) != NULL))
342 nextChar = str[nextPos];
368 nextChar = str[nextPos];
380 lastChar = str[len - 1];
391 char nextTokenChar = nextToken
[0
];
392 return nextTokenChar;
449 while ((nextPos < len) && (strchr (whiteSpace, str[nextPos]) != NULL))
456 KKStr result
(1 + len - nextPos
);
459 while (nextPos < len)
461 lastChar = str[nextPos];
462 if (lastChar ==
'\n')
465 else if (lastChar ==
'\r')
474 if (lastChar ==
'\n')
476 if (str[nextPos] ==
'\r')
479 else if (lastChar ==
'\r')
481 if (str[nextPos] ==
'\n')
498 while ((nextPos < len) && (strchr (whiteSpace, str[nextPos]) != NULL))
505 KKStr result
(1 + len - nextPos
);
506 while (nextPos < len)
532 if (lastChar < firstChar)
535 kkuint32 subStrLen = (1 + lastChar - firstChar);
542 for (idx = firstChar; idx <= lastChar; idx++)
KKStr(kkint32 size)
Creates a KKStr object that pre-allocates space for 'size' characters.
bool GetNextTokenBool(const char *delStr="\n\t\r ")
char * STRDUP(const char *src)
KKStr SubStrPart(kkuint32 firstChar, kkuint32 lastChar) const
void TrimWhiteSpace(const char *_whiteSpace=" ")
After this call all leading and trailing whitespace will be trimmed from tokens.
KKStrParser(const KKStrParser &_strParser)
KKStr & TrimRight(const char *whiteSpaceChars="\n\r\t ")
KKStr GetNextToken(const char *delStr="\n\t\r ")
Extract next Token from string, tokens will be separated by delimiter characters. ...
KKStrParser(KKStr &&_str)
long GetNextTokenLong(const char *delStr="\n\t\r ")
unsigned __int32 kkuint32
float GetNextTokenFloat(const char *delStr="\n\t\r ")
kkuint32 Len() const
Returns the number of characters in the string.
char PeekNextChar() const
KKStrParser(const KKStr &_str)
void SkipWhiteSpace(const char *whiteSpace=" ")
Advances the next-character pointer to the next NOT white space character.
char PeekLastChar() const
VectorKKStr Split(const char *delStr="\n\t\r ")
KKStr PeekNextToken(const char *delStr="\n\t\r ") const
Will use the same rules as "GetNextToken" to retrieve the next token n the string but will not advanc...
kkuint32 GetNextTokenUint(const char *delStr="\n\t\r ")
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of 'std::string' strings.
KKStr(const char *src, kkuint32 startPos, kkuint32 endPos)
Constructs a KKStr instance from a sub-string of 'src'.
KKB::DateTime GetNextTokenDateTime(const char *delStr="\n\t\r ")
static const KKStr & EmptyStr()
Static method that returns an Empty String.
double GetNextTokenDouble(const char *delStr="\n\t\r ")
kkint32 GetNextTokenInt(const char *delStr="\n\t\r ")
const char * Str() const
Returns a pointer to a ascii string.
char operator[](kkint32 i) const
Class that manages the extraction of tokens from a String without being destructive to the original s...
bool ToBool() const
Returns the bool equivalent of the string, ex 'Yes' = true, 'No' = false, 'True' = true...
char GetNextTokenChar(const char *delStr="\n\t\r ")
KKStrParser(const char *_str)