#include <evo/strtok.h>
String reverse tokenizer (strict).
- Variants: StrTokWordRS
- This does not skip whitespace so tokens may start or end with whitespace
- This references target string data – results are undefined if target string is modified while referenced
- For forward "strict" tokenizing see: StrTokS
- For "non-strict" tokenizing (skipping whitespace) see: StrTokR, StrTok
- Note: All tokenizers (including forward and reverse) implement the same basic interface (excluding
next*()
variants)
Example:
int main() {
while (tok.next(','))
return 0;
}
|
template<class C , class T > |
static C::Size | split (C &items, const T &str, char delim=',') |
| Split delimited string into item list using next() (in reverse order). More...
|
|
template<class T > |
static SubString | splitat (const T &str, Size index, char delim=',') |
| Split delimited string to extract token at index (in reverse order). More...
|
|
◆ BaseType
◆ Size
◆ ThisType
◆ StrTokRS() [1/4]
Default constructor creates empty tokenizer.
◆ StrTokRS() [2/4]
Copy constructor.
- Parameters
-
◆ StrTokRS() [3/4]
Copy constructor.
- Parameters
-
◆ StrTokRS() [4/4]
Constructor to start tokenizing given string.
Call next() or nextw() for each token.
- Parameters
-
◆ copy()
◆ delim()
Get current delimiter before next token.
- Returns
- Current delimiter, null if none or at end
◆ index()
Get current index before next token.
- Returns
- Current index, END if at end
◆ next()
Find next token using delimiter (in reverse order).
Call value() to get token value.
- Parameters
-
- Returns
- Whether next token was found, false if no more
◆ nextany()
Find next token using any of given delimiters (in reverse order).
Call value() to get token value.
- Parameters
-
- Returns
- Whether next token was found, false if no more
◆ nextw()
Find next token using word delimiter (in reverse order).
Call value() to get token value.
- Same as next(char) except duplicate delimiters are skipped
- Parameters
-
- Returns
- Whether next token was found, false if no more
◆ operator=() [1/3]
Assignment/Copy operator.
- Parameters
-
- Returns
- This
◆ operator=() [2/3]
Assignment/Copy operator.
- Parameters
-
- Returns
- This
◆ operator=() [3/3]
Assignment operator to start tokenizing given string from end.
Call next() or nextw() for each token.
- Parameters
-
- Returns
- This
◆ reset()
Reset to tokenize from beginning of string.
- Returns
- This
◆ split()
static C::Size split |
( |
C & |
items, |
|
|
const T & |
str, |
|
|
char |
delim = ',' |
|
) |
| |
|
inlinestatic |
Split delimited string into item list using next() (in reverse order).
- This tokenizes and adds each item to list, using convert() for conversion to list item type
- String must be convertible to list item type via convert()
- See String::join() to join list back into string
- Template Parameters
-
C | List container for items – inferred from items parameter |
T | String type to split – inferred from str parameter |
- Parameters
-
items | List to add items to [in/out] |
str | String to tokenize |
delim | Delimiter to use |
◆ splitat()
static SubString splitat |
( |
const T & |
str, |
|
|
Size |
index, |
|
|
char |
delim = ',' |
|
) |
| |
|
inlinestatic |
Split delimited string to extract token at index (in reverse order).
- This will tokenize until token at index is found
- Template Parameters
-
T | String type to tokenize – inferred from str parameter |
- Parameters
-
str | String to tokenize |
index | Token index to extract |
delim | Delimiter to use |
- Returns
- Result token, set to null if not found
◆ value()
Get current token value from last call to next().
- Returns
- Current token value
◆ delim_
Current delimiter, null when none or at end.
◆ index_
Current index, END when at end.
◆ string_
String being tokenized, NULL for none
◆ value_
The documentation for this class was generated from the following file: