libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
D4Maps.cc
Go to the documentation of this file.
1// -*- mode: c++; c-basic-offset:4 -*-
2
3// This file is part of libdap, A C++ implementation of the OPeNDAP Data
4// Access Protocol.
5
6// Copyright (c) 2013 OPeNDAP, Inc.
7// Author: James Gallagher <jgallagher@opendap.org>
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Lesser General Public
11// License as published by the Free Software Foundation; either
12// version 2.1 of the License, or (at your option) any later version.
13//
14// This library is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Lesser General Public License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22//
23// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24
25#include "config.h"
26
27#include "Array.h"
28#include "D4Dimensions.h"
29#include "D4Group.h"
30#include "D4Maps.h"
31#include "InternalErr.h"
32#include "XMLWriter.h"
33
34using namespace libdap;
35
37 if (d_array)
38 return d_array;
39 else {
40 d_array = dynamic_cast<Array *>(root->find_var(d_array_path));
41 if (!d_array)
42 throw InternalErr(__FILE__, __LINE__, std::string("Failed to find an array at: ").append(d_array_path));
43 return d_array;
44 }
45}
46
48 if (xmlTextWriterStartElement(xml.get_writer(), (const xmlChar *)"Map") < 0)
49 throw InternalErr(__FILE__, __LINE__, "Could not write Map element");
50
51 if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar *)"name",
52 (const xmlChar *)(d_array ? d_array->FQN().c_str() : d_name.c_str())) < 0)
53 throw InternalErr(__FILE__, __LINE__, "Could not write attribute for name");
54
55 if (xmlTextWriterEndElement(xml.get_writer()) < 0)
56 throw InternalErr(__FILE__, __LINE__, "Could not end Map element");
57}
A multidimensional array of identical data types.
Definition Array.h:121
BaseType * find_var(const string &name)
Definition D4Group.cc:354
virtual void print_dap4(XMLWriter &xml)
Definition D4Maps.cc:47
Array * array() const
Only use this accessor in code that can deal with a nullptr return!
Definition D4Maps.h:101
A class for software fault reporting.
Definition InternalErr.h:61
xmlTextWriterPtr get_writer() const
Definition XMLWriter.h:55
top level DAP object to house generic methods
Definition AISConnect.cc:30