53 #include "AttrTable.h" 55 #include "InternalErr.h" 59 #include "DapIndent.h" 65 extern void das_switch_to_buffer(
void *new_buffer);
66 extern void das_delete_buffer(
void * buffer);
67 extern void *das_buffer(FILE *fp);
75 void DAS::duplicate(
const DAS &src)
79 d_container =
new AttrTable(*src.d_container);
83 d_container_name = src.d_container_name;
84 d_attrs = src.d_attrs;
87 DAS &DAS::operator=(
const DAS &rhs)
107 if (cn != d_container_name) {
115 d_container_name = cn;
138 d_container->
erase();
212 at->set_is_global_attribute(
false);
234 FILE *in = fopen(fname.c_str(),
"r");
237 throw Error(cannot_read_file,
"Could not open: " + fname);
242 int res = fclose(in);
244 DBG(cerr <<
"DAS::parse - Failed to close file " << (
void *)in << endl ;) ;
262 int new_fd = _dup(fd);
264 int new_fd = dup(fd);
268 throw InternalErr(__FILE__, __LINE__,
"Could not access file.");
269 FILE *in = fdopen(new_fd,
"r");
272 throw InternalErr(__FILE__, __LINE__,
"Could not access file.");
277 int res = fclose(in);
279 DBG(cerr <<
"DAS::parse(fd) - Failed to close " << (
void *)in << endl ;) ;
295 throw InternalErr(__FILE__, __LINE__,
"Null input stream.");
298 void *buffer = das_buffer(in);
299 das_switch_to_buffer(buffer);
304 bool status = dasparse(&arg) == 0;
306 das_delete_buffer(buffer);
310 if (!status || !arg.status()) {
333 fprintf(out,
"Attributes {\n") ;
335 d_attrs.
print(out,
" ", dereference);
337 fprintf(out,
"}\n") ;
355 out <<
"Attributes {\n" ;
357 d_attrs.
print(out,
" ", dereference);
371 strm << DapIndent::LMarg <<
"DAS::dump - (" << (
void *)
this <<
")" << endl;
374 strm << DapIndent::LMarg <<
"current container: " << d_container_name << endl;
377 strm << DapIndent::LMarg <<
"current container: NONE" << endl;
380 DapIndent::UnIndent();
AttrTable * get_table(AttrTable::Attr_iter &i)
Returns the referenced variable attribute table.
virtual Attr_iter attr_end()
Contains the attributes for a dataset.
AttrTable::Attr_iter var_begin()
Returns a reference to the attribute table for the first variable.
virtual string get_name() const
Get the name of this 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, string pad=" ", bool dereference=false)
Prints the attribute table.
virtual void print(FILE *out, bool dereference=false)
top level DAP object to house generic methods
A class for software fault reporting.
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.
string get_name(AttrTable::Attr_iter &i)
Returns the name of the referenced variable attribute table.
virtual void erase()
Erase the attribute table.
virtual unsigned int get_size() const
Returns the number of attributes in the current attribute table.
virtual void erase()
erase all attributes in this DAS
virtual Attr_iter attr_begin()
virtual string container_name() const
Returns the name of the current attribute container when multiple files used to build this DAS...
AttrTable::Attr_iter var_end()
virtual void parse(string fname)
Reads a DAS from the named file.
Pass parameters by reference to a parser.
virtual void dump(ostream &strm) const
dumps information about this object
A class for error processing.
virtual unsigned int get_size() const
Get the number of entries in this attribute table.
virtual void dump(ostream &strm) const
dumps information about this object