55#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)
79 d_container =
new AttrTable(*src.d_container);
83 d_container_name = src.d_container_name;
84 d_attrs = src.d_attrs;
87DAS &DAS::operator=(
const DAS &rhs)
105 if (cn != d_container_name) {
113 d_container_name = cn;
136 d_container->
erase();
210 at->set_is_global_attribute(
false);
232 FILE *in = fopen(fname.c_str(),
"r");
235 throw Error(cannot_read_file,
"Could not open: " + fname);
240 int res = fclose(in);
242 DBG(cerr <<
"DAS::parse - Failed to close file " << (
void *)in << endl ;) ;
260 int new_fd = _dup(fd);
262 int new_fd = dup(fd);
266 throw InternalErr(__FILE__, __LINE__,
"Could not access file.");
267 FILE *in = fdopen(new_fd,
"r");
270 throw InternalErr(__FILE__, __LINE__,
"Could not access file.");
275 int res = fclose(in);
277 DBG(cerr <<
"DAS::parse(fd) - Failed to close " << (
void *)in << endl ;) ;
293 throw InternalErr(__FILE__, __LINE__,
"Null input stream.");
296 void *buffer = das_buffer(in);
297 das_switch_to_buffer(buffer);
302 bool status = dasparse(&arg) == 0;
304 das_delete_buffer(buffer);
308 if (!status || !arg.status()) {
331 fprintf(out,
"Attributes {\n") ;
333 d_attrs.
print(out,
" ", dereference);
335 fprintf(out,
"}\n") ;
353 out <<
"Attributes {\n" ;
355 d_attrs.
print(out,
" ", dereference);
369 strm << DapIndent::LMarg <<
"DAS::dump - (" << (
void *)
this <<
")" << endl;
372 strm << DapIndent::LMarg <<
"current container: " << d_container_name << endl;
375 strm << DapIndent::LMarg <<
"current container: NONE" << endl;
378 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.
virtual Attr_iter attr_end()
virtual Attr_iter attr_begin()
virtual string get_name() const
Get the name of this attribute table.
virtual void erase()
Erase the attribute table.
virtual void print(FILE *out, string pad=" ", bool dereference=false)
Prints the attribute table.
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
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.