41#include <libdap/InternalErr.h>
42#include <libdap/D4Group.h>
43#include "AsciiStructure.h"
44#include "AsciiSequence.h"
48using namespace dap_asciival;
51AsciiStructure::ptr_duplicate()
53 return new AsciiStructure(*
this);
56AsciiStructure::AsciiStructure(
const string &n) :
61AsciiStructure::AsciiStructure(Structure *bt) :
67 Vars_iter p = bt->var_begin();
68 while (p != bt->var_end()) {
69 BaseType *new_bt = basetype_to_asciitype(*p);
77 BaseType::set_send_p(bt->send_p());
80AsciiStructure::~AsciiStructure()
84void AsciiStructure::transform_to_dap4(D4Group *root, Constructor *container){
85 cerr << __func__ <<
"() -BEGIN " <<
86 "('"<< root->name() <<
"':"<< (
void *)root <<
")" <<
87 "('"<< container->name() <<
"':"<< (
void *)container <<
")" <<
89 AsciiStructure *dest =
new AsciiStructure(name());
90 Constructor::transform_to_dap4(root,dest);
91 container->add_var_nocopy(dest);
92 cerr << __func__ <<
"() - END" << endl;
95void AsciiStructure::print_header(ostream &strm)
97 Vars_iter p = var_begin();
98 while (p != var_end()) {
99 if ((*p)->is_simple_type())
100 strm << dynamic_cast<AsciiOutput&>(**p).get_full_name();
101 else if ((*p)->type() == dods_structure_c)
102 dynamic_cast<AsciiStructure&
>(**p).print_header(strm);
106 throw InternalErr(__FILE__, __LINE__,
107 "Support for ASCII output of datasets with structures which contain Sequences or Grids has not been completed.");
108 if (++p != var_end()) strm <<
", ";
114 BESDEBUG(
"ascii",
"In 'AsciiStructure::print_ascii'" << endl);
122 Vars_iter p = var_begin();
123 while (p != var_end()) {
124 if ((*p)->send_p())
dynamic_cast<AsciiOutput &
>(**p).print_ascii(strm,
false);
126 if (++p != var_end()) strm <<
", ";
130 for (Vars_iter p = var_begin(); p != var_end(); ++p) {
131 if ((*p)->send_p()) {
132 dynamic_cast<AsciiOutput&
>(**p).print_ascii(strm,
true);
virtual void print_ascii(ostream &strm, bool print_name=true)