OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
ExplicitElement.cc
Go to the documentation of this file.
1 // This file is part of the "NcML Module" project, a BES module designed
3 // to allow NcML files to be used to be used as a wrapper to add
4 // AIS to existing datasets of any format.
5 //
6 // Copyright (c) 2009 OPeNDAP, Inc.
7 // Author: Michael Johnson <m.johnson@opendap.org>
8 //
9 // For more information, please also see the main website: http://opendap.org/
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Lesser General Public
13 // License as published by the Free Software Foundation; either
14 // version 2.1 of the License, or (at your option) any later version.
15 //
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 // Lesser General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public
22 // License along with this library; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 //
25 // Please see the files COPYING and COPYRIGHT for more information on the GLPL.
26 //
27 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
29 #include "ExplicitElement.h"
30 #include "NCMLDebug.h"
31 #include "NCMLParser.h"
32 #include "NCMLUtil.h"
33 #include "NetcdfElement.h"
34 
35 namespace ncml_module
36 {
37 
38  const string ExplicitElement::_sTypeName = "explicit";
39  const vector<string> ExplicitElement::_sValidAttributes = vector<string>(); // init to the empty vector... we should have none in here!
40 
42  :NCMLElement(0)
43  {
44  }
45 
47  : RCObjectInterface()
48  , NCMLElement(0)
49  {
50  }
51 
53  {
54  }
55 
56  const string&
58  {
59  return _sTypeName;
60  }
61 
64  {
65  return new ExplicitElement(*this);
66  }
67 
68  void
70  {
71  // make sure that none are specifed, basically. We'll list them out in here if we get any
72  // which is why this rather than check map size and throw.
74  }
75 
76  void
78  {
79  NCMLParser& p = *_parser;
80  if (!p.isScopeNetcdf())
81  {
83  "Got <explicit/> while not a direct child of a <netcdf>");
84  }
85  // this applies to the current dataset
86  NetcdfElement* dataset = p.getCurrentDataset();
87  VALID_PTR(dataset);
88 
89  if (dataset->getProcessedMetadataDirective())
90  {
92  "Got " + toString() +
93  " element but we already got a metadata directive for the current dataset! Only one may be specified.");
94  }
95 
97  VALID_PTR(dataset->getDDS());
98  p.clearAllAttrTables(dataset->getDDS());
99  }
100 
101  void
102  ExplicitElement::handleContent(const string& content)
103  {
104  if (!NCMLUtil::isAllWhitespace(content))
105  {
107  "Got non-whitespace for element content and didn't expect it. Element=" + toString() + " content=\"" +
108  content + "\"");
109  }
110  }
111 
112  void
114  {
115  }
116 
117  string
119  {
120  return "<" + _sTypeName + ">";
121  }
122 }
virtual bool validateAttributes(const XMLAttributeMap &attrs, const vector< string > &validAttrs, vector< string > *pInvalidAttrs=0, bool printInvalid=true, bool throwOnError=true)
Check that the given attributes are all in the valid set, otherwise fill in *pInvalidAttrs with the p...
Definition: NCMLElement.cc:191
virtual ExplicitElement * clone() const
Make and return a copy of this.
An abstract superclass for NCMLArray that handles the non-parameterized functionality and allows u...
static const string _sTypeName
virtual void handleEnd()
Handle the closing of this element.
static bool isAllWhitespace(const std::string &str)
Is all the string whitespace as defined by chars in WHITESPACE ?
Definition: NCMLUtil.cc:110
Concrete class for NcML element.
Definition: NetcdfElement.h:63
virtual const libdap::DDS * getDDS() const
Return the DDS for this dataset, loading it in if needed.
int getParseLineNumber() const
Get the line of the NCML file the parser is currently parsing.
Definition: NCMLParser.cc:222
static const vector< string > _sValidAttributes
virtual void handleBegin()
Handle a begin on this element.
bool getProcessedMetadataDirective() const
#define THROW_NCML_PARSE_ERROR(parseLine, msg)
Definition: NCMLDebug.h:69
virtual string toString() const
Return a string describing the element.
Base class for NcML element concrete classes.
Definition: NCMLElement.h:64
virtual const string & getTypeName() const
Return the type of the element, which should be: the same as ConcreteClassName::getTypeName() ...
Concrete class for NcML element.
virtual void handleContent(const string &content)
Handle the characters content for the element.
#define VALID_PTR(ptr)
Definition: NCMLDebug.h:88
virtual void setAttributes(const XMLAttributeMap &attrs)
Set the attributes of this from the map.