|
OPeNDAP Hyrax Back End Server (BES)
Updated for version 3.8.3
|
Wrapper for libxml SAX parser C callbacks into C++. More...
#include <SaxParserWrapper.h>

Public Member Functions | |
| void | deferException (BESError &theErr) |
| The remaining calls are for the internals of the parser, but need to be public. More... | |
| int | getCurrentParseLine () const |
| Return the current line of the parse we're on, assuming we're not in an exception state and that we are parsing. More... | |
| SaxParser & | getParser () const |
| bool | isExceptionState () const |
| Used by the callbacks to know whether we have a deferred exception. More... | |
| bool | parse (const string &ncmlFilename) |
| Do a SAX parse of the ncmlFilename and pass the calls to wrapper parser. More... | |
| void | rethrowException () |
| If there's a deferred exception, this will throw the right subclass type from the preserved state at deferral time. More... | |
| SaxParserWrapper (SaxParser &parser) | |
| Create a wrapper for the given parser. More... | |
| virtual | ~SaxParserWrapper () |
Wrapper for libxml SAX parser C callbacks into C++.
On a parse(const string& ncmlFilename) call, the filename is parsed using the libxml C SAX parser and the C callbacks are passed onto our C++ parser via the SaxParser interface class.
Since the underlying libxml is C and uses its internal static memory pools which will be used by other parts of the BES, we have to be careful with exceptions. Any BESError thrown in a SaxParser callback is caught and deferred (stored in this). We enter an error state and ignore all further callbacks until the libxml parser exits cleanly. Then we recreate and rethrow the deferred exception.
Any other exception types (...) are also caught and a local BESInternalError is thrown at parse end, so be careful with which exceptions are thrown in SaxParser callbacks.
Definition at line 63 of file SaxParserWrapper.h.
| SaxParserWrapper::SaxParserWrapper | ( | SaxParser & | parser | ) |
Create a wrapper for the given parser.
| parser | Must exist for the duration of the life of the wrapper. |
Definition at line 307 of file SaxParserWrapper.cc.
|
virtual |
Definition at line 319 of file SaxParserWrapper.cc.
| void SaxParserWrapper::deferException | ( | BESError & | theErr | ) |
The remaining calls are for the internals of the parser, but need to be public.
If we get a BESError exception thrown in a SaxParser call, defer it by entering the EXCEPTION state and copying the exception. In EXCEPTION state, we don't pass on any callbacks to SaxParser. When the underlying C parser completes and cleans up its storage, then we recreate and throw the exception. NOTE: We can't store theErr itself since it will be destroyed by the exception system.
Definition at line 367 of file SaxParserWrapper.cc.
References BESError::get_error_type(), BESError::get_file(), BESError::get_line(), and BESError::get_message().

| int SaxParserWrapper::getCurrentParseLine | ( | ) | const |
Return the current line of the parse we're on, assuming we're not in an exception state and that we are parsing.
Definition at line 413 of file SaxParserWrapper.cc.
|
inline |
Definition at line 127 of file SaxParserWrapper.h.
|
inline |
Used by the callbacks to know whether we have a deferred exception.
Definition at line 145 of file SaxParserWrapper.h.
Referenced by parse().
| bool SaxParserWrapper::parse | ( | const string & | ncmlFilename | ) |
Do a SAX parse of the ncmlFilename and pass the calls to wrapper parser.
| path | to the file to parse. |
Definition at line 327 of file SaxParserWrapper.cc.
References isExceptionState(), and rethrowException().
Referenced by ncml_module::SimpleLocationParser::parseAndGetLocation(), and ncml_module::NCMLParser::parseInto().

| void SaxParserWrapper::rethrowException | ( | ) |
If there's a deferred exception, this will throw the right subclass type from the preserved state at deferral time.
Definition at line 379 of file SaxParserWrapper.cc.
References BES_FORBIDDEN_ERROR, BES_INTERNAL_ERROR, BES_INTERNAL_FATAL_ERROR, BES_NOT_FOUND_ERROR, and BES_SYNTAX_USER_ERROR.
Referenced by parse().