OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
ncml_module::NCMLParser Class Reference

#include <NCMLParser.h>

Inheritance diagram for ncml_module::NCMLParser:
Inheritance graph
Collaboration diagram for ncml_module::NCMLParser:
Collaboration graph

Public Member Functions

void checkDataIsValidForCanonicalTypeOrThrow (const string &type, const vector< string > &tokens) const
 Make sure the given tokens are valid for the listed type. More...
 
int getParseLineNumber () const
 Get the line of the NCML file the parser is currently parsing. More...
 
const XMLNamespaceStackgetXMLNamespaceStack () const
 If using namespaces, get the current stack of namespaces. More...
 
 NCMLParser (agg_util::DDSLoader &loader)
 Create a structure that can parse an NCML filename and returned a transformed response of requested type. More...
 
virtual void onCharacters (const std::string &content)
 Called when characters are encountered within an element. More...
 
virtual void onEndDocument ()
 
virtual void onEndElement (const std::string &name)
 
virtual void onEndElementWithNamespace (const std::string &localname, const std::string &prefix, const std::string &uri)
 SAX2 End element with namespace information. More...
 
virtual void onParseError (std::string msg)
 An unrecoverable parse error occurred. More...
 
virtual void onParseWarning (std::string msg)
 A recoverable parse error occured. More...
 
virtual void onStartDocument ()
 
virtual void onStartElement (const std::string &name, const XMLAttributeMap &attrs)
 
virtual void onStartElementWithNamespace (const std::string &localname, const std::string &prefix, const std::string &uri, const XMLAttributeMap &attributes, const XMLNamespaceMap &namespaces)
 SAX2 start element call with gets namespace information. More...
 
auto_ptr< BESDapResponseparse (const string &ncmlFilename, agg_util::DDSLoader::ResponseType type)
 Parse the NcML filename, returning a newly allocated DDS response containing the underlying dataset transformed by the NcML. More...
 
void parseInto (const string &ncmlFilename, agg_util::DDSLoader::ResponseType responseType, BESDapResponse *response)
 Same as parse, but the response object to parse into is passed down by the caller rather than created. More...
 
bool parsing () const
 Are we currently parsing? More...
 
virtual void setParseLineNumber (int line)
 Before any of the callbacks are issued, this function is called to let the implementing parser know what line number in the parse the next callback is being issued from to allow for more informative error messages. More...
 
virtual ~NCMLParser ()
 

Static Public Member Functions

static string convertNcmlTypeToCanonicalType (const string &ncmlType)
 Convert the NCML type in ncmlType into a canonical type we will use in the parser. More...
 

Static Public Attributes

static const string STRUCTURE_TYPE
 The string describing the type "Structure". More...
 

Friends

class AggregationElement
 
class AttributeElement
 
class AttrTableLazyPtr
 
class DimensionElement
 
class ExplicitElement
 
class NetcdfElement
 
class ReadMetadataElement
 
class RemoveElement
 
class ScanElement
 
class ValuesElement
 
class VariableAggElement
 
class VariableElement
 

Detailed Description

Definition at line 164 of file NCMLParser.h.

Constructor & Destructor Documentation

ncml_module::NCMLParser::NCMLParser ( agg_util::DDSLoader loader)

Create a structure that can parse an NCML filename and returned a transformed response of requested type.

Parameters
loaderhelper for loading a location referred to in the ncml.

Definition at line 145 of file NCMLParser.cc.

References BESDEBUG.

ncml_module::NCMLParser::~NCMLParser ( )
virtual

Definition at line 163 of file NCMLParser.cc.

Member Function Documentation

void ncml_module::NCMLParser::checkDataIsValidForCanonicalTypeOrThrow ( const string &  type,
const vector< string > &  tokens 
) const

Make sure the given tokens are valid for the listed type.

For example, makes sure floats are well formed, UInt16 are unsigned, etc. A successful call will return normally, else we throw an exception.

Exceptions
BESUserSyntaxErroron invalid values.

Definition at line 1076 of file NCMLParser.cc.

References getParseLineNumber(), ncml_module::ScopeStack::getScopeString(), ncml_module::NCMLUtil::isAscii(), THROW_NCML_INTERNAL_ERROR, and THROW_NCML_PARSE_ERROR.

