39 unsigned long value = 0;
40 istringstream iss(
size);
45 if (!iss || !iss.eof())
46 throw Error(
"Invalid value '" +
size +
"' passed to D4Dimension::set_size.");
59 D4Group *grp = d_parent->parent();
80 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar *)
"Dimension") < 0)
81 throw InternalErr(__FILE__, __LINE__,
"Could not write Dimension element");
83 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"name", (
const xmlChar *)d_name.c_str()) < 0)
84 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
88 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
92 oss << (d_c_stop - d_c_start) / d_c_stride + 1;
95 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"size", (
const xmlChar *)oss.str().c_str()) < 0)
96 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for size");
98 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
99 throw InternalErr(__FILE__, __LINE__,
"Could not end Dimension element");
108 return d->
name() == name;
114 D4DimensionsIter d = find_if(d_dims.begin(), d_dims.end(), bind2nd(ptr_fun(dim_name_eq), name));
116 auto d = find_if(d_dims.begin(), d_dims.end(), [name](
const D4Dimension *dim) { return name == dim->name(); });
117 return (d != d_dims.end()) ? *d : 0;
122 while (i != d_dims.end()) {
124 if (!constrained ||
parent()->find_first_var_that_uses_dimension(*i))
125 (*i)->print_dap4(xml);
128 if ((*i)->used_by_projected_var())
129 (*i)->print_dap4(xml);
131 (*i)->print_dap4(xml);
virtual string name() const
Returns the name of the class instance.
virtual BaseType * get_parent() const
unsigned long long size() const
void print_dap4(XMLWriter &xml) const
Print the Dimension declaration. Print the Dimension in a form suitable for use in a Group definition...
void set_size(unsigned long long size)
string fully_qualified_name() const
Get the FQN for the dimension.
vector< D4Dimension * >::iterator D4DimensionsIter
Iterator used for D4Dimensions.
vector< D4Dimension * >::const_iterator D4DimensionsCIter
D4Dimension * find_dim(const string &name)
void print_dap4(XMLWriter &xml, bool constrained=false) const
A class for error processing.
A class for software fault reporting.
xmlTextWriterPtr get_writer() const
top level DAP object to house generic methods