bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
XDUrl.cc
1// -*- mode: c++; c-basic-offset:4 -*-
2
3// This file is part of asciival, software which can return an XML data
4// representation of the data read from a DAP server.
5
6// Copyright (c) 2010 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// Authors:
26// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
27
28// Implementation for XDUrl. See XDByte.cc
29//
30// 3/12/98 jhrg
31
32#include "config.h"
33
34#include <BESDebug.h>
35
36#include "XDUrl.h"
37
38using namespace libdap;
39
40BaseType *
41XDUrl::ptr_duplicate()
42{
43 return new XDUrl(*this);
44}
45
46void XDUrl::print_xml_data(XMLWriter *writer, bool show_type)
47{
48 BESDEBUG("xd", "Entering XDUrl::print_xml_data" << endl);
49
50 Url *u = dynamic_cast<Url*>(d_redirect);
51#if ENABLE_UNIT_TESTS
52 if (!u) u = dynamic_cast<Url *>(this);
53#else
54 if (!u)
55 throw InternalErr(__FILE__, __LINE__, "d_redirect is null.");
56#endif
57
58 if (show_type) start_xml_declaration(writer);
59
60 // Write the element for the value, then the value
61 if (xmlTextWriterWriteElement(writer->get_writer(), (const xmlChar*) "value", (const xmlChar*) u->value().c_str())
62 < 0) throw InternalErr(__FILE__, __LINE__, "Could not write value element for " + u->name());
63
64 if (show_type) end_xml_declaration(writer);
65}
66