Here is the call graph for this function:

string ncml_module::NCMLParser::convertNcmlTypeToCanonicalType ( const string &  ncmlType)
static

Convert the NCML type in ncmlType into a canonical type we will use in the parser.

Specifically, we map NcML types to their closest DAP equivalent type, but we leave Structure as Structure since it is assumed to mean Constructor for DAP which is a superclass type. Note this passes DAP types through unchanged as well. It is illegal for ncmlType to be empty(). We return "" to indicate an error in conversion.

Parameters
ncmlTypea non empty() string that could be an NcML type (or built-in DAP type)
Returns
the converted type or "" if unknown type.

Definition at line 1058 of file NCMLParser.cc.

References NCML_ASSERT_MSG.

const XMLNamespaceStack & ncml_module::NCMLParser::getXMLNamespaceStack ( ) const

If using namespaces, get the current stack of namespaces.

Might be empty.

Definition at line 228 of file NCMLParser.cc.

Referenced by ncml_module::OtherXMLParser::onStartElementWithNamespace().

void ncml_module::NCMLParser::onCharacters ( const std::string &  content)
virtual

Called when characters are encountered within an element.

content is only valid for the call duration. Note: this will return all whitespace in the document as well, which makes it messy to use.

Implements ncml_module::SaxParser.

Definition at line 378 of file NCMLParser.cc.

References ncml_module::NCMLElement::handleContent(), ncml_module::OtherXMLParser::onCharacters(), and VALID_PTR.

Here is the call graph for this function:

void ncml_module::NCMLParser::onEndDocument ( )
virtual

Implements ncml_module::SaxParser.

Definition at line 240 of file NCMLParser.cc.

References BESDEBUG.

void ncml_module::NCMLParser::onEndElement ( const std::string &  name)
virtual
Deprecated:
We are preferring onEndElementWithNamespace() now. Called at the end of the element with the given name. The args are only valid for the duration of the call, so copy if necessary to keep.

Implements ncml_module::SaxParser.

Definition at line 282 of file NCMLParser.cc.

References ncml_module::OtherXMLParser::onEndElement(), and VALID_PTR.

Here is the call graph for this function:

void ncml_module::NCMLParser::onEndElementWithNamespace ( const std::string &  localname,
const std::string &  prefix,
const std::string &  uri 
)
virtual

SAX2 End element with namespace information.

Parameters
localnamethe localname of the element
prefixthe namespace prefix or "" on the element
urithe uri (or "") associated with the namespace of the element.

Implements ncml_module::SaxParser.

Definition at line 341 of file NCMLParser.cc.

References ncml_module::OtherXMLParser::onEndElementWithNamespace(), ncml_module::XMLNamespaceStack::pop(), and VALID_PTR.

Here is the call graph for this function:

void ncml_module::NCMLParser::onParseError ( std::string  msg)
virtual

An unrecoverable parse error occurred.

Implements ncml_module::SaxParser.

Definition at line 405 of file NCMLParser.cc.

References getParseLineNumber(), and THROW_NCML_PARSE_ERROR.

Here is the call graph for this function:

void ncml_module::NCMLParser::onParseWarning ( std::string  msg)
virtual

A recoverable parse error occured.

Implements ncml_module::SaxParser.

Definition at line 398 of file NCMLParser.cc.

References BESDEBUG.

void ncml_module::NCMLParser::onStartDocument ( )
virtual

Implements ncml_module::SaxParser.

Definition at line 234 of file NCMLParser.cc.

References BESDEBUG.

void ncml_module::NCMLParser::onStartElement ( const std::string &  name,
const XMLAttributeMap attrs 
)
virtual
Deprecated:
We are preferring onStartElementWithNamespace() now Called at the start of the element with the given name and attribute dictionary The args are only valid for the duration of the call, so copy if necessary to keep.
Parameters
namename of the element
attrsa map of any attributes -> values. Volatile for this call.
See also
onStartElementWithNamespace()

Implements ncml_module::SaxParser.

Definition at line 246 of file NCMLParser.cc.

References ncml_module::OtherXMLParser::onStartElement(), and VALID_PTR.

Here is the call graph for this function:

void ncml_module::NCMLParser::onStartElementWithNamespace ( const std::string &  localname,
const std::string &  prefix,
const std::string &  uri,
const XMLAttributeMap attributes,
const XMLNamespaceMap namespaces 
)
virtual

SAX2 start element call with gets namespace information.

Parameters
localnamethe localname of the element
prefixthe namespace prefix of the element, or "" if none.
urithe uri for the namespace of the element.
attributestable of the attributes (excluding namespace attributes prefixed with xmlns)
namespacetable of all the namespaces specification on this element

Implements ncml_module::SaxParser.

Definition at line 315 of file NCMLParser.cc.

References ncml_module::OtherXMLParser::onStartElementWithNamespace(), ncml_module::XMLNamespaceStack::push(), and VALID_PTR.

Here is the call graph for this function:

auto_ptr< BESDapResponse > ncml_module::NCMLParser::parse ( const string &  ncmlFilename,
agg_util::DDSLoader::ResponseType  type 
)

Parse the NcML filename, returning a newly allocated DDS response containing the underlying dataset transformed by the NcML.

The caller owns the returned memory.

Exceptions
BESSyntaxUserErrorfor parse errors such as bad XML or NcML referring to variables that do not exist.
BESInternalErrorfor assertion failures, null ptr exceptions, or logic errors.
Returns
a new response object with the transformed DDS in it. The caller assumes ownership of the returned object. It will be of type BESDDSResponse or BESDataDDSResponse depending on the request being processed.

Definition at line 170 of file NCMLParser.cc.

References parseInto().

Referenced by ncml_module::NCMLRequestHandler::ncml_build_das(), ncml_module::NCMLRequestHandler::ncml_build_dds(), and ncml_module::NCMLRequestHandler::ncml_build_dmr().

Here is the call graph for this function:

void ncml_module::NCMLParser::parseInto ( const string &  ncmlFilename,
agg_util::DDSLoader::ResponseType  responseType,
BESDapResponse response 
)

Same as parse, but the response object to parse into is passed down by the caller rather than created.

Parameters
ncmlFilenamethe ncml file to parse
responseTypethe type of response. Must match response.
responsethe premade response object. The caller owns this memory.

Definition at line 184 of file NCMLParser.cc.

References BESDEBUG, NCML_ASSERT_MSG, ncml_module::SaxParserWrapper::parse(), parsing(), THROW_NCML_INTERNAL_ERROR, and VALID_PTR.

Referenced by ncml_module::NCMLRequestHandler::ncml_build_data(), and parse().

Here is the call graph for this function:

bool ncml_module::NCMLParser::parsing ( ) const

Are we currently parsing?

Definition at line 216 of file NCMLParser.cc.

Referenced by parseInto().

void ncml_module::NCMLParser::setParseLineNumber ( int  )
virtual

Before any of the callbacks are issued, this function is called to let the implementing parser know what line number in the parse the next callback is being issued from to allow for more informative error messages.

(Default impl is to ignore it now).

Reimplemented from ncml_module::SaxParser.

Definition at line 413 of file NCMLParser.cc.

Friends And Related Function Documentation

friend class AggregationElement
friend

Definition at line 169 of file NCMLParser.h.

friend class AttributeElement
friend

Definition at line 171 of file NCMLParser.h.

friend class AttrTableLazyPtr
friend

Definition at line 170 of file NCMLParser.h.

friend class DimensionElement
friend

Definition at line 172 of file NCMLParser.h.

friend class ExplicitElement
friend

Definition at line 173 of file NCMLParser.h.

friend class NetcdfElement
friend

Definition at line 174 of file NCMLParser.h.

friend class ReadMetadataElement
friend

Definition at line 175 of file NCMLParser.h.

friend class RemoveElement
friend

Definition at line 176 of file NCMLParser.h.

friend class ScanElement
friend

Definition at line 177 of file NCMLParser.h.

friend class ValuesElement
friend

Definition at line 178 of file NCMLParser.h.

friend class VariableAggElement
friend

Definition at line 179 of file NCMLParser.h.

friend class VariableElement
friend

Definition at line 180 of file NCMLParser.h.

Member Data Documentation

const string ncml_module::NCMLParser::STRUCTURE_TYPE
static

The string describing the type "Structure".

Definition at line 578 of file NCMLParser.h.


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