29 #include "XMLWriter.h" 30 #include "D4Dimensions.h" 34 #include "InternalErr.h" 39 D4Dimension::set_size(
const string &size)
41 unsigned long value = 0;
42 istringstream iss(size);
47 if (!iss || !iss.eof())
throw Error(
"Invalid value '" + size +
"' passed to D4Dimension::set_size.");
62 D4Group *grp = d_parent->parent();
65 name = (grp->
name() ==
"/") ?
"/" + name : grp->
name() +
"/" + name;
68 grp = static_cast<D4Group*>(grp->
get_parent());
85 if (xmlTextWriterStartElement(xml.get_writer(), (
const xmlChar*)
"Dimension") < 0)
86 throw InternalErr(__FILE__, __LINE__,
"Could not write Dimension element");
88 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
"name", (
const xmlChar*)d_name.c_str()) < 0)
89 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
92 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
"name", (
const xmlChar*)
fully_qualified_name().c_str()) < 0)
93 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
97 oss << (d_c_stop - d_c_start) / d_c_stride + 1;
100 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
"size", (
const xmlChar*) oss.str().c_str()) < 0)
101 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for size");
103 if (xmlTextWriterEndElement(xml.get_writer()) < 0)
104 throw InternalErr(__FILE__, __LINE__,
"Could not end Dimension element");
112 return d->name() == name;
116 D4Dimensions::find_dim(
const string &name)
118 D4DimensionsIter d = find_if(d_dims.begin(), d_dims.end(), bind2nd(ptr_fun(dim_name_eq), name));
119 return (d != d_dims.end()) ? *d: 0;
123 D4Dimensions::print_dap4(
XMLWriter &xml,
bool constrained)
const 125 D4DimensionsCIter i = d_dims.begin();
126 while (i != d_dims.end()) {
128 if (!constrained || parent()->find_first_var_that_uses_dimension(*i))
132 if ((*i)->used_by_projected_var())
133 (*i)->print_dap4(xml);
136 (*i)->print_dap4(xml);
virtual string name() const
Returns the name of the class instance.
top level DAP object to house generic methods
A class for software fault reporting.
string fully_qualified_name() const
Get the FQN for the dimension.
virtual BaseType * get_parent() const
void print_dap4(XMLWriter &xml) const
Print the Dimension declaration. Print the Dimension in a form suitable for use in a Group definition...