bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
|
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. | |
int | getCurrentParseLine () const |
SaxParser & | getParser () const |
bool | isExceptionState () const |
bool | parse (const std::string &ncmlFilename) |
Do a SAX parse of the ncmlFilename and pass the calls to wrapper parser. | |
void | rethrowException () |
SaxParserWrapper (SaxParser &parser) | |
Create a wrapper for the given parser. | |
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 59 of file SaxParserWrapper.h.
|
explicit |
Create a wrapper for the given parser.
parser | Must exist for the duration of the life of the wrapper. |
Definition at line 305 of file SaxParserWrapper.cc.
|
virtual |
Definition at line 310 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 343 of file SaxParserWrapper.cc.
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 380 of file SaxParserWrapper.cc.
|
inline |
Definition at line 129 of file SaxParserWrapper.h.
|
inline |
Used by the callbacks to know whether we have a deferred exception.
Definition at line 150 of file SaxParserWrapper.h.
bool SaxParserWrapper::parse | ( | const std::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 319 of file SaxParserWrapper.cc.
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 354 of file SaxParserWrapper.cc.