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

Generated on Wed Nov 28 16:23:14 2007 for libdap++ by  doxygen 1.4.7