libdap Updated for version 3.20.10
libdap4 is an implementation of OPeNDAP's DAP protocol.
DataDDS.cc
1
2// -*- mode: c++; c-basic-offset:4 -*-
3
4// This file is part of libdap, A C++ implementation of the OPeNDAP Data
5// Access Protocol.
6
7// Copyright (c) 2002,2003 OPeNDAP, Inc.
8// Author: James Gallagher <jgallagher@opendap.org>
9//
10// This library is free software; you can redistribute it and/or
11// modify it under the terms of the GNU Lesser General Public
12// License as published by the Free Software Foundation; either
13// version 2.1 of the License, or (at your option) any later version.
14//
15// This library is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18// Lesser General Public License for more details.
19//
20// You should have received a copy of the GNU Lesser General Public
21// License along with this library; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23//
24// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25
26// (c) COPYRIGHT URI/MIT 1997-1999
27// Please read the full copyright statement in the file COPYRIGHT_URI.
28//
29// Authors:
30// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
31
32//
33// jhrg 9/19/97
34
35#include "config.h"
36
37#include <iostream>
38#include <iomanip>
39#include <sstream>
40#include <string>
41
42#include "DataDDS.h"
43#include "debug.h"
44#include "DapIndent.h"
45
46using namespace std;
47
48namespace libdap {
49
50// private
51
55void
56DataDDS::m_version_string_to_numbers()
57{
58 string num = d_server_version.substr(d_server_version.find('/') + 1);
59
60 if (!num.empty() && num.find('.') != string::npos) {
61 istringstream iss(num);
62 char c = 0;
63
64 iss >> d_server_version_major;
65 iss >> c; // This reads the `.' in the version string
66 iss >> d_server_version_minor;
67
68 // Did it parse?
69 if (!(c == '.' && d_server_version_major > 0
70 && d_server_version_minor > 0)) {
71
72 d_server_version_major = 0;
73 d_server_version_minor = 0;
74 }
75 }
76 else {
77 d_server_version_major = 0;
78 d_server_version_minor = 0;
79 }
80
81 DBG(cerr << "Server version: " << d_server_version_major << "." \
82 << d_server_version_minor << endl);
83}
84
88void
89DataDDS::m_protocol_string_to_numbers()
90{
91
92 if (!d_protocol_version.empty() && d_protocol_version.find('.')
93 != string::npos) {
94 istringstream iss(d_protocol_version);
95 char c = 0;
96
97 iss >> d_server_protocol_major;
98 iss >> c; // This reads the `.' in the version string
99 iss >> d_server_protocol_minor;
100
101 // Did it parse?
102 if (!(c == '.' && d_server_protocol_major > 0)) {
103 d_server_protocol_major = 2;
104 d_server_protocol_minor = 0;
105 }
106 }
107 else {
108 d_server_protocol_major = 2;
109 d_server_protocol_minor = 0;
110 }
111
112 DBG(cerr << "Server version: " << d_server_version_major << "." \
113 << d_server_version_minor << endl);
114}
115
123void
124DataDDS::dump(ostream &strm) const
125{
126 strm << DapIndent::LMarg << "DataDDS::dump - ("
127 << (void *)this << ")" << endl ;
128 DapIndent::Indent() ;
129 DDS::dump(strm) ;
130 strm << DapIndent::LMarg << "server version: " << d_server_version
131 << endl ;
132 strm << DapIndent::LMarg << "version major: " << d_server_version_major
133 << endl ;
134 strm << DapIndent::LMarg << "version minor: " << d_server_version_minor
135 << endl ;
136 strm << DapIndent::LMarg << "protocol version: " << d_protocol_version
137 << endl ;
138 strm << DapIndent::LMarg << "protocol major: " << d_server_protocol_major
139 << endl ;
140 strm << DapIndent::LMarg << "protocol minor: " << d_server_protocol_minor
141 << endl ;
142 DapIndent::UnIndent() ;
143}
144
145// public
146
159DataDDS::DataDDS(BaseTypeFactory *factory, const string &n, const string &v,
160 const string &p)
161 : DDS(factory, n), d_server_version(v), d_protocol_version(p)
162{
163 m_version_string_to_numbers();
164 m_protocol_string_to_numbers();
165}
166
167} // namespace libdap
168
virtual void dump(ostream &strm) const
dumps information about this object
Definition DDS.cc:1547
virtual void dump(ostream &strm) const
dumps information about this object
Definition DataDDS.cc:124
DataDDS(BaseTypeFactory *factory, const string &n="", const string &v="", const string &p="")
Make an instance of DataDDS A DataDDS instance is a DDS with additional information about the version...
Definition DataDDS.cc:159
top level DAP object to house generic methods