libdap
Updated for version 3.17.0
|
00001 00002 // -*- mode: c++; c-basic-offset:4 -*- 00003 00004 // This file is part of libdap, A C++ implementation of the OPeNDAP Data 00005 // Access Protocol. 00006 00007 // Copyright (c) 2002,2003 OPeNDAP, Inc. 00008 // Author: James Gallagher <jgallagher@opendap.org> 00009 // 00010 // This library is free software; you can redistribute it and/or 00011 // modify it under the terms of the GNU Lesser General Public 00012 // License as published by the Free Software Foundation; either 00013 // version 2.1 of the License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00023 // 00024 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112. 00025 00026 // (c) COPYRIGHT URI/MIT 1997-1999 00027 // Please read the full copyright statement in the file COPYRIGHT_URI. 00028 // 00029 // Authors: 00030 // jhrg,jimg James Gallagher <jgallagher@gso.uri.edu> 00031 00032 // 00033 // jhrg 9/19/97 00034 00035 #include "config.h" 00036 00037 #include <iostream> 00038 #include <iomanip> 00039 #include <sstream> 00040 #include <string> 00041 00042 #include "DataDDS.h" 00043 #include "debug.h" 00044 00045 using namespace std; 00046 00047 namespace libdap { 00048 00049 // private 00050 00054 void 00055 DataDDS::m_version_string_to_numbers() 00056 { 00057 string num = d_server_version.substr(d_server_version.find('/') + 1); 00058 00059 if (!num.empty() && num.find('.') != string::npos) { 00060 istringstream iss(num); 00061 char c; 00062 00063 iss >> d_server_version_major; 00064 iss >> c; // This reads the `.' in the version string 00065 iss >> d_server_version_minor; 00066 00067 // Did it parse? 00068 if (!(c == '.' && d_server_version_major > 0 00069 && d_server_version_minor > 0)) { 00070 00071 d_server_version_major = 0; 00072 d_server_version_minor = 0; 00073 } 00074 } 00075 else { 00076 d_server_version_major = 0; 00077 d_server_version_minor = 0; 00078 } 00079 00080 DBG(cerr << "Server version: " << d_server_version_major << "." \ 00081 << d_server_version_minor << endl); 00082 } 00083 00087 void 00088 DataDDS::m_protocol_string_to_numbers() 00089 { 00090 00091 if (!d_protocol_version.empty() && d_protocol_version.find('.') 00092 != string::npos) { 00093 istringstream iss(d_protocol_version); 00094 char c; 00095 00096 iss >> d_server_protocol_major; 00097 iss >> c; // This reads the `.' in the version string 00098 iss >> d_server_protocol_minor; 00099 00100 // Did it parse? 00101 if (!(c == '.' && d_server_protocol_major > 0)) { 00102 d_server_protocol_major = 2; 00103 d_server_protocol_minor = 0; 00104 } 00105 } 00106 else { 00107 d_server_protocol_major = 2; 00108 d_server_protocol_minor = 0; 00109 } 00110 00111 DBG(cerr << "Server version: " << d_server_version_major << "." \ 00112 << d_server_version_minor << endl); 00113 } 00114 00122 void 00123 DataDDS::dump(ostream &strm) const 00124 { 00125 strm << DapIndent::LMarg << "DataDDS::dump - (" 00126 << (void *)this << ")" << endl ; 00127 DapIndent::Indent() ; 00128 DDS::dump(strm) ; 00129 strm << DapIndent::LMarg << "server version: " << d_server_version 00130 << endl ; 00131 strm << DapIndent::LMarg << "version major: " << d_server_version_major 00132 << endl ; 00133 strm << DapIndent::LMarg << "version minor: " << d_server_version_minor 00134 << endl ; 00135 strm << DapIndent::LMarg << "protocol version: " << d_protocol_version 00136 << endl ; 00137 strm << DapIndent::LMarg << "protocol major: " << d_server_protocol_major 00138 << endl ; 00139 strm << DapIndent::LMarg << "protocol minor: " << d_server_protocol_minor 00140 << endl ; 00141 DapIndent::UnIndent() ; 00142 } 00143 00144 // public 00145 00158 DataDDS::DataDDS(BaseTypeFactory *factory, const string &n, const string &v, 00159 const string &p) 00160 : DDS(factory, n), d_server_version(v), d_protocol_version(p) 00161 { 00162 m_version_string_to_numbers(); 00163 m_protocol_string_to_numbers(); 00164 } 00165 00166 } // namespace libdap 00167