30 #ifndef __NCML_MODULE_NCML_PARSER_H__
31 #define __NCML_MODULE_NCML_PARSER_H__
40 #include <AttrTable.h>
42 #include "DDSLoader.h"
43 #include "NCMLElement.h"
44 #include "SaxParser.h"
45 #include "ScopeStack.h"
46 #include "XMLHelpers.h"
65 class AggregationElement;
66 class DimensionElement;
140 AttrTable* get()
const;
143 void set(AttrTable* pAT);
152 void loadAndSetAttrTable();
155 mutable AttrTable* _pAttrTable;
156 mutable bool _loaded;
219 bool parsing()
const;
222 int getParseLineNumber()
const;
230 virtual void onStartDocument();
231 virtual void onEndDocument();
232 virtual void onStartElement(
const std::string& name,
const XMLAttributeMap& attrs);
233 virtual void onEndElement(
const std::string& name);
235 virtual void onStartElementWithNamespace(
const std::string& localname,
const std::string& prefix,
238 virtual void onEndElementWithNamespace(
const std::string& localname,
const std::string& prefix,
239 const std::string& uri);
241 virtual void onCharacters(
const std::string& content);
242 virtual void onParseWarning(std::string msg);
243 virtual void onParseError(std::string msg);
244 virtual void setParseLineNumber(
int line);
253 bool isScopeAtomicAttribute()
const;
256 bool isScopeAttributeContainer()
const;
259 bool isScopeSimpleVariable()
const;
262 bool isScopeCompositeVariable()
const;
265 bool isScopeVariable()
const;
268 bool isScopeGlobal()
const;
271 bool isScopeNetcdf()
const;
274 bool isScopeAggregation()
const;
279 bool withinNetcdf()
const;
285 bool withinVariable()
const;
313 DDS* getDDSForCurrentDataset()
const;
331 void addChildDatasetToCurrentDataset(
NetcdfElement* dataset);
344 bool parsingDataRequest()
const;
349 void resetParseState();
358 bool isNameAlreadyUsedAtCurrentScope(
const std::string& name);
367 BaseType* getVariableInCurrentVariableContainer(
const string& name);
376 BaseType* getVariableInContainer(
const string& varName, BaseType* pContainer);
385 BaseType* getVariableInDDS(
const string& varName);
401 void addCopyOfVariableAtCurrentScope(BaseType& varTemplate);
407 void deleteVariableAtCurrentScope(
const string& name);
412 BaseType* getCurrentVariable()
const;
418 void setCurrentVariable(BaseType* pVar);
426 static bool typeCheckDAPVariable(
const BaseType& var,
const string& expectedType);
436 AttrTable* getCurrentAttrTable()
const;
443 void setCurrentAttrTable(AttrTable* pAT);
449 AttrTable* getGlobalAttrTable()
const;
455 bool attributeExistsAtCurrentScope(
const string& name)
const;
462 bool findAttribute(
const string& name, AttrTable::Attr_iter& attr)
const;
467 void clearAllAttrTables(DDS* dds);
470 void clearVariableMetadataRecursively(BaseType* var);
477 int tokenizeAttrValues(vector<string>& tokens,
const string& values,
const string& dapAttrTypeName,
478 const string& separator);
488 int tokenizeValuesForDAPType(vector<string>& tokens,
const string& values, AttrType dapType,
489 const string& separator);
498 void printScope()
const;
501 string getScopeString()
const;
504 string getTypedScopeString()
const;
507 int getScopeDepth()
const;
523 typedef std::vector<NCMLElement*>::const_reverse_iterator ElementStackConstIterator;
524 ElementStackConstIterator getElementStackBegin()
const
526 return _elementStack.rbegin();
528 ElementStackConstIterator getElementStackEnd()
const
530 return _elementStack.rend();
536 void clearElementStack();
539 void processStartNCMLElement(
const std::string& name,
const XMLAttributeMap& attrs);
542 void processEndNCMLElement(
const std::string& name);
547 const DimensionElement* getDimensionAtLexicalScope(
const string& dimName)
const;
553 string printAllDimensionsAtLexicalScope()
const;
569 bool isParsingOtherXML()
const;
591 static string convertNcmlTypeToCanonicalType(
const string& ncmlType);
600 void checkDataIsValidForCanonicalTypeOrThrow(
const string& type,
const vector<string>& tokens)
const;
608 static bool sThrowExceptionOnUnknownElements;
646 std::vector<NCMLElement*> _elementStack;
664 int _currentParseLine;