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 
32 ML_START_NAMESPACE
33 
34 // ------------------------------------------------------------------
35 // Class ListParser
36 // ------------------------------------------------------------------
37 
40 {
41 public:
42 
44  ListParser() = default;
45 
46 
53  int init (const char *source) override;
54 
55 #if !ML_DEPRECATED_SINCE(3,5,0)
56 private:
57 #endif
64  [[deprecated]] int nextItemString (char *&itemString);
65 
66 #if !ML_DEPRECATED_SINCE(3,5,0)
67 public:
68 #endif
69 
70 
76  std::pair<int, std::string> nextItem();
77 
79  const char *getErrorMessage (int errorCode) override;
80 
82  enum {
83  kMissingOpenBracket = kNumBaseErrorCodes,
86  kNumErrorCodes
87  };
88 
89 
91  static bool needsQuote(const char *itemStr);
92  static bool needsQuote(const std::string& itemStr);
93 
94 #if !ML_DEPRECATED_SINCE(3,5,0)
95 private:
96 #endif
98  [[deprecated]] static char *quoteString(const char *itemStr);
99 #if !ML_DEPRECATED_SINCE(3,5,0)
100 public:
101 #endif
102 
103 
104  static std::string quoteString(const std::string& itemStr);
105 
106 
107 protected:
108 
113  int unquoteString (std::string &itemString);
114 
115 };
116 
117 ML_END_NAMESPACE
118 
119 #endif // __mlListParser_H
Parser class for parsing persistent state strings of list objects.
Definition: mlListParser.h:40
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.
const char * getErrorMessage(int errorCode) override
Get error string for errorCode.
Basic parser class from which special parser classes can be derived for parsing persistent state stri...
Definition: mlParserBase.h:37
@ kNumBaseErrorCodes
Highest error code +1.
Definition: mlParserBase.h:63
#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.