53 #include "AttrTable.h" 55 #include "InternalErr.h" 64 extern void das_switch_to_buffer(
void *new_buffer);
65 extern void das_delete_buffer(
void * buffer);
66 extern void *das_buffer(FILE *fp);
74 void 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;
86 DAS &DAS::operator=(
const DAS &rhs)
106 if (cn != d_container_name) {
114 d_container_name = cn;
137 d_container->
erase();
211 at->set_is_global_attribute(
false);
233 FILE *in = fopen(fname.c_str(),
"r");
236 throw Error(cannot_read_file,
"Could not open: " + fname);
241 int res = fclose(in);
243 DBG(cerr <<
"DAS::parse - Failed to close file " << (
void *)in << endl ;) ;
261 int new_fd = _dup(fd);
263 int new_fd = dup(fd);
267 throw InternalErr(__FILE__, __LINE__,
"Could not access file.");
268 FILE *in = fdopen(new_fd,
"r");
271 throw InternalErr(__FILE__, __LINE__,
"Could not access file.");
276 int res = fclose(in);
278 DBG(cerr <<
"DAS::parse(fd) - Failed to close " << (
void *)in << endl ;) ;
294 throw InternalErr(__FILE__, __LINE__,
"Null input stream.");
297 void *buffer = das_buffer(in);
298 das_switch_to_buffer(buffer);
303 bool status = dasparse(&arg) == 0;
305 das_delete_buffer(buffer);
309 if (!status || !arg.status()) {
332 fprintf(out,
"Attributes {\n") ;
334 d_attrs.
print(out,
" ", dereference);
336 fprintf(out,
"}\n") ;
354 out <<
"Attributes {\n" ;
356 d_attrs.
print(out,
" ", dereference);
370 strm << DapIndent::LMarg <<
"DAS::dump - (" << (
void *)
this <<
")" << endl;
373 strm << DapIndent::LMarg <<
"current container: " << d_container_name << endl;
376 strm << DapIndent::LMarg <<
"current container: NONE" << endl;
379 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 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 string get_name() const
Get the name of this attribute table.
virtual void print(FILE *out, bool dereference=false)
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 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 dump(ostream &strm) const
dumps information about this object
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
Returns the number of attributes in the current attribute table.
virtual unsigned int get_size() const
Get the number of entries in this attribute table.