MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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:
43 ListParser() = default;
44
45
52 int init(const char* source) override;
53
59 std::pair<int, std::string> nextItem();
60
62 const char* getErrorMessage(int errorCode) override;
63
65 enum {
66 kMissingOpenBracket = kNumBaseErrorCodes,
69 kNumErrorCodes
70 };
71
72
74 static bool needsQuote(const char* itemStr);
75 static bool needsQuote(const std::string& itemStr);
76
77 static std::string quoteString(const std::string& itemStr);
78
79protected:
84 int unquoteString(std::string& itemString);
85};
86
88
89#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.