30#include "D4Dimensions.h"
34#include "InternalErr.h"
39D4Dimension::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;
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");
113 return d->name() == name;
118D4Dimensions::find_dim(
const string &name)
121 D4DimensionsIter d = find_if(d_dims.begin(), d_dims.end(), bind2nd(ptr_fun(dim_name_eq), name));
123 auto d = find_if(d_dims.begin(), d_dims.end(),
124 [name](
const D4Dimension *dim) { return name == dim->name(); });
125 return (d != d_dims.end()) ? *d: 0;
129D4Dimensions::print_dap4(XMLWriter &xml,
bool constrained)
const
131 D4DimensionsCIter i = d_dims.begin();
132 while (i != d_dims.end()) {
134 if (!constrained || parent()->find_first_var_that_uses_dimension(*i))
135 (*i)->print_dap4(xml);
138 if ((*i)->used_by_projected_var())
139 (*i)->print_dap4(xml);
142 (*i)->print_dap4(xml);
virtual string name() const
Returns the name of the class instance.
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...
string fully_qualified_name() const
Get the FQN for the dimension.
vector< D4Dimension * >::iterator D4DimensionsIter
Iterator used for D4Dimensions.
A class for software fault reporting.
top level DAP object to house generic methods