bes  Updated for version 3.20.6
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 namespace ncml_module {
38 class SaxParser;
39 }
40 
41 namespace ncml_module {
60 private:
61  // Inner Classes
62 
69  enum ParserState {
70  NOT_PARSING = 0, PARSING, EXCEPTION, NUM_STATES
71  };
72 
73 private:
74  // Data Rep
75 
77  SaxParser& _parser;
78 
84  xmlSAXHandler _handler;
85 
86 #if 1
87 
90  xmlParserCtxtPtr _context;
91 #endif
92 
93 
95  ParserState _state;
96 
100  std::string _errorMsg;
101  int _errorType;
102  std::string _errorFile;
103  int _errorLine;
104 
105 private:
106  SaxParserWrapper(const SaxParserWrapper&); // illegal
107  SaxParserWrapper& operator=(const SaxParserWrapper&); // illegal
108 
109 public:
115  explicit SaxParserWrapper(SaxParser& parser);
116  virtual ~SaxParserWrapper();
117 
127  bool parse(const std::string& ncmlFilename);
128 
129  SaxParser& getParser() const
130  {
131  return _parser;
132  }
133 
136 
145  void deferException(BESError& theErr);
146 
150  bool isExceptionState() const
151  {
152  return _state == EXCEPTION;
153  }
154 
159  void rethrowException();
160 
164  int getCurrentParseLine() const;
165 
166 private:
167 
174  void setupParser();
175 
176 #if 1
177  // Leak fix. jhrg 6/21/19
179  void cleanupParser() throw ();
180 #endif
181 
182 
183 };
184 // class SaxParserWrapper
185 
186 }// namespace ncml_module
187 
188 #endif /*__NCML_MODULE__SAX_PARSER_WRAPPER_H__ */
ncml_module::SaxParserWrapper::rethrowException
void rethrowException()
Definition: SaxParserWrapper.cc:351
ncml_module::SaxParserWrapper::parse
bool parse(const std::string &ncmlFilename)
Do a SAX parse of the ncmlFilename and pass the calls to wrapper parser.
Definition: SaxParserWrapper.cc:316
ncml_module::SaxParserWrapper::isExceptionState
bool isExceptionState() const
Definition: SaxParserWrapper.h:150
ncml_module::SaxParserWrapper::getCurrentParseLine
int getCurrentParseLine() const
Definition: SaxParserWrapper.cc:377
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:59
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
ncml_module::SaxParserWrapper::deferException
void deferException(BESError &theErr)
The remaining calls are for the internals of the parser, but need to be public.
Definition: SaxParserWrapper.cc:340