61 d_factory = dmr.d_factory;
64 d_filename = dmr.d_filename;
66 d_dap_major = dmr.d_dap_major;
67 d_dap_minor = dmr.d_dap_minor;
68 d_dap_version = dmr.d_dap_version;
70 d_dmr_version = dmr.d_dmr_version;
72 d_request_xml_base = dmr.d_request_xml_base;
74 d_namespace = dmr.d_namespace;
76 d_max_response_size_kb = dmr.d_max_response_size_kb;
78 d_ce_empty = dmr.d_ce_empty;
83 DBG(cerr <<
"dmr.d_root: " << dmr.d_root << endl);
84 DBG(cerr <<
"d_root (from ptr_dup(): " << d_root << endl);
122 : d_factory(
factory), d_name(dds.get_dataset_name()), d_filename(dds.
filename()) {
164 DBG(cerr << __func__ <<
"() - Transforming top level variable: " <<
" (" << (*i)->type_name() <<
":'"
165 << (*i)->name() <<
"':" << (
void *)(*i) <<
") (root:" << root_grp <<
")" << endl;);
166 (*i)->transform_to_dap4(root_grp, root_grp);
167 DBG(cerr << __func__ <<
"() - top level variable: '" << (*i)->name() <<
"' (type:" << (*i)->type_name()
168 <<
") Transformed" << endl;);
170 DBG(cerr << __func__ <<
"() - Skipping variable: " << d4_var->
type_name() <<
" " << d4_var->
name()
171 <<
" because a variable with" <<
" this name already exists in the root group." << endl;);
195 DBG(cerr << __func__ <<
"() - BEGIN" << endl);
205 unique_ptr<vector<BaseType *>> top_vars(
root()->transform_to_dap2(&(dds->
get_attr_table()) ));
216 DBG(cerr << __func__ <<
"() - END" << endl);
240 istringstream iss(v);
242 int major = -1, minor = -1;
244 if (!iss.eof() && !iss.fail())
246 if (!iss.eof() && !iss.fail())
248 if (!iss.eof() && !iss.fail())
251 if (major == -1 || minor == -1 or dot !=
'.')
252 throw InternalErr(__FILE__, __LINE__,
"Could not parse dap version. Value given: " + v);
263 switch (d_dap_major) {
307 if (xmlTextWriterStartElement(xml.
get_writer(), (
const xmlChar *)
"Dataset") < 0)
308 throw InternalErr(__FILE__, __LINE__,
"Could not write Dataset element");
310 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"xmlns",
312 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for xmlns");
315 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"xml:base",
317 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for xml:base");
320 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"dapVersion",
322 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for dapVersion");
324 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"dmrVersion",
326 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for dapVersion");
328 if (xmlTextWriterWriteAttribute(xml.
get_writer(), (
const xmlChar *)
"name", (
const xmlChar *)
name().c_str()) < 0)
329 throw InternalErr(__FILE__, __LINE__,
"Could not write attribute for name");
333 if (xmlTextWriterEndElement(xml.
get_writer()) < 0)
334 throw InternalErr(__FILE__, __LINE__,
"Could not end the top-level Group element");
346 for (
const auto var :
root()->variables()) {
347 has_dap4 |= var->is_dap4_projected(inventory);
349 for (
const auto grp :
root()->groups()) {
350 has_dap4 |= grp->is_dap4_projected(inventory);
The basic data type for the DODS DAP types.
virtual string type_name() const
Returns the type of the class instance as a string.
virtual string name() const
Returns the name of the class instance.
virtual D4Attributes * attributes()
BaseType * var(const string &name, bool exact_match=true, btp_stack *s=nullptr) override
btp_stack no longer needed; use back pointers (BaseType::get_parent())
void transform_to_dap4(AttrTable &at)
copy attributes from DAP2 to DAP4
bool has_dap4_types(const std::string &path, std::vector< std::string > &inventory) const
void print_dap4(XMLWriter &xml, bool constrained=false) override
BaseType * ptr_duplicate() override
std::vector< BaseType * > * transform_to_dap2(AttrTable *parent_attr_table) override
Transform the D4Group's variables to DAP2 variables.
void add_var_nocopy(BaseType *bt)
Adds the variable to the DDS.
virtual AttrTable & get_attr_table()
BaseTypeFactory * set_factory(BaseTypeFactory *factory)
string get_dataset_name() const
Vars_iter var_end()
Return an iterator.
std::vector< BaseType * >::iterator Vars_iter
void dump(std::ostream &strm) const override
dumps information about this object
virtual DDS * getDDS()
Build a DDS from a DMR.
void m_duplicate(const DMR &dmr)
Copy the contents of the given DMR into this one. This is defined because the we perform a deep copy ...
void set_dap_version(const std::string &version_string)
std::string get_namespace() const
Get the namespace associated with the DMR.
std::string dap_version() const
std::string request_xml_base() const
Get the URL that will return this DMR.
DMR & operator=(const DMR &rhs)
void set_name(const std::string &n)
virtual bool is_dap4_projected(std::vector< string > &inventory)
Scans the inventory of projected variables and their attributes for projected DAP4 types....
virtual void build_using_dds(DDS &dds)
long request_size(bool constrained)
Get the estimated response size, in kilobytes.
uint64_t request_size_kb(bool constrained)
Compute the estimated response size, in kilobytes.
void set_filename(const std::string &fn)
std::string filename() const
virtual D4BaseTypeFactory * factory()
std::string dmr_version() const
void print_dap4(XMLWriter &xml, bool constrained=false)
static ostream & LMarg(ostream &strm)
libdap base object for common functionality of libdap objects
A class for software fault reporting.
xmlTextWriterPtr get_writer() const
top level DAP object to house generic methods
const string c_dap40_namespace