![]() |
KSquare Utilities
|
Class that manages the extraction of tokens from a String without being destructive to the original string. More...
#include <KKStrParser.h>
Public Member Functions | |
| KKStrParser (const KKStrParser &_strParser) | |
| KKStrParser (const char *_str) | |
| KKStrParser (const KKStr &_str) | |
| KKStrParser (KKStr &&_str) | |
| ~KKStrParser () | |
| char | GetLastChar () |
| char | GetNextChar () |
| KKStr | GetNextToken (const char *delStr="\n\t\r ") |
| Extract next Token from string, tokens will be separated by delimiter characters. More... | |
| bool | GetNextTokenBool (const char *delStr="\n\t\r ") |
| char | GetNextTokenChar (const char *delStr="\n\t\r ") |
| KKB::DateTime | GetNextTokenDateTime (const char *delStr="\n\t\r ") |
| double | GetNextTokenDouble (const char *delStr="\n\t\r ") |
| float | GetNextTokenFloat (const char *delStr="\n\t\r ") |
| kkint32 | GetNextTokenInt (const char *delStr="\n\t\r ") |
| long | GetNextTokenLong (const char *delStr="\n\t\r ") |
| kkuint32 | GetNextTokenUint (const char *delStr="\n\t\r ") |
| KKStr | GetRestOfLine () |
| KKStr | GetRestOfStr () |
| char | LastDelimiter () const |
| bool | MoreTokens () const |
| char | PeekLastChar () const |
| char | PeekNextChar () const |
| 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 advance the next character pointer. More... | |
| void | Reset () |
| void | SkipWhiteSpace (const char *whiteSpace=" ") |
| Advances the next-character pointer to the next NOT white space character. More... | |
| VectorKKStr | Split (const char *delStr="\n\t\r ") |
| const char * | Str () const |
| 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. More... | |
Class that manages the extraction of tokens from a String without being destructive to the original string.
Definition at line 18 of file KKStrParser.h.
| KKStrParser::KKStrParser | ( | const KKStrParser & | _strParser | ) |
Definition at line 28 of file KKStrParser.cpp.
References KKStrParser(), and KKB::STRDUP().
Referenced by KKStrParser().
| KKStrParser::KKStrParser | ( | const char * | _str | ) |
Definition at line 54 of file KKStrParser.cpp.
References KKStrParser().
Referenced by KKStrParser(), and KKB::KKStr::ToVectorInt32().
| KKStrParser::KKStrParser | ( | const KKStr & | _str | ) |
Definition at line 42 of file KKStrParser.cpp.
References KKB::KKStr::Len(), and KKB::KKStr::Str().
Referenced by KKB::DateTime::DateTime(), KKMLL::MLClassIndexList::ParseClassIndexList(), KKMLL::AttributeTypeVector::ReadXML(), KKB::VectorKKStr::ReadXML(), KKMLL::ClassProbList::ReadXML(), SVM233::SvmModel233::ReadXML(), KKB::KKStrList::ReadXML(), KKB::KKStrListIndexed::ReadXML(), KKB::XmlElementKeyValuePairs::XmlElementKeyValuePairs(), KKMLL::XmlElementMLClassNameList::XmlElementMLClassNameList(), and KKB::XmlTag::XmlTag().
| KKStrParser::KKStrParser | ( | KKStr && | _str | ) |
Definition at line 66 of file KKStrParser.cpp.
References KKB::KKStr::Len(), KKB::KKStr::Str(), and KKB::STRDUP().
| KKStrParser::~KKStrParser | ( | ) |
Definition at line 82 of file KKStrParser.cpp.
| char KKStrParser::GetLastChar | ( | ) |
Definition at line 350 of file KKStrParser.cpp.
Referenced by KKB::XmlTag::XmlTag().
| char KKStrParser::GetNextChar | ( | ) |
Definition at line 337 of file KKStrParser.cpp.
Referenced by KKB::XmlTag::XmlTag().
| KKStr KKStrParser::GetNextToken | ( | const char * | delStr = "\n\t\r " | ) |
Extract next Token from string, tokens will be separated by delimiter characters.
Removes next Token from string. The token will be terminated by end of string or the first occurrence of a delimiter character. If no more tokens left will return a Empty KKStr. If you want to remove leading and trailing whitespace characters you need to call the "TrimWhiteSpace" method.
Quoted Strings will be treated differently. If the first character in the token is a quote(") or apostrophe(') character then the token will include all characters until the matching quote character. The quote characters will be NOT be included in the token. The next character pointer will be set to the following delimiter character. The quote characters must match. That is if the first quote character was (') then the terminating quote character also be ('). The special escape sequences ("\t", "\n", "\r", "\\", '"', and "\'" will be translated into (tab), (line-feed), (carriage-return), (back-slash), (quote), and (apostrophe).
| [in] | delStr | List of delimiter characters. |
Definition at line 131 of file KKStrParser.cpp.
References KKB::KKStr::Append(), KKB::KKStr::Concat(), KKB::KKStr::EmptyStr(), and KKB::KKStr::KKStr().
Referenced by KKB::DateTime::DateTime(), GetNextTokenBool(), GetNextTokenChar(), GetNextTokenDateTime(), GetNextTokenDouble(), GetNextTokenFloat(), GetNextTokenInt(), GetNextTokenLong(), GetNextTokenUint(), KKMLL::MLClassIndexList::ParseClassIndexList(), KKMLL::AttributeTypeVector::ReadXML(), KKB::VectorKKStr::ReadXML(), KKMLL::ClassProbList::ReadXML(), SVM233::SvmModel233::ReadXML(), KKB::KKStrList::ReadXML(), KKB::KKStrListIndexed::ReadXML(), KKB::KKStr::ToVectorInt32(), KKB::XmlElementKeyValuePairs::XmlElementKeyValuePairs(), KKMLL::XmlElementMLClassNameList::XmlElementMLClassNameList(), and KKB::XmlTag::XmlTag().
| bool KKStrParser::GetNextTokenBool | ( | const char * | delStr = "\n\t\r " | ) |
Definition at line 438 of file KKStrParser.cpp.
References GetNextToken(), and KKB::KKStr::ToBool().
| char KKStrParser::GetNextTokenChar | ( | const char * | delStr = "\n\t\r " | ) |
Definition at line 388 of file KKStrParser.cpp.
References KKB::KKStr::Concat(), GetNextToken(), and KKB::KKStr::operator[]().
| KKB::DateTime KKStrParser::GetNextTokenDateTime | ( | const char * | delStr = "\n\t\r " | ) |
Definition at line 396 of file KKStrParser.cpp.
References KKB::DateTime::DateTime(), and GetNextToken().
| double KKStrParser::GetNextTokenDouble | ( | const char * | delStr = "\n\t\r " | ) |
Definition at line 418 of file KKStrParser.cpp.
References GetNextToken(), and KKB::KKStr::ToDouble().
Referenced by KKMLL::ClassProbList::ReadXML(), and SVM233::SvmModel233::ReadXML().
| float KKStrParser::GetNextTokenFloat | ( | const char * | delStr = "\n\t\r " | ) |
Definition at line 424 of file KKStrParser.cpp.
References GetNextToken(), and KKB::KKStr::ToFloat().
Referenced by KKMLL::ClassProbList::ReadXML().
| kkint32 KKStrParser::GetNextTokenInt | ( | const char * | delStr = "\n\t\r " | ) |
Definition at line 404 of file KKStrParser.cpp.
References GetNextToken(), and KKB::KKStr::ToInt().
Referenced by KKMLL::AttributeTypeVector::ReadXML(), and SVM233::SvmModel233::ReadXML().
| long KKStrParser::GetNextTokenLong | ( | const char * | delStr = "\n\t\r " | ) |
Definition at line 411 of file KKStrParser.cpp.
References GetNextToken(), and KKB::KKStr::ToLong().
| kkuint32 KKStrParser::GetNextTokenUint | ( | const char * | delStr = "\n\t\r " | ) |
Definition at line 431 of file KKStrParser.cpp.
References GetNextToken(), and KKB::KKStr::ToUint().
| KKStr KKStrParser::GetRestOfLine | ( | ) |
Definition at line 445 of file KKStrParser.cpp.
References KKB::KKStr::Append(), KKB::KKStr::Concat(), KKB::KKStr::EmptyStr(), KKB::KKStr::KKStr(), and KKB::KKStr::TrimRight().
| KKStr KKStrParser::GetRestOfStr | ( | ) |
Definition at line 494 of file KKStrParser.cpp.
References KKB::KKStr::Append(), KKB::KKStr::Concat(), KKB::KKStr::EmptyStr(), KKB::KKStr::KKStr(), and KKB::KKStr::TrimRight().
Referenced by KKB::DateTime::DateTime().
|
inline |
Definition at line 72 of file KKStrParser.h.
Referenced by KKMLL::MLClassIndexList::ParseClassIndexList().
|
inline |
Definition at line 74 of file KKStrParser.h.
Referenced by KKMLL::MLClassIndexList::ParseClassIndexList(), KKMLL::AttributeTypeVector::ReadXML(), KKB::VectorKKStr::ReadXML(), SVM233::SvmModel233::ReadXML(), KKB::KKStrList::ReadXML(), KKB::KKStrListIndexed::ReadXML(), KKB::XmlElementKeyValuePairs::XmlElementKeyValuePairs(), KKMLL::XmlElementMLClassNameList::XmlElementMLClassNameList(), and KKB::XmlTag::XmlTag().
| char KKStrParser::PeekLastChar | ( | ) | const |
Definition at line 375 of file KKStrParser.cpp.
Referenced by KKB::XmlTag::XmlTag().
| char KKStrParser::PeekNextChar | ( | ) | const |
Definition at line 363 of file KKStrParser.cpp.
Referenced by KKB::XmlTag::XmlTag().
| KKStr KKStrParser::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 advance the next character pointer.
Returns what the next token that 'GetNextToken' will without updating the position in the string buffer.
Allows you to see what the token would be without updating the KKStrParser instance.
| [in] | delStr | List of delimiting characters. |
Definition at line 258 of file KKStrParser.cpp.
References KKB::KKStr::Append(), KKB::KKStr::Concat(), KKB::KKStr::EmptyStr(), and KKB::KKStr::KKStr().
| void KKStrParser::Reset | ( | ) |
Definition at line 520 of file KKStrParser.cpp.
| void KKStrParser::SkipWhiteSpace | ( | const char * | whiteSpace = " " | ) |
Advances the next-character pointer to the next NOT white space character.
Definition at line 111 of file KKStrParser.cpp.
Referenced by TrimWhiteSpace(), and KKB::XmlTag::XmlTag().
| VectorKKStr KKStrParser::Split | ( | const char * | delStr = "\n\t\r " | ) |
Definition at line 119 of file KKStrParser.cpp.
|
inline |
Definition at line 96 of file KKStrParser.h.
Definition at line 528 of file KKStrParser.cpp.
References KKB::KKStr::Append(), KKB::KKStr::Concat(), KKB::KKStr::EmptyStr(), and KKB::KKStr::KKStr().
| void KKStrParser::TrimWhiteSpace | ( | const char * | _whiteSpace = " " | ) |
After this call all leading and trailing whitespace will be trimmed from tokens.
The next character pointer will be advanced to the next NON whitespace character.
Definition at line 95 of file KKStrParser.cpp.
References SkipWhiteSpace(), and KKB::STRDUP().
Referenced by KKMLL::MLClassIndexList::ParseClassIndexList(), KKMLL::AttributeTypeVector::ReadXML(), KKB::VectorKKStr::ReadXML(), KKMLL::ClassProbList::ReadXML(), SVM233::SvmModel233::ReadXML(), KKB::KKStrList::ReadXML(), KKB::XmlElementKeyValuePairs::XmlElementKeyValuePairs(), KKMLL::XmlElementMLClassNameList::XmlElementMLClassNameList(), and KKB::XmlTag::XmlTag().