MeVisLabToolboxReference
ml::ListParser Class Reference

Parser class for parsing persistent state strings of list objects. More...

#include <mlListParser.h>

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

List of all members.

Public Types

enum  { kMissingOpenBracket = kNumBaseErrorCodes, kMissingCloseBracket, kUnmatchedQuote, kNumErrorCodes }
 Error codes. More...

Public Member Functions

 ListParser ()
 Constructor.
virtual int init (const char *source)
 Initialize parser and proceed to first character of first item.
int nextItemString (char *&itemString)
 Set itemString to next item's substring Return codes:
virtual const char * getErrorMessage (int errorCode)
 Get error string for errorCode.

Static Public Member Functions

static bool needsQuote (char *itemStr)
 Return true if itemStr needs to be quoted.
static char * quoteString (char *itemStr)
 Return a quoted copy of itemStr allocated on the heap.

Protected Member Functions

int unquoteString (std::string &itemString)
 Convert quoted string to original, unescaped character sequence Assumes that _pNext points to a leading quote, proceeds to the first character after the terminating quote.

Detailed Description

Parser class for parsing persistent state strings of list objects.

Definition at line 42 of file mlListParser.h.


Member Enumeration Documentation

anonymous enum

Error codes.

Enumerator:
kMissingOpenBracket 
kMissingCloseBracket 
kUnmatchedQuote 
kNumErrorCodes 

Highest error code +1.

Definition at line 69 of file mlListParser.h.


Constructor & Destructor Documentation

ml::ListParser::ListParser ( ) [inline]

Constructor.

Definition at line 47 of file mlListParser.h.


Member Function Documentation

virtual const char* ml::ListParser::getErrorMessage ( int  errorCode) [virtual]

Get error string for errorCode.

Reimplemented from ml::ParserBase.

Referenced by ml::ListTemplate< T >::setPersistentState().

virtual int ml::ListParser::init ( const char *  source) [virtual]

Initialize parser and proceed to first character of first item.

Return codes:

  • kEmptyString for an empty or null source string,
  • kEndOfSource for an empty list ("[]")
  • kMissingOpenBracket for a non-empty string not beginning with '['
  • kMissingCloseBracket for a string containing only "["

Reimplemented from ml::ParserBase.

Referenced by ml::ListTemplate< T >::setPersistentState().

static bool ml::ListParser::needsQuote ( char *  itemStr) [static]

Return true if itemStr needs to be quoted.

int ml::ListParser::nextItemString ( char *&  itemString)

Set itemString to next item's substring Return codes:

  • kEndOfSource if no next item exists
  • kMissingCloseBracket if string ends without closing bracket
  • Any return code of unquoteString()

Referenced by ml::ListTemplate< T >::setPersistentState().

static char* ml::ListParser::quoteString ( char *  itemStr) [static]

Return a quoted copy of itemStr allocated on the heap.

int ml::ListParser::unquoteString ( std::string &  itemString) [protected]

Convert quoted string to original, unescaped character sequence Assumes that _pNext points to a leading quote, proceeds to the first character after the terminating quote.

Return kUnmatchedQuote if strings ends without terminating quote.


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