bes  Updated for version 3.20.5
SaxParserWrapper.h
1 // This file is part of the "NcML Module" project, a BES module designed
3 // to allow NcML files to be used to be used as a wrapper to add
4 // AIS to existing datasets of any format.
5 //
6 // Copyright (c) 2009 OPeNDAP, Inc.
7 // Author: Michael Johnson <m.johnson@opendap.org>
8 //
9 // For more information, please also see the main website: http://opendap.org/
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Lesser General Public
13 // License as published by the Free Software Foundation; either
14 // version 2.1 of the License, or (at your option) any later version.
15 //
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Lesser General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public
22 // License along with this library; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 //
25 // Please see the files COPYING and COPYRIGHT for more information on the GLPL.
26 //
27 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
29 
30 #ifndef __NCML_MODULE__SAX_PARSER_WRAPPER_H__
31 #define __NCML_MODULE__SAX_PARSER_WRAPPER_H__
32 
33 #include <string>
34 #include <libxml/parserInternals.h>
35 #include "BESError.h"
36 
37 using namespace std;
38 
39 namespace ncml_module {
40 class SaxParser;
41 }
42 
43 namespace ncml_module {
62 private:
63  // Inner Classes
64 
71  enum ParserState {
72  NOT_PARSING = 0, PARSING, EXCEPTION, NUM_STATES
73  };
74 
75 private:
76  // Data Rep
77 
79  SaxParser& _parser;
80 
86  xmlSAXHandler _handler;
87 
88 #if 0
89 
92  xmlParserCtxtPtr _context;
93 #endif
94 
95 
97  ParserState _state;
98 
102  string _errorMsg;
103  int _errorType;
104  string _errorFile;
105  int _errorLine;
106 
107 private:
108  SaxParserWrapper(const SaxParserWrapper&); // illegal
109  SaxParserWrapper& operator=(const SaxParserWrapper&); // illegal
110 
111 public:
117  SaxParserWrapper(SaxParser& parser);
118  virtual ~SaxParserWrapper();
119 
129  bool parse(const string& ncmlFilename);
130 
131  SaxParser& getParser() const
132  {
133  return _parser;
134  }
135 
138 
147  void deferException(BESError& theErr);
148 
152  bool isExceptionState() const
153  {
154  return _state == EXCEPTION;
155  }
156 
161  void rethrowException();
162 
166  int getCurrentParseLine() const;
167 
168 private:
169 
171  void setupParser(const string& filename);
172 
173 #if 0
174  // Leak fix. jhrg 6/21/19
176  void cleanupParser() throw ();
177 #endif
178 
179 
180 };
181 // class SaxParserWrapper
182 
183 }// namespace ncml_module
184 
185 #endif /*__NCML_MODULE__SAX_PARSER_WRAPPER_H__ */
ncml_module::SaxParserWrapper::isExceptionState
bool isExceptionState() const
Definition: SaxParserWrapper.h:152
ncml_module
NcML Parser for adding/modifying/removing metadata (attributes) to existing local datasets using NcML...
Definition: AggregationElement.cc:72
ncml_module::SaxParserWrapper
Wrapper for libxml SAX parser C callbacks into C++.
Definition: SaxParserWrapper.h:61
ncml_module::SaxParser
Interface class for the wrapper between libxml C SAX parser and our NCMLParser.
Definition: SaxParser.h:48
BESError
Abstract exception class for the BES with basic string message.
Definition: BESError.h:58