62 Constructor::Constructor(
const string &n,
const Type &t)
76 Constructor::Constructor(
const string &n,
const string &d,
const Type &t)
92 dynamic_cast<BaseType &
>(*this) = rhs;
103 return _vars.begin() ;
129 string::size_type i = source->
name.find(
"_dim_");
130 if (i != string::npos && (btp =
var(source->
name.substr(0, i)))) {
137 int n = atoi(source->
name.substr(i + 5).c_str());
138 DBG(cerr <<
"Found a Grid (" << btp->
name() <<
") and "
139 << source->
name.substr(i) <<
", extracted n: " << n << endl);
140 return *(
dynamic_cast<Grid&
>(*btp).map_begin() + n);
151 Constructor::find_matching_container(AttrTable::entry *source,
152 BaseType **dest_variable)
156 throw InternalErr(__FILE__, __LINE__,
"Constructor::find_matching_container");
161 if ((btp =
var(source->name))) {
163 *dest_variable = btp;
168 else if ((btp = find_hdf4_dimension_attribute_home(source))) {
172 DBG(cerr <<
"Found a Grid" << endl);
173 *dest_variable = btp;
174 return &btp->get_attr_table();
177 string::size_type i = source->name.find(
"_dim_");
178 string ext = source->name.substr(i + 1);
179 *dest_variable = btp;
180 return btp->get_attr_table().append_container(ext);
187 at =
new AttrTable();
217 DBG(cerr <<
"Constructor::transfer_attributes, variable: " <<
name() <<
219 DBG(cerr <<
"Working on the '" << entry->
220 name <<
"' container." << endl);
222 throw InternalErr(__FILE__, __LINE__,
223 "Constructor::transfer_attributes");
225 AttrTable *source = entry->attributes;
227 AttrTable *dest = find_matching_container(entry, &dest_variable);
231 while (source_p != source->attr_end()) {
232 DBG(cerr <<
"Working on the '" << (*source_p)->
233 name <<
"' attribute" << endl);
236 if (dest_variable && dest_variable->is_constructor_type()) {
237 dynamic_cast <Constructor & >(*dest_variable).transfer_attributes(*source_p);
240 dest->append_container(
new AttrTable(*(*source_p)->attributes),
245 dest->append_attr(source->get_name(source_p),
246 source->get_type(source_p),
247 source->get_attr_vector(source_p));
273 DBG(cerr <<
"Processing the attributes for: " << (*var)->name() <<
" a " << (*var)->type_name() << endl);
274 (*var)->transfer_attributes(at);
312 return _vars.rbegin();
329 return _vars.begin() + i;
338 return *(
_vars.begin() + i);
344 bool constraint_info,
bool constrained)
346 if (constrained && !
send_p())
349 fprintf(out,
"%s%s {\n", space.c_str(),
type_name().c_str()) ;
351 (*i)->print_decl(out, space +
" ",
true,
352 constraint_info, constrained);
354 fprintf(out,
"%s} %s", space.c_str(),
id2www(
name()).c_str()) ;
356 if (constraint_info) {
358 cout <<
": Send True";
360 cout <<
": Send False";
364 fprintf(out,
";\n") ;
370 bool constraint_info,
bool constrained)
372 if (constrained && !
send_p())
377 (*i)->print_decl(out, space +
" ",
true,
378 constraint_info, constrained);
382 if (constraint_info) {
384 out <<
": Send True";
386 out <<
": Send False";
394 class PrintField :
public unary_function<BaseType *, void>
400 PrintField(FILE *o,
string s,
bool c)
401 : d_out(o), d_space(s), d_constrained(c)
404 void operator()(BaseType *btp)
406 btp->print_xml(d_out, d_space, d_constrained);
416 if (constrained && !
send_p())
419 bool has_attributes =
false;
422 fprintf(out,
"%s<%s", space.c_str(),
type_name().c_str());
424 fprintf(out,
" name=\"%s\"",
id2xml(
name()).c_str());
426 if (has_attributes || has_variables) {
432 PrintField(out, space +
" ", constrained));
434 fprintf(out,
"%s</%s>\n", space.c_str(),
type_name().c_str());
437 fprintf(out,
"/>\n");
442 class PrintFieldStrm :
public unary_function<BaseType *, void>
448 PrintFieldStrm(ostream &o,
string s,
bool c)
449 : d_out(o), d_space(s), d_constrained(c)
452 void operator()(BaseType *btp)
454 btp->print_xml(d_out, d_space, d_constrained);
464 if (constrained && !
send_p())
467 bool has_attributes =
false;
474 if (has_attributes || has_variables) {
480 PrintFieldStrm(out, space +
" ", constrained));
482 out << space <<
"</" <<
type_name() <<
">\n" ;
489 class PrintFieldXMLWriter :
public unary_function<BaseType *, void>
494 PrintFieldXMLWriter(
XMLWriter &x,
bool c)
495 : d_xml(x), d_constrained(c)
498 void operator()(BaseType *btp)
500 btp->print_xml_writer(d_xml, d_constrained);
507 if (constrained && !
send_p())
514 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar*)
"name", (
const xmlChar*)
name().c_str()) < 0)
515 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
517 bool has_attributes =
false;
519 if (has_attributes || has_variables) {
525 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
559 << (
void *)
this <<
")" << endl ;
563 DapIndent::Indent() ;
566 for (; i != ie; i++) {