DataDDS.cc
// -*- mode: c++; c-basic-offset:4 -*-
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
// Access Protocol.
// Copyright (c) 2002,2003 OPeNDAP, Inc.
// Author: James Gallagher <jgallagher@opendap.org>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
// (c) COPYRIGHT URI/MIT 1997-1999
// Please read the full copyright statement in the file COPYRIGHT_URI.
//
// Authors:
// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
//
// jhrg 9/19/97
#include "config.h"
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>
#include "DapIndent.h"
#include "DataDDS.h"
#include "debug.h"
using namespace std;
namespace libdap {
// private
void DataDDS::m_version_string_to_numbers() {
string num = d_server_version.substr(d_server_version.find('/') + 1);
if (!num.empty() && num.find('.') != string::npos) {
istringstream iss(num);
char c = 0;
iss >> d_server_version_major;
iss >> c; // This reads the `.' in the version string
iss >> d_server_version_minor;
// Did it parse?
if (!(c == '.' && d_server_version_major > 0 && d_server_version_minor > 0)) {
d_server_version_major = 0;
d_server_version_minor = 0;
}
} else {
d_server_version_major = 0;
d_server_version_minor = 0;
}
DBG(cerr << "Server version: " << d_server_version_major << "." << d_server_version_minor << endl);
}
void DataDDS::m_protocol_string_to_numbers() {
if (!d_protocol_version.empty() && d_protocol_version.find('.') != string::npos) {
istringstream iss(d_protocol_version);
char c = 0;
iss >> d_server_protocol_major;
iss >> c; // This reads the `.' in the version string
iss >> d_server_protocol_minor;
// Did it parse?
if (!(c == '.' && d_server_protocol_major > 0)) {
d_server_protocol_major = 2;
d_server_protocol_minor = 0;
}
} else {
d_server_protocol_major = 2;
d_server_protocol_minor = 0;
}
DBG(cerr << "Server version: " << d_server_version_major << "." << d_server_version_minor << endl);
}
void DataDDS::dump(ostream &strm) const {
strm << DapIndent::LMarg << "DataDDS::dump - (" << (void *)this << ")" << endl;
DapIndent::Indent();
DDS::dump(strm);
strm << DapIndent::LMarg << "server version: " << d_server_version << endl;
strm << DapIndent::LMarg << "version major: " << d_server_version_major << endl;
strm << DapIndent::LMarg << "version minor: " << d_server_version_minor << endl;
strm << DapIndent::LMarg << "protocol version: " << d_protocol_version << endl;
strm << DapIndent::LMarg << "protocol major: " << d_server_protocol_major << endl;
strm << DapIndent::LMarg << "protocol minor: " << d_server_protocol_minor << endl;
DapIndent::UnIndent();
}
// public
DataDDS::DataDDS(BaseTypeFactory *factory, const string &n, const string &v, const string &p)
: DDS(factory, n), d_server_version(v), d_protocol_version(p) {
m_version_string_to_numbers();
m_protocol_string_to_numbers();
}
} // namespace libdap
libdap::BaseTypeFactory
Definition BaseTypeFactory.h:79
libdap::DDS::DDS
DDS(BaseTypeFactory *factory, const string &name="")
Definition DDS.cc:160
libdap::DDS::dump
virtual void dump(ostream &strm) const
dumps information about this object
Definition DDS.cc:1411
libdap::DataDDS::dump
virtual void dump(ostream &strm) const
dumps information about this object
Definition DataDDS.cc:113
libdap::DataDDS::DataDDS
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
libdap
top level DAP object to house generic methods
Definition AlarmHandler.h:35