#include <AISDatabaseParser.h>
Public Member Functions | |
void | intern (const string &database, AISResources *ais) |
Static Public Member Functions | |
SAX Parser Callbacks | |
These methods are declared static in the class header. This gives them C linkage which allows them to be used as callbacks by the SAX parser engine. | |
static void | aisEndDocument (AISParserState *state) |
static void | aisEndElement (AISParserState *state, const char *name) |
static void | aisError (AISParserState *state, const char *msg,...) |
static void | aisFatalError (AISParserState *state, const char *msg,...) |
static xmlEntityPtr | aisGetEntity (AISParserState *state, const xmlChar *name) |
static void | aisStartDocument (AISParserState *state) |
static void | aisStartElement (AISParserState *state, const char *name, const char **attrs) |
static void | aisWarning (AISParserState *state, const char *msg,...) |
Classes | |
struct | AISParserState |
Static methods are used as callbacks for the SAX parser. They do not throw exceptions because exceptions from within callbacks are not reliable or portable. To signal errors, the methods record information in the AISParserState object. Once any of the error handlers (aisWarning, aisError or aisFatalError) is called, construction of an AISResources object ends even though the SAX parser still calls the various callback functions. The parse method throws an AISDatabaseReadFailed exception if an error was found.
Note that this class uses the C++-supplied default definitions for the default and copy constructors as well as the destructor and assignment operator.
This class should be extended so that the line number is added to error messages.
Definition at line 66 of file AISDatabaseParser.h.
void AISDatabaseParser::aisEndDocument | ( | AISParserState * | state | ) | [static] |
Clean up after finishing a parse.
state | The SAX parser state. |
Definition at line 78 of file AISDatabaseParser.cc.
References aisFatalError(), DBG, and DBG2.
Here is the call graph for this function:
void AISDatabaseParser::aisEndElement | ( | AISParserState * | state, | |
const char * | name | |||
) | [static] |
Process an end element tag. This is where values are added to the AISResources object that's held by state
.
state | The SAX parser state. | |
name | The name of the element; used only for code instrumentation. |
Definition at line 204 of file AISDatabaseParser.cc.
References DBG2.
void AISDatabaseParser::aisError | ( | AISParserState * | state, | |
const char * | msg, | |||
... | ||||
) | [static] |
Process an XML error. This is treated as a fatal error since there's no easy way for libdap++ to signal a warning to users.
state | The SAX parser state. | |
msg | A printf-style format string. |
Definition at line 292 of file AISDatabaseParser.cc.
References long_to_string().
Here is the call graph for this function:
void AISDatabaseParser::aisFatalError | ( | AISParserState * | state, | |
const char * | msg, | |||
... | ||||
) | [static] |
Process an XML fatal error.
state | The SAX parser state. | |
msg | A printf-style format string. |
Definition at line 317 of file AISDatabaseParser.cc.
References long_to_string().
Referenced by aisEndDocument(), and aisStartElement().
Here is the call graph for this function:
xmlEntityPtr AISDatabaseParser::aisGetEntity | ( | AISParserState * | state, | |
const xmlChar * | name | |||
) | [static] |
Handle the standard XML entities.
state | The SAX parser state. | |
name | The XML entity. |
Definition at line 256 of file AISDatabaseParser.cc.
void AISDatabaseParser::aisStartDocument | ( | AISParserState * | state | ) | [static] |
Initialize the SAX parser state object. This object is passed to each callback as a void pointer.
state | The SAX parser state. |
Definition at line 65 of file AISDatabaseParser.cc.
References DBG2.
void AISDatabaseParser::aisStartElement | ( | AISParserState * | state, | |
const char * | name, | |||
const char ** | attrs | |||
) | [static] |
Process a start element tag. Because the AIS DTD uses attributes and because libxml2 does not validate those, we do attribute validation here. Values pulled from the attributes are recorded in state
for later use in aisEndElement.
state | The SAX parser state. | |
name | The name of the element. | |
attrs | The element's attributes; 0, 2, 4, ... are the attribute names, 1, 3, 5, ... are the values. |
Definition at line 99 of file AISDatabaseParser.cc.
References aisFatalError(), DBG, and DBG2.
Here is the call graph for this function:
void AISDatabaseParser::aisWarning | ( | AISParserState * | state, | |
const char * | msg, | |||
... | ||||
) | [static] |
Process an XML warning. This is treated as a fatal error since there's no easy way for libdap++ to signal a warning to users.
state | The SAX parser state. | |
msg | A printf-style format string. |
Definition at line 266 of file AISDatabaseParser.cc.
References long_to_string().
Here is the call graph for this function:
void AISDatabaseParser::intern | ( | const string & | database, | |
AISResources * | ais | |||
) |
Parse an AIS database encoded in XML. The information in the XML document is loaded into an instance of AISResources.
database | Read from this XML file. | |
ais | Load information into this instance of AISResources. |
AISDatabaseReadFailed | Thrown if the XML document could not be read or parsed. |
Definition at line 389 of file AISDatabaseParser.cc.
Referenced by AISResources::read_database().