Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

XmlScanner.h
Go to the documentation of this file.
1 
32 #pragma once
33 
35 
36 namespace ogdf {
37 
42 enum class XmlToken {
45  questionMark,
47  minus,
48  slash,
49  equalSign,
50  identifier,
52  quotedValue,
53  endOfFile,
54  invalidToken,
55  noToken
56 }; // enum XmlToken
58 
63 
64 private:
65 
66  // Pointer to the line buffer
68 
69  // String which contains the characters of the current token
71 
72 public:
73  // construction
74  explicit XmlScanner(istream &is);
75 
77  ~XmlScanner();
78 
79  // This function represents the core of the scanner. It scans the input
80  // and returns the identified token. After performing getNextToken() the
81  // token is "consumed", i.e. the line buffer pointer already points to the
82  // next token.
83  // The scanned string is deposited in m_currentToken, hence it is
84  // available via getCurrentToken()
85  XmlToken getNextToken();
86 
87  // Returns the current token string (a copy)
88  inline const string getCurrentToken()
89  {
90  return m_currentToken;
91  }
92 
93  // This function provides a lookahead to the next token;
94  // the token is NOT consumed like it is the case for getNextToken()
95  XmlToken testNextToken();
96 
97  // This function provides a lookahead to the nextnext token;
98  // the tokens are NOT consumed like it is the case for getNextToken()
99  XmlToken testNextNextToken();
100 
101  // Skips until the searchCharacter is found;
102  //
103  // If skipOverSearchCharacter is set true the currentPosition will be set
104  // BEHIND the search character
105  // otherwise the pointer currentPosition points TO the searchCharacter
106  //
107  // Returns true if the searchCharacter is found
108  // Returns false if file ends before the searchCharacter is found
109  bool skipUntil(char searchCharacter, bool skipOverSearchCharacter = true);
110 
111  // Skips until '>' is found (> is consumed)
112  // Nested brackets are taken into account
113  // Returns true if matching bracket has been found; false otherwise
114  bool skipUntilMatchingClosingBracket();
115 
116  // Reads until the searchCharacter is found; the string starting at the current
117  // position and ending at the position where the search character is found
118  // is deposited in m_currentToken.
119  // If includeSearchCharacter is false (default) the search character is
120  // not contained; otherwise it is contained
121  //
122  // Returns true if the searchCharacter is found
123  // Returns false if file ends before the searchCharacter is found
124  bool readStringUntil(char searchCharacter, bool includeSearchCharacter = false);
125 
126  // Returns line number of the most recently read line of the input file
127  inline int getInputFileLineCounter() const {
128  return m_pLineBuffer->getInputFileLineCounter();
129  }
130 
131  // This function tests the scanner by reading the complete
132  // input file and printing the identified token to stdout
133  void test();
134 
135 }; // class XmlScanner
136 
137 } // end namespace ogdf
int getInputFileLineCounter() const
Returns line number of the most recently read line of the input file.
Definition: LineBuffer.h:163
This class maintains the input file and provides a convenient interface to handle it...
Definition: LineBuffer.h:114
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
all quoted content " ... " or ' ... '
This class scans the characters of the input file and provides the detected token.
Definition: XmlScanner.h:62
int getInputFileLineCounter() const
Definition: XmlScanner.h:127
(a..z|A..Z){(a..z|A..Z|0..9|.|_|:)}
Used for the m_lookAheadToken to indicate that there is no lookahead token.
string m_currentToken
Definition: XmlScanner.h:70
const string getCurrentToken()
Definition: XmlScanner.h:88
LineBuffer * m_pLineBuffer
Definition: XmlScanner.h:67
Declaration of the clssses LineBuffer and LineBufferPosition.
a sequence of characters, digits, minus - and dot .
No token identified.
XmlToken
This enum type represents the values, which are returned by the function XmlScanner::getNextToken().
Definition: XmlScanner.h:42
The namespace for all OGDF objects.
End of file detected.