Open
Graph Drawing
Framework

 v.2012.07
 

DinoXmlScanner.h
Go to the documentation of this file.
1 /*
2  * $Revision: 2564 $
3  *
4  * last checkin:
5  * $Author: gutwenger $
6  * $Date: 2012-07-07 00:03:48 +0200 (Sa, 07. Jul 2012) $
7  ***************************************************************/
8 
44 #ifdef _MSC_VER
45 #pragma once
46 #endif
47 
48 #ifndef OGDF_DINO_XML_SCANNER_H
49 #define OGDF_DINO_XML_SCANNER_H
50 
52 
53 namespace ogdf {
54 
55  //---------------------------------------------------------
56  // X m l T o k e n
57  //---------------------------------------------------------
62  enum XmlToken {
76 
77  }; // enum XmlToken
78 
79 
80  //---------------------------------------------------------
81  // D i n o X m l S c a n n e r
82  //---------------------------------------------------------
87 
88  private:
89 
90  // Pointer to the line buffer
92 
93  // String which contains the characters of the current token
94  // Its size is limited to DinoLineBuffer::c_maxStringLength
96 
97  public:
98  // construction
99  DinoXmlScanner(const char *fileName);
100 
101  // destruction: destroys the parse tree
102  ~DinoXmlScanner();
103 
104  // This function represents the core of the scanner. It scans the input
105  // and returns the identified token. After performing getNextToken() the
106  // token is "consumed", i.e. the line buffer pointer already points to the
107  // next token.
108  // The scanned string is deposited in m_pCurrentTokenString, hence it is
109  // available via getCurrentTokenString()
110  XmlToken getNextToken();
111 
112  // Returns the current token string
113  inline const char *getCurrentTokenString(){
114  return m_pCurrentTokenString;
115  }
116 
117  // This function provides a lookahead to the next token;
118  // the token is NOT consumed like it is the case for getNextToken()
119  XmlToken testNextToken();
120 
121  // This function provides a lookahead to the nextnext token;
122  // the tokens are NOT consumed like it is the case for getNextToken()
123  XmlToken testNextNextToken();
124 
125  // Skips until the searchCharacter is found;
126  //
127  // If skipOverSearchCharacter is set true the currentPosition will be set
128  // BEHIND the search character
129  // otherwise the pointer currentPosition points TO the searchCharacter
130  //
131  // Returns true if the searchCharacter is found
132  // Returns false if file ends before the searchCharacter is found
133  bool skipUntil(char searchCharacter, bool skipOverSearchCharacter = true);
134 
135  // Skips until '>' is found (> is consumed)
136  // Nested brackets are taken into account
137  // Returns true if matching bracket has been found; false otherwise
138  bool skipUntilMatchingClosingBracket();
139 
140  // Reads until the searchCharacter is found; the string starting at the current
141  // position and ending at the position where the search character is found
142  // is deposited in m_pCurrentTokenString.
143  // If includeSearchCharacter is false (default) the search character is
144  // not contained; otherwise it is contained
145  //
146  // Returns true if the searchCharacter is found
147  // Returns false if file ends before the searchCharacter is found
148  bool readStringUntil(char searchCharacter, bool includeSearchCharacter = false);
149 
150  // Returns line number of the most recently read line of the input file
151  inline int getInputFileLineCounter() const {
152  return m_pLineBuffer->getInputFileLineCounter();
153  }
154 
155  // This function tests the scanner by reading the complete
156  // input file and printing the identified token to stdout
157  void test();
158 
159  }; // class DinoXmlScanner
160 
161 } // end namespace ogdf
162 
163 #endif