104 throw InternalErr(__FILE__, __LINE__,
"Unsupported attribute type");
112 if (s ==
"container")
115 else if (s ==
"byte")
117 else if (s ==
"int8")
119 else if (s ==
"uint8")
121 else if (s ==
"int16")
123 else if (s ==
"uint16")
125 else if (s ==
"int32")
127 else if (s ==
"uint32")
129 else if (s ==
"int64")
131 else if (s ==
"uint64")
134 else if (s ==
"float32")
136 else if (s ==
"float64")
139 else if (s ==
"string")
143 else if (s ==
"otherxml")
150 D4Attribute::m_duplicate(
const D4Attribute &src)
154 d_values = src.d_values;
155 if (src.d_attributes)
156 d_attributes =
new D4Attributes(*src.d_attributes);
174 if (
this == &rhs)
return *
this;
270 throw InternalErr(__FILE__, __LINE__,
"Unknown DAP2 attribute type in D4Attributes::copy_from_dap2()");
276 D4Attributes::find_depth_first(
const string &name, D4AttributesIter i)
280 else if ((*i)->name() == name)
283 return find_depth_first(name, (*i)->attributes()->attribute_begin());
285 return find_depth_first(name, ++i);
303 size_t pos = fqn.find(
'.');
304 string part = fqn.substr(0, pos);
307 if (pos != string::npos)
308 rest = fqn.substr(pos + 1);
310 DBG(cerr <<
"part: '" << part <<
"'; rest: '" << rest <<
"'" << endl);
317 return (*i)->attributes()->get(rest);
324 if ((*i)->name() == part)
337 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar*)
"Attribute") < 0)
338 throw InternalErr(__FILE__, __LINE__,
"Could not write Attribute element");
339 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar*)
"name", (
const xmlChar*)
name().c_str()) < 0)
340 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
342 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for type");
347 throw InternalErr(__FILE__, __LINE__,
"Null Attribute container");
353 throw Error(
"OtherXML attributes cannot be vector-valued.");
354 if (xmlTextWriterWriteRaw(xml.
get_writer(), (
const xmlChar*)
value(0).c_str()) < 0)
355 throw InternalErr(__FILE__, __LINE__,
"Could not write OtherXML value");
361 while (i != d_values.end()) {
362 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar*)
"Value") < 0)
363 throw InternalErr(__FILE__, __LINE__,
"Could not write value element");
365 if (xmlTextWriterWriteString(xml.
get_writer(), (
const xmlChar*) (*i++).c_str()) < 0)
366 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute value");
368 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
369 throw InternalErr(__FILE__, __LINE__,
"Could not end value element");
376 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
377 throw InternalErr(__FILE__, __LINE__,
"Could not end Attribute element");
387 while (i != d_attrs.end()) {
std::vector< entry * >::iterator Attr_iter
D4AttributeType StringToD4AttributeType(string s)
xmlTextWriterPtr get_writer()
string value(unsigned int i) const
virtual Attr_iter attr_end()
D4Attributes * attributes()
D4AttributesIter attribute_begin()
Get an iterator to the start of the enumerations.
Contains the attributes for a dataset.
void print_dap4(XMLWriter &xml) const
D4Attribute * find(const string &name)
D4Attribute & operator=(const D4Attribute &rhs)
D4AttributeType type() const
virtual string get_name() const
Get the name of this attribute table.
A class for software fault reporting.
vector< D4Attribute * >::iterator D4AttributesIter
vector< D4Attribute * >::const_iterator D4AttributesCIter
virtual AttrTable * get_attr_table(const string &name)
Get an attribute container.
vector< string >::const_iterator D4AttributeCIter
virtual Attr_iter attr_begin()
unsigned int num_values() const
void add_attribute_nocopy(D4Attribute *attr)
void add_value_vector(const vector< string > &values)
virtual AttrType get_attr_type(const string &name)
Get the type of an attribute.
D4AttributesIter attribute_end()
Get an iterator to the end of the enumerations.
virtual vector< string > * get_attr_vector(const string &name)
Get a vector-valued attribute.
D4Attribute * get(const string &fqn)
A class for error processing.
string D4AttributeTypeToString(D4AttributeType at)
void transform_to_dap4(AttrTable &at)
copy attributes from DAP2 to DAP4
void print_dap4(XMLWriter &xml) const