DataDDS.cc

Go to the documentation of this file.
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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 static char rcsid[] not_used =
00038     {"$Id: DataDDS.cc 16088 2007-03-28 21:42:19Z jimg $"
00039     };
00040 
00041 
00042 #include <iostream>
00043 #include <sstream>
00044 #include <string>
00045 
00046 #include "DataDDS.h"
00047 #include "debug.h"
00048 
00049 using namespace std;
00050 
00051 // private
00052 
00056 void
00057 DataDDS::m_version_string_to_numbers()
00058 {
00059     string num = d_server_version.substr(d_server_version.find('/') + 1);
00060 
00061     if (!num.empty() && num.find('.') != string::npos) {
00062         istringstream iss(num);
00063         char c;
00064 
00065         iss >> d_server_version_major;
00066         iss >> c;               // This reads the `.' in the version string
00067         iss >> d_server_version_minor;
00068 
00069         // Did it parse?
00070         if (!(c == '.' && d_server_version_major > 0
00071               && d_server_version_minor > 0)) {
00072 
00073             d_server_version_major = 0;
00074             d_server_version_minor = 0;
00075         }
00076     }
00077     else {
00078         d_server_version_major = 0;
00079         d_server_version_minor = 0;
00080     }
00081 
00082     DBG(cerr << "Server version: " << d_server_version_major << "." \
00083         << d_server_version_minor << endl);
00084 }
00085 
00089 void
00090 DataDDS::m_protocol_string_to_numbers()
00091 {
00092 
00093     if (!d_protocol_version.empty() && d_protocol_version.find('.')
00094         != string::npos) {
00095         istringstream iss(d_protocol_version);
00096         char c;
00097 
00098         iss >> d_server_protocol_major;
00099         iss >> c;               // This reads the `.' in the version string
00100         iss >> d_server_protocol_minor;
00101 
00102         // Did it parse?
00103         if (!(c == '.' && d_server_protocol_major > 0)) {
00104             d_server_protocol_major = 2;
00105             d_server_protocol_minor = 0;
00106         }
00107     }
00108     else {
00109         d_server_protocol_major = 2;
00110         d_server_protocol_minor = 0;
00111     }
00112 
00113     DBG(cerr << "Server version: " << d_server_version_major << "." \
00114         << d_server_version_minor << endl);
00115 }
00116 
00124 void
00125 DataDDS::dump(ostream &strm) const
00126 {
00127     strm << DapIndent::LMarg << "DataDDS::dump - ("
00128     << (void *)this << ")" << endl ;
00129     DapIndent::Indent() ;
00130     DDS::dump(strm) ;
00131     strm << DapIndent::LMarg << "server version: " << d_server_version
00132     << endl ;
00133     strm << DapIndent::LMarg << "version major: " << d_server_version_major
00134     << endl ;
00135     strm << DapIndent::LMarg << "version minor: " << d_server_version_minor
00136     << endl ;
00137     strm << DapIndent::LMarg << "protocol version: " << d_protocol_version
00138     << endl ;
00139     strm << DapIndent::LMarg << "protocol major: " << d_server_protocol_major
00140     << endl ;
00141     strm << DapIndent::LMarg << "protocol minor: " << d_server_protocol_minor
00142     << endl ;
00143     DapIndent::UnIndent() ;
00144 }
00145 
00146 // public
00147 
00160 DataDDS::DataDDS(BaseTypeFactory *factory, const string &n, const string &v,
00161                  const string &p)
00162         : DDS(factory, n), d_server_version(v), d_protocol_version(p)
00163 {
00164     m_version_string_to_numbers();
00165     m_protocol_string_to_numbers();
00166 }
00167 

Generated on Wed Jun 27 12:56:38 2007 for libdap++ by  doxygen 1.4.7