MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
mlParserBase.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_PARSER_BASE_H
14#define ML_PARSER_BASE_H
15
16
21
22// ML-includes
23#include "mlBaseInit.h"
24#include "mlModuleIncludes.h"
25
26
28
29
30// ------------------------------------------------------------------
31// Class ParserBase
32// ------------------------------------------------------------------
33
37{
38public:
41 : _source(nullptr)
42 , _pNext(nullptr)
43 , _eos(true)
44 {}
45
47 virtual ~ParserBase()
48 {}
49
52 virtual int init(const char* source);
53
55 const char* getCurrentPos()
56 {
57 return _pNext;
58 }
59
62 {
63 return _eos;
64 }
65
67 virtual const char* getErrorMessage(int errorCode);
68
70 enum {
71 kNoError = 0,
74 kEndOfSource = -1
75 };
76
77
81 static char* newString(const std::string& str);
82
84 static void deleteString(char* str);
85
86
87protected:
90
91
93 const char* _source;
95 const char* _pNext;
97 bool _eos;
98};
99
100
102
103#endif // __mlParserBase_H
Basic parser class from which special parser classes can be derived for parsing persistent state stri...
const char * _pNext
Pointer to current parser position.
@ kNumBaseErrorCodes
Highest error code +1.
@ kEmptyString
Source string null or empty.
static char * newString(const std::string &str)
Convenience method to create a copy of the string str allocated on the heap.
const char * getCurrentPos()
Get current parser position.
virtual const char * getErrorMessage(int errorCode)
Get error string for errorCode.
static void deleteString(char *str)
Dispose a string allocated with newString()
ParserBase()
Constructor.
bool _eos
End-of-string flag.
bool endOfSource()
Return end-of-source flag.
const char * _source
Source string.
virtual int init(const char *source)
Initialize parser and proceed to first non-whitespace character.
virtual ~ParserBase()
Make destructor virtual to avoid warnings.
void skipWhitespace()
Proceed to next non-whitespace character.
#define MLBASEEXPORT
defined Header file mlBaseInit.h
Definition mlBaseInit.h:22
Target mlrange_cast(Source arg)
Generic version of checked ML casts.