29 #include <XMLWriter.h>
34 #include "DmrppStructure.h"
42 DmrppStructure::_duplicate(
const DmrppStructure &)
46 DmrppStructure::DmrppStructure(
const string &n) : Structure(n), DmrppCommon()
50 DmrppStructure::DmrppStructure(
const string &n,
const string &d) : Structure(n, d), DmrppCommon()
55 DmrppStructure::ptr_duplicate()
57 return new DmrppStructure(*
this);
60 DmrppStructure::DmrppStructure(
const DmrppStructure &rhs) : Structure(rhs), DmrppCommon(rhs)
66 DmrppStructure::operator=(
const DmrppStructure &rhs)
71 dynamic_cast<Structure &
>(*this) = rhs;
74 DmrppCommon::m_duplicate_common(rhs);
80 class PrintDAP4FieldXMLWriter :
public unary_function<BaseType *, void>
85 PrintDAP4FieldXMLWriter(XMLWriter &x,
bool c) : d_xml(x), d_constrained(c) {}
87 void operator()(BaseType *btp)
89 btp->print_dap4(d_xml, d_constrained);
94 DmrppStructure::print_dap4(XMLWriter &xml,
bool constrained)
96 if (constrained && !send_p())
99 if (xmlTextWriterStartElement(xml.get_writer(), (
const xmlChar*)type_name().c_str()) < 0)
100 throw InternalErr(__FILE__, __LINE__,
"Could not write " + type_name() +
" element");
103 if (xmlTextWriterWriteAttribute(xml.get_writer(), (
const xmlChar*)
"name", (
const xmlChar*)name().c_str()) < 0)
104 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
106 bool has_variables = (var_begin() != var_end());
108 for_each(var_begin(), var_end(), PrintDAP4FieldXMLWriter(xml, constrained));
110 attributes()->print_dap4(xml);
112 if (xmlTextWriterEndElement(xml.get_writer()) < 0)
113 throw InternalErr(__FILE__, __LINE__,
"Could not end " + type_name() +
" element");
118 void DmrppStructure::dump(ostream & strm)
const
120 strm << BESIndent::LMarg <<
"DmrppStructure::dump - (" << (
void *)
this <<
")" << endl;
122 DmrppCommon::dump(strm);
123 Structure::dump(strm);
124 strm << BESIndent::LMarg <<
"value: " <<
"----" << endl;
125 BESIndent::UnIndent();