56#include "InternalErr.h"
65extern void das_switch_to_buffer(
void *new_buffer);
66extern void das_delete_buffer(
void *buffer);
67extern void *das_buffer(FILE *fp);
75void DAS::duplicate(
const DAS &src) {
78 d_container =
new AttrTable(*src.d_container);
82 d_container_name = src.d_container_name;
83 d_attrs = src.d_attrs;
86DAS &DAS::operator=(
const DAS &rhs) {
102 if (cn != d_container_name) {
110 d_container_name = cn;
122 return d_container->get_size();
124 return d_attrs.get_size();
131 d_container->erase();
141 return d_container->attr_begin();
143 return d_attrs.attr_begin();
151 return d_container->attr_end();
153 return d_attrs.attr_end();
160 return d_container->get_name(i);
162 return d_attrs.get_name(i);
169 return d_container->get_attr_table(i);
178 return d_container->get_attr_table(name);
195 at->set_is_global_attribute(
false);
196 return d_container->append_container(at, name);
214 FILE *in = fopen(fname.c_str(),
"r");
217 throw Error(cannot_read_file,
"Could not open: " + fname);
222 int res = fclose(in);
224 DBG(cerr <<
"DAS::parse - Failed to close file " << (
void *)in << endl;);
240 int new_fd = _dup(fd);
242 int new_fd = dup(fd);
246 throw InternalErr(__FILE__, __LINE__,
"Could not access file.");
247 FILE *in = fdopen(new_fd,
"r");
250 throw InternalErr(__FILE__, __LINE__,
"Could not access file.");
255 int res = fclose(in);
257 DBG(cerr <<
"DAS::parse(fd) - Failed to close " << (
void *)in << endl;);
269 throw InternalErr(__FILE__, __LINE__,
"Null input stream.");
272 void *buffer = das_buffer(in);
273 das_switch_to_buffer(buffer);
278 bool status = dasparse(&arg) == 0;
280 das_delete_buffer(buffer);
284 if (!status || !arg.status()) {
305 fprintf(out,
"Attributes {\n");
307 d_attrs.print(out,
" ", dereference);
325 out <<
"Attributes {\n";
327 d_attrs.print(out,
" ", dereference);
340 strm << DapIndent::LMarg <<
"DAS::dump - (" << (
void *)
this <<
")" << endl;
343 strm << DapIndent::LMarg <<
"current container: " << d_container_name << endl;
345 strm << DapIndent::LMarg <<
"current container: NONE" << endl;
348 DapIndent::UnIndent();
Contains the attributes for a dataset.
virtual AttrTable * append_container(const string &name)
Add a container to the attribute table.
virtual AttrTable * get_attr_table(const string &name)
Get an attribute container.
Hold attribute data for a DAP2 dataset.
AttrTable::Attr_iter var_begin()
Returns a reference to the attribute table for the first variable.
virtual unsigned int get_size() const
Returns the number of attributes in the current attribute table.
virtual AttrTable * add_table(const string &name, AttrTable *at)
Adds a variable attribute table to the DAS or the current dataset container attribute table.
virtual void print(FILE *out, bool dereference=false)
virtual void dump(ostream &strm) const
dumps information about this object
AttrTable::Attr_iter var_end()
virtual void parse(string fname)
Reads a DAS from the named file.
AttrTable * get_table(AttrTable::Attr_iter &i)
Returns the referenced variable attribute table.
virtual void erase()
erase all attributes in this DAS
string get_name(AttrTable::Attr_iter &i)
Returns the name of the referenced variable attribute table.
virtual string container_name() const
Returns the name of the current attribute container when multiple files used to build this DAS.
A class for error processing.
A class for software fault reporting.
top level DAP object to house generic methods
Pass parameters by reference to a parser.