MeVisLab Toolbox Reference
mlListParser.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_LIST_PARSER_H
14#define ML_LIST_PARSER_H
15
18
19// - ParserBase is a base class from which special parser classes can be derived.
20// - ListParser (derived from ParserBase) is a parser class for parsing persistent
21// state strings of list objects.
22// - BaseItemParser (derived from ParserBase) is a parser class for BaseItem strings.
23
24// ML-includes
25#include "mlBaseInit.h"
26#include "mlParserBase.h"
27
28// For backward compatibility also include BaseItemParser.
29#include "mlBaseItemParser.h"
30
31
33
34// ------------------------------------------------------------------
35// Class ListParser
36// ------------------------------------------------------------------
37
40{
41public:
42
44 ListParser() = default;
45
46
53 int init (const char *source) override;
54
60 std::pair<int, std::string> nextItem();
61
63 const char *getErrorMessage (int errorCode) override;
64
66 enum {
67 kMissingOpenBracket = kNumBaseErrorCodes,
70 kNumErrorCodes
71 };
72
73
75 static bool needsQuote(const char *itemStr);
76 static bool needsQuote(const std::string& itemStr);
77
78 static std::string quoteString(const std::string& itemStr);
79
80protected:
81
86 int unquoteString (std::string &itemString);
87
88};
89
91
92#endif // __mlListParser_H
Parser class for parsing persistent state strings of list objects.
const char * getErrorMessage(int errorCode) override
Get error string for errorCode.
int unquoteString(std::string &itemString)
Convert quoted string to original, unescaped character sequence Assumes that _pNext points to a leadi...
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)
std::pair< int, std::string > nextItem()
Return a string to next item's substring Return codes:
ListParser()=default
Constructor.
int init(const char *source) override
Initialize parser and proceed to first character of first item.
Basic parser class from which special parser classes can be derived for parsing persistent state stri...
@ kNumBaseErrorCodes
Highest error code +1.
#define MLBASEEXPORT
defined Header file mlBaseInit.h
Definition mlBaseInit.h:22
Target mlrange_cast(Source arg)
Generic version of checked ML casts.