libdap  Updated for version 3.20.6
libdap4 is an implementation of OPeNDAP's DAP protocol.
libdap::AISDatabaseParser Class Reference

#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 aisStartDocument (AISParserState *state)
 
static void aisEndDocument (AISParserState *state)
 
static void aisStartElement (AISParserState *state, const char *name, const char **attrs)
 
static void aisEndElement (AISParserState *state, const char *name)
 
static xmlEntityPtr aisGetEntity (AISParserState *state, const xmlChar *name)
 
static void aisWarning (AISParserState *state, const char *msg,...)
 
static void aisError (AISParserState *state, const char *msg,...)
 
static void aisFatalError (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 69 of file AISDatabaseParser.h.

Member Function Documentation

◆ aisEndDocument()

void libdap::AISDatabaseParser::aisEndDocument ( AISParserState *  state)
static

Clean up after finishing a parse.

Parameters
stateThe SAX parser state.

Definition at line 82 of file AISDatabaseParser.cc.

◆ aisEndElement()

void libdap::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
stateThe SAX parser state.
nameThe name of the element; used only for code instrumentation.

Definition at line 211 of file AISDatabaseParser.cc.

◆ aisError()

void libdap::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
stateThe SAX parser state.
msgA printf-style format string.

Definition at line 298 of file AISDatabaseParser.cc.

◆ aisFatalError()

void libdap::AISDatabaseParser::aisFatalError ( AISParserState *  state,
const char *  msg,
  ... 
)
static

Process an XML fatal error.

Parameters
stateThe SAX parser state.
msgA printf-style format string.

Definition at line 323 of file AISDatabaseParser.cc.

◆ aisGetEntity()

xmlEntityPtr libdap::AISDatabaseParser::aisGetEntity ( AISParserState *  state,
const xmlChar *  name 
)
static

Handle the standard XML entities.

Parameters
stateThe SAX parser state.
nameThe XML entity.

Definition at line 262 of file AISDatabaseParser.cc.

◆ aisStartDocument()

void libdap::AISDatabaseParser::aisStartDocument ( AISParserState *  state)
static

Initialize the SAX parser state object. This object is passed to each callback as a void pointer.

Parameters
stateThe SAX parser state.

Definition at line 69 of file AISDatabaseParser.cc.

◆ aisStartElement()

void libdap::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
stateThe SAX parser state.
nameThe name of the element.
attrsThe element's attributes; 0, 2, 4, ... are the attribute names, 1, 3, 5, ... are the values.

Definition at line 103 of file AISDatabaseParser.cc.

◆ aisWarning()

void libdap::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
stateThe SAX parser state.
msgA printf-style format string.

Definition at line 272 of file AISDatabaseParser.cc.

◆ intern()

void libdap::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
databaseRead from this XML file.
aisLoad information into this instance of AISResources.
Exceptions
AISDatabaseReadFailedThrown if the XML document could not be read or parsed.

Definition at line 395 of file AISDatabaseParser.cc.


The documentation for this class was generated from the following files: