Home2L - C/C++ API  v1.2-2-ga4fe (2023-04-15)
Smart Tools for a Private Home
Public Member Functions | List of all members
CSplitString Class Reference

Description

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.

Definition at line 819 of file base.H.

#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. More...
 
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.
 

Member Function Documentation

◆ Set()

void CSplitString::Set ( const char *  str,
int  maxArgc = INT_MAX,
const char *  sepChars = NULL 
)
inline

Set and split a string.

Parameters
strThe string to split
maxArgcMaximum number of strings to return. If more substrings are contained in the input the last ones are returned unsplit as a whole.
sepCharsSet of characters treated as separators

Definition at line 829 of file base.H.


The documentation for this class was generated from the following file: