MeVisLab Toolbox Reference
ml::ParserBase Class Reference

Basic parser class from which special parser classes can be derived for parsing persistent state strings. More...

#include <mlParserBase.h>

Inheritance diagram for ml::ParserBase:
ml::BaseItemParser ml::ListParser

Public Types

enum  { kNoError = 0 , kEmptyString , kNumBaseErrorCodes , kEndOfSource = -1 }
 Error codes. More...
 

Public Member Functions

 ParserBase ()
 Constructor. More...
 
virtual ~ParserBase ()
 Make destructor virtual to avoid warnings. More...
 
virtual int init (const char *source)
 Initialize parser and proceed to first non-whitespace character. More...
 
const char * getCurrentPos ()
 Get current parser position. More...
 
bool endOfSource ()
 Return end-of-source flag. More...
 
virtual const char * getErrorMessage (int errorCode)
 Get error string for errorCode. More...
 

Static Public Member Functions

static char * newString (const std::string &str)
 Convenience method to create a copy of the string str allocated on the heap. More...
 
static void deleteString (char *str)
 Dispose a string allocated with newString() More...
 

Protected Member Functions

void skipWhitespace ()
 Proceed to next non-whitespace character. More...
 

Protected Attributes

const char * _source
 Source string. More...
 
const char * _pNext
 Pointer to current parser position. More...
 
bool _eos
 End-of-string flag. More...
 

Detailed Description

Basic parser class from which special parser classes can be derived for parsing persistent state strings.

Definition at line 36 of file mlParserBase.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Error codes.

Enumerator
kNoError 
kEmptyString 

Source string null or empty.

kNumBaseErrorCodes 

Highest error code +1.

kEndOfSource 

End of source reached.

Definition at line 60 of file mlParserBase.h.

Constructor & Destructor Documentation

◆ ParserBase()

ml::ParserBase::ParserBase ( )
inline

Constructor.

Definition at line 41 of file mlParserBase.h.

◆ ~ParserBase()

virtual ml::ParserBase::~ParserBase ( )
inlinevirtual

Make destructor virtual to avoid warnings.

Definition at line 44 of file mlParserBase.h.

Member Function Documentation

◆ deleteString()

static void ml::ParserBase::deleteString ( char *  str)
static

Dispose a string allocated with newString()

Referenced by ml::ListBase::deleteString().

◆ endOfSource()

bool ml::ParserBase::endOfSource ( )
inline

Return end-of-source flag.

Definition at line 54 of file mlParserBase.h.

◆ getCurrentPos()

const char* ml::ParserBase::getCurrentPos ( )
inline

Get current parser position.

Definition at line 51 of file mlParserBase.h.

◆ getErrorMessage()

virtual const char* ml::ParserBase::getErrorMessage ( int  errorCode)
virtual

Get error string for errorCode.

Reimplemented in ml::ListParser, and ml::BaseItemParser.

◆ init()

virtual int ml::ParserBase::init ( const char *  source)
virtual

Initialize parser and proceed to first non-whitespace character.

Returns kEmptyString for an empty or null source string.

Reimplemented in ml::ListParser.

◆ newString()

static char* ml::ParserBase::newString ( const std::string &  str)
static

Convenience method to create a copy of the string str allocated on the heap.

This avoids passing STL strings between modules, which fails in Windows due to a bug in the VC++ implementation of the STL.

Referenced by ml::ListBase::newString().

◆ skipWhitespace()

void ml::ParserBase::skipWhitespace ( )
protected

Proceed to next non-whitespace character.

Member Data Documentation

◆ _eos

bool ml::ParserBase::_eos
protected

End-of-string flag.

Definition at line 88 of file mlParserBase.h.

◆ _pNext

const char* ml::ParserBase::_pNext
protected

Pointer to current parser position.

Definition at line 86 of file mlParserBase.h.

◆ _source

const char* ml::ParserBase::_source
protected

Source string.

Definition at line 84 of file mlParserBase.h.


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