|
Home2L - C/C++ API v1.4-2-g83f4c (2025-08-23)
Smart Tools for a Private Home
|
Factory class to split a string into substrings.
Objects of this class are usually declared locally whereever a string needs to be split into substrings, for example, as in the argument analysis of a shell.
#include "base.H"
Public Member Functions | |
| CSplitString (const char *str, int maxArgc=INT_MAX, const char *sepChars=NULL) | |
Initialize, set and split str (see Set ()). | |
| void | Clear () |
| Clear the object (only necessary if another string is to be split) | |
| void | Set (const char *str, int maxArgc=INT_MAX, const char *sepChars=NULL) |
| Set and split a string. | |
| int | Entries () const |
| Get number of string after splitting. | |
| const char * | Get (int idx) const |
| Get one string. | |
| const char * | operator[] (int n) const |
| Get one string. | |
| int | GetOffset (int argNo) |
Get offset of argument number arg in the original string. | |
| int | GetOffset (const char *p) |
| Get offset of some character in some string in the original string. | |
| int | GetIdx (int pos) |
Get the argument number of character number pos of the original string. On error, -1 is returned, unless 'pos' points behind some existing argument, in which this (or the last) argument is returned. | |
|
inline |
Set and split a string.
| str | The string to split |
| maxArgc | Maximum number of strings to return. If more substrings are contained in the input the last ones are returned unsplit as a whole. |
| sepChars | Set of characters treated as separators. If NULL, whitespace characters are used as separators, and multiple of them count as a single separation. |