libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
DataDDS.cc
Go to the documentation of this file.
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 <iomanip>
38#include <iostream>
39#include <sstream>
40#include <string>
41
42#include "DapIndent.h"
43#include "DataDDS.h"
44#include "debug.h"
45
46using namespace std;
47
48namespace libdap {
49
50// private
51
55void DataDDS::m_version_string_to_numbers() {
56 string num = d_server_version.substr(d_server_version.find('/') + 1);
57
58 if (!num.empty() && num.find('.') != string::npos) {
59 istringstream iss(num);
60 char c = 0;
61
62 iss >> d_server_version_major;
63 iss >> c; // This reads the `.' in the version string
64 iss >> d_server_version_minor;
65
66 // Did it parse?
67 if (!(c == '.' && d_server_version_major > 0 && d_server_version_minor > 0)) {
68
69 d_server_version_major = 0;
70 d_server_version_minor = 0;
71 }
72 } else {
73 d_server_version_major = 0;
74 d_server_version_minor = 0;
75 }
76
77 DBG(cerr << "Server version: " << d_server_version_major << "." << d_server_version_minor << endl);
78}
79
83void DataDDS::m_protocol_string_to_numbers() {
84
85 if (!d_protocol_version.empty() && d_protocol_version.find('.') != string::npos) {
86 istringstream iss(d_protocol_version);
87 char c = 0;
88
89 iss >> d_server_protocol_major;
90 iss >> c; // This reads the `.' in the version string
91 iss >> d_server_protocol_minor;
92
93 // Did it parse?
94 if (!(c == '.' && d_server_protocol_major > 0)) {
95 d_server_protocol_major = 2;
96 d_server_protocol_minor = 0;
97 }
98 } else {
99 d_server_protocol_major = 2;
100 d_server_protocol_minor = 0;
101 }
102
103 DBG(cerr << "Server version: " << d_server_version_major << "." << d_server_version_minor << endl);
104}
105
113void DataDDS::dump(ostream &strm) const {
114 strm << DapIndent::LMarg << "DataDDS::dump - (" << (void *)this << ")" << endl;
116 DDS::dump(strm);
117 strm << DapIndent::LMarg << "server version: " << d_server_version << endl;
118 strm << DapIndent::LMarg << "version major: " << d_server_version_major << endl;
119 strm << DapIndent::LMarg << "version minor: " << d_server_version_minor << endl;
120 strm << DapIndent::LMarg << "protocol version: " << d_protocol_version << endl;
121 strm << DapIndent::LMarg << "protocol major: " << d_server_protocol_major << endl;
122 strm << DapIndent::LMarg << "protocol minor: " << d_server_protocol_minor << endl;
124}
125
126// public
127
139
140DataDDS::DataDDS(BaseTypeFactory *factory, const string &n, const string &v, const string &p)
141 : DDS(factory, n), d_server_version(v), d_protocol_version(p) {
142 m_version_string_to_numbers();
143 m_protocol_string_to_numbers();
144}
145
146} // namespace libdap
DDS(BaseTypeFactory *factory, const string &name="")
Definition DDS.cc:160
virtual void dump(ostream &strm) const
dumps information about this object
Definition DDS.cc:1406
static ostream & LMarg(ostream &strm)
Definition DapIndent.cc:61
static void Indent()
Definition DapIndent.cc:44
static void UnIndent()
Definition DapIndent.cc:46
virtual void dump(ostream &strm) const
dumps information about this object
Definition DataDDS.cc:113
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:140
#define DBG(x)
Definition debug.h:58
top level DAP object to house generic methods
Definition AISConnect.cc:30