Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

AISDatabaseParser Class Reference

#include <AISDatabaseParser.h>

List of all members.

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.

void aisEndDocument (AISParserState *state)
void aisEndElement (AISParserState *state, const char *name)
void aisError (AISParserState *state, const char *msg,...)
void aisFatalError (AISParserState *state, const char *msg,...)
xmlEntityPtr aisGetEntity (AISParserState *state, const xmlChar *name)
void aisStartDocument (AISParserState *state)
void aisStartElement (AISParserState *state, const char *name, const char **attrs)
void aisWarning (AISParserState *state, const char *msg,...)


Detailed Description

Parse the XML database/configuration file which lists a collection of AIS resources.

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.

See also:
AISResource

Definition at line 66 of file AISDatabaseParser.h.


Member Function Documentation

void AISDatabaseParser::aisEndDocument AISParserState *  state  )  [static]
 

Clean up after finishing a parse.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
database Read from this XML file.
ais Load information into this instance of AISResources.
Exceptions:
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().


The documentation for this class was generated from the following files:
Generated on Thu Aug 2 06:44:01 2007 for libdap++ by  doxygen 1.3.9.1