30#ifndef __NCML_MODULE_NCML_PARSER_H__
31#define __NCML_MODULE_NCML_PARSER_H__
40#include <libdap/AttrTable.h>
43#include "NCMLElement.h"
45#include "ScopeStack.h"
46#include "XMLHelpers.h"
65class AggregationElement;
66class DimensionElement;
139 AttrTable*
get()
const;
142 void set(AttrTable* pAT);
151 void loadAndSetAttrTable();
154 mutable AttrTable* _pAttrTable;
155 mutable bool _loaded;
229 virtual void onStartDocument();
230 virtual void onEndDocument();
238 const std::string& uri);
252 bool isScopeAtomicAttribute()
const;
255 bool isScopeAttributeContainer()
const;
258 bool isScopeSimpleVariable()
const;
261 bool isScopeCompositeVariable()
const;
264 bool isScopeVariable()
const;
267 bool isScopeGlobal()
const;
270 bool isScopeNetcdf()
const;
273 bool isScopeAggregation()
const;
278 bool withinNetcdf()
const;
284 bool withinVariable()
const;
312 DDS* getDDSForCurrentDataset()
const;
330 void addChildDatasetToCurrentDataset(
NetcdfElement* dataset);
343 bool parsingDataRequest()
const;
348 void resetParseState();
357 bool isNameAlreadyUsedAtCurrentScope(
const std::string& name);
366 BaseType* getVariableInCurrentVariableContainer(
const string& name);
375 BaseType* getVariableInContainer(
const string& varName, BaseType* pContainer);
384 BaseType* getVariableInDDS(
const string& varName);
400 void addCopyOfVariableAtCurrentScope(BaseType& varTemplate);
406 void deleteVariableAtCurrentScope(
const string& name);
411 BaseType* getCurrentVariable()
const;
417 void setCurrentVariable(BaseType* pVar);
425 static bool typeCheckDAPVariable(
const BaseType& var,
const string& expectedType);
435 AttrTable* getCurrentAttrTable()
const;
442 void setCurrentAttrTable(AttrTable* pAT);
448 AttrTable* getGlobalAttrTable()
const;
454 bool attributeExistsAtCurrentScope(
const string& name)
const;
461 bool findAttribute(
const string& name, AttrTable::Attr_iter& attr)
const;
466 void clearAllAttrTables(DDS* dds);
469 void clearVariableMetadataRecursively(BaseType* var);
476 int tokenizeAttrValues(vector<string>& tokens,
const string& values,
const string& dapAttrTypeName,
477 const string& separator);
487 int tokenizeValuesForDAPType(vector<string>& tokens,
const string& values, AttrType dapType,
488 const string& separator);
497 void printScope()
const;
500 string getScopeString()
const;
503 string getTypedScopeString()
const;
506 int getScopeDepth()
const;
522 typedef std::vector<NCMLElement*>::const_reverse_iterator ElementStackConstIterator;
523 ElementStackConstIterator getElementStackBegin()
const
525 return _elementStack.rbegin();
527 ElementStackConstIterator getElementStackEnd()
const
529 return _elementStack.rend();
535 void clearElementStack();
538 void processStartNCMLElement(
const std::string& name,
const XMLAttributeMap& attrs);
541 void processEndNCMLElement(
const std::string& name);
546 const DimensionElement* getDimensionAtLexicalScope(
const string& dimName)
const;
552 string printAllDimensionsAtLexicalScope()
const;
568 bool isParsingOtherXML()
const;
607 static bool sThrowExceptionOnUnknownElements;
645 std::vector<NCMLElement*> _elementStack;
663 int _currentParseLine;
Holds a DDS object within the BES.
Represents an OPeNDAP DAP response object within the BES.
Represents an OPeNDAP DataDDS DAP2 data object within the BES.
Concrete class for NcML <attribute> element.
Concrete class for NcML <explicit> element.
Base class for NcML element concrete classes.
virtual void onParseWarning(std::string msg)
virtual void onEndElement(const std::string &name)
const XMLNamespaceStack & getXMLNamespaceStack() const
virtual void onParseError(std::string msg)
int getParseLineNumber() const
virtual void onStartElement(const std::string &name, const XMLAttributeMap &attrs)
static string convertNcmlTypeToCanonicalType(const string &ncmlType)
virtual void onStartElementWithNamespace(const std::string &localname, const std::string &prefix, const std::string &uri, const XMLAttributeMap &attributes, const XMLNamespaceMap &namespaces)
void 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 for...
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...
static const string STRUCTURE_TYPE
virtual void onEndElementWithNamespace(const std::string &localname, const std::string &prefix, const std::string &uri)
std::unique_ptr< BESDapResponse > parse(const std::string &ncmlFilename, agg_util::DDSLoader::ResponseType type)
Parse the NcML filename, returning a newly allocated DDS response containing the underlying dataset t...
virtual void onCharacters(const std::string &content)
virtual void setParseLineNumber(int line)
Concrete class for NcML <netcdf> element.
Interface class for the wrapper between libxml C SAX parser and our NCMLParser.
Element for the <variableAgg> element child of an <aggregation>.
Concrete class for NcML <variable> element.
Helper class for temporarily hijacking an existing dhi to load a DDX response for one particular file...
NcML Parser for adding/modifying/removing metadata (attributes) to existing local datasets using NcML...