ddc
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
StringTokenizer Class Reference

#include <ddcString.h>

Public Member Functions

 StringTokenizer (const char *_text, const char *_delims=" \\)
 
 StringTokenizer (const std::string &_text, const std::string &_delims)
 ! moo: constructor from std::string (implicitly calls c_str() on arguments) More...
 
 ~StringTokenizer ()
 
void initialize (const char *_text, const char *_delims=" \\)
 
void reinitialize (const char *_text, const char *_delims=" \\)
 
void initialize (const std::string &_text, const std::string &_delims)
 ! moo: initialize from std::string (copies) More...
 
const char * operator() ()
 
std::string next_token ()
 
const char * get_rest () const
 
const char * val () const
 
int count () const
 
bool has_next () const
 
void get_tokens (std::vector< std::string > &tokens)
 moo: append all remaining tokens to a string vector (consumes the rest of the source string) More...
 
const char * get_rest_trim ()
 moo: get all remaining text as a single token, trimming any initial or trailing delimiters More...
 

Protected Member Functions

bool is_delim (char ch) const
 

Protected Attributes

char * text_ptr
 
char * text
 
int i
 
std::string delims
 
char * _val
 

Detailed Description

old string tokenizer from ../CommonLib/util_classes.h, utilit.cpp, rsp. ../CommonLib/string_tokenizer.h see also stringSplitE() from utilit.cpp re-entrant replacement of strtok().

Usage (C-strings): char *text = "word, word2;word3" CStringTokenizer token(text, " ,;"); const char *word; while((word = token())){ handle token here }

Constructor & Destructor Documentation

◆ StringTokenizer() [1/2]

StringTokenizer::StringTokenizer ( const char *  _text,
const char *  _delims = " \t\r\n" 
)

◆ StringTokenizer() [2/2]

StringTokenizer::StringTokenizer ( const std::string &  _text,
const std::string &  _delims 
)
inline

! moo: constructor from std::string (implicitly calls c_str() on arguments)

References initialize(), reinitialize(), and ~StringTokenizer().

Here is the call graph for this function:

◆ ~StringTokenizer()

StringTokenizer::~StringTokenizer ( )

Referenced by StringTokenizer().

Here is the caller graph for this function:

Member Function Documentation

◆ is_delim()

bool StringTokenizer::is_delim ( char  ch) const
inlineprotected

◆ initialize() [1/2]

void StringTokenizer::initialize ( const char *  _text,
const char *  _delims = " \t\r\n" 
)

Referenced by initialize(), and StringTokenizer().

Here is the caller graph for this function:

◆ reinitialize()

void StringTokenizer::reinitialize ( const char *  _text,
const char *  _delims = " \t\r\n" 
)

Referenced by StringTokenizer().

Here is the caller graph for this function:

◆ initialize() [2/2]

void StringTokenizer::initialize ( const std::string &  _text,
const std::string &  _delims 
)
inline

! moo: initialize from std::string (copies)

References initialize(), next_token(), and operator()().

Here is the call graph for this function:

◆ operator()()

const char * StringTokenizer::operator() ( )

Referenced by initialize().

Here is the caller graph for this function:

◆ next_token()

std::string StringTokenizer::next_token ( )

◆ get_rest()

const char* StringTokenizer::get_rest ( ) const
inline

References text.

Referenced by GetValue().

Here is the caller graph for this function:

◆ val()

const char* StringTokenizer::val ( ) const
inline

◆ count()

int StringTokenizer::count ( ) const
inline

References i.

◆ has_next()

bool StringTokenizer::has_next ( ) const
inline

References get_rest_trim(), and get_tokens().

Here is the call graph for this function:

◆ get_tokens()

void StringTokenizer::get_tokens ( std::vector< std::string > &  tokens)

moo: append all remaining tokens to a string vector (consumes the rest of the source string)

Referenced by has_next(), and stringSplit().

Here is the caller graph for this function:

◆ get_rest_trim()

const char * StringTokenizer::get_rest_trim ( )

moo: get all remaining text as a single token, trimming any initial or trailing delimiters

Referenced by has_next().

Here is the caller graph for this function:

Member Data Documentation

◆ text_ptr

char* StringTokenizer::text_ptr
protected

◆ text

char* StringTokenizer::text
protected

Referenced by get_rest().

◆ i

int StringTokenizer::i
protected

Referenced by count().

◆ delims

std::string StringTokenizer::delims
protected

◆ _val

char* StringTokenizer::_val
protected

Referenced by val().


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