MeVisLab Toolbox Reference
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 
27 ML_START_NAMESPACE
28 
29 
30 // ------------------------------------------------------------------
31 // Class ParserBase
32 // ------------------------------------------------------------------
33 
37 {
38 public:
39 
41  ParserBase () : _source(nullptr), _pNext(nullptr), _eos(true) {}
42 
44  virtual ~ParserBase() {}
45 
48  virtual int init (const char *source);
49 
51  const char *getCurrentPos () { return _pNext; }
52 
54  bool endOfSource () { return _eos; }
55 
57  virtual const char *getErrorMessage (int errorCode);
58 
60  enum {
61  kNoError = 0,
64  kEndOfSource = -1
65  };
66 
67 
71  static char *newString (const std::string &str);
72 
74  static void deleteString (char *str);
75 
76 
77 protected:
78 
80  void skipWhitespace ();
81 
82 
84  const char *_source;
86  const char *_pNext;
88  bool _eos;
89 
90 };
91 
92 
93 ML_END_NAMESPACE
94 
95 #endif // __mlParserBase_H
Basic parser class from which special parser classes can be derived for parsing persistent state stri...
Definition: mlParserBase.h:37
const char * _pNext
Pointer to current parser position.
Definition: mlParserBase.h:86
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.
Definition: mlParserBase.h:51
@ kNumBaseErrorCodes
Highest error code +1.
Definition: mlParserBase.h:63
@ kEmptyString
Source string null or empty.
Definition: mlParserBase.h:62
static void deleteString(char *str)
Dispose a string allocated with newString()
ParserBase()
Constructor.
Definition: mlParserBase.h:41
bool _eos
End-of-string flag.
Definition: mlParserBase.h:88
bool endOfSource()
Return end-of-source flag.
Definition: mlParserBase.h:54
const char * _source
Source string.
Definition: mlParserBase.h:84
virtual int init(const char *source)
Initialize parser and proceed to first non-whitespace character.
virtual const char * getErrorMessage(int errorCode)
Get error string for errorCode.
virtual ~ParserBase()
Make destructor virtual to avoid warnings.
Definition: mlParserBase.h:44
void skipWhitespace()
Proceed to next non-whitespace character.
#define MLBASEEXPORT
defined Header file mlBaseInit.h
Definition: mlBaseInit.h:22
boost::graph_traits< ml_graph_ptr >::vertex_descriptor source(graph_traits< ml_graph_ptr >::edge_descriptor e, const ml_graph_ptr)
Returns the vertex descriptor for u of the edge (u,v) represented by e.