Parser class for parsing persistent state strings of list objects.
More...
#include <mlListParser.h>
|
| | ListParser ()=default |
| | Constructor.
|
| |
| int | init (const char *source) override |
| | Initialize parser and proceed to first character of first item.
|
| |
| std::pair< int, std::string > | nextItem () |
| | Return a string to next item's substring Return codes:
|
| |
| const char * | getErrorMessage (int errorCode) override |
| | Get error string for errorCode.
|
| |
| | ParserBase () |
| | Constructor.
|
| |
| virtual | ~ParserBase () |
| | Make destructor virtual to avoid warnings.
|
| |
| const char * | getCurrentPos () |
| | Get current parser position.
|
| |
| bool | endOfSource () |
| | Return end-of-source flag.
|
| |
|
| static bool | needsQuote (const char *itemStr) |
| | Return true if itemStr needs to be quoted.
|
| |
| static bool | needsQuote (const std::string &itemStr) |
| |
| static std::string | quoteString (const std::string &itemStr) |
| |
| static char * | newString (const std::string &str) |
| | Convenience method to create a copy of the string str allocated on the heap.
|
| |
| static void | deleteString (char *str) |
| | Dispose a string allocated with newString()
|
| |
|
| 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.
|
| |
| void | skipWhitespace () |
| | Proceed to next non-whitespace character.
|
| |
|
| const char * | _source |
| | Source string.
|
| |
| const char * | _pNext |
| | Pointer to current parser position.
|
| |
| bool | _eos |
| | End-of-string flag.
|
| |
Parser class for parsing persistent state strings of list objects.
Definition at line 39 of file mlListParser.h.
◆ anonymous enum
Error codes.
| Enumerator |
|---|
| kMissingOpenBracket | |
| kMissingCloseBracket | |
| kUnmatchedQuote | |
| kNumErrorCodes | Highest error code +1.
|
Definition at line 66 of file mlListParser.h.
◆ ListParser()
| ml::ListParser::ListParser |
( |
| ) |
|
|
default |
◆ getErrorMessage()
| const char * ml::ListParser::getErrorMessage |
( |
int |
errorCode | ) |
|
|
overridevirtual |
◆ init()
| int ml::ListParser::init |
( |
const char * |
source | ) |
|
|
overridevirtual |
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().
◆ needsQuote() [1/2]
| static bool ml::ListParser::needsQuote |
( |
const char * |
itemStr | ) |
|
|
static |
Return true if itemStr needs to be quoted.
◆ needsQuote() [2/2]
| static bool ml::ListParser::needsQuote |
( |
const std::string & |
itemStr | ) |
|
|
static |
◆ nextItem()
| std::pair< int, std::string > ml::ListParser::nextItem |
( |
| ) |
|
◆ quoteString()
| static std::string ml::ListParser::quoteString |
( |
const std::string & |
itemStr | ) |
|
|
static |
◆ unquoteString()
| 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: