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 1994-1999 00027 // Please read the full copyright statement in the file COPYRIGHT. 00028 // 00029 // Authors: 00030 // jhrg,jimg James Gallagher (jgallagher@gso.uri.edu) 00031 00032 // declarations for utility functions 00033 // 00034 // jhrg 9/21/94 00035 00036 #ifndef _util_h 00037 #define _util_h 1 00038 00039 #include <cstdio> 00040 #include <cmath> 00041 #include <vector> 00042 00043 #ifndef _basetype_h 00044 #include "BaseType.h" 00045 #endif 00046 00047 using std::iostream; 00048 00049 namespace libdap 00050 { 00051 00052 class Array; 00053 00055 inline bool double_eq(double lhs, double rhs, double epsilon = 1.0e-5) 00056 { 00057 return fabs(lhs - rhs) < epsilon; 00058 } 00059 00060 string extract_string_argument(BaseType *arg) ; 00061 double extract_double_value(BaseType *arg) ; 00062 double *extract_double_array(Array *a) ; 00063 void extract_double_array(Array *a, vector<double> &dest) ; 00064 void set_array_using_double(Array *dest, double *src, int src_len) ; 00065 00066 bool is_host_big_endian(); 00067 00068 string prune_spaces(const string &); 00069 bool unique_names(vector<BaseType *> l, const string &var, const string &type, string &msg); 00070 string systime(); 00071 const char *libdap_root(); 00072 extern "C" const char *libdap_version(); 00073 extern "C" const char *libdap_name(); 00074 00075 #ifdef WIN32 00076 void flush_stream(iostream ios, FILE *out); 00077 #endif 00078 00079 void downcase(string &s); 00080 bool is_quoted(const string &s); 00081 string remove_quotes(const string &s); 00082 00083 Type get_type(const char *name); 00084 string D2type_name(Type t); 00085 string D4type_name(Type t); 00086 string type_name(Type t); 00087 bool is_simple_type(Type t); 00088 bool is_vector_type(Type t); 00089 bool is_constructor_type(Type t); 00090 bool is_integer_type(Type t); 00091 00092 bool dir_exists(const string &dir); 00093 00094 // Jose Garcia 00125 void append_long_to_string(long val, int base, string &str_val); 00126 string long_to_string(long val, int base = 10); 00128 00129 // Jose Garcia 00143 void append_double_to_string(const double &num, string &str); 00144 string double_to_string(const double &num); 00146 00147 string path_to_filename(string path); 00148 int glob( const char *c, const char *s ); 00149 time_t parse_time(const char * str, bool expand); 00150 bool size_ok(unsigned int sz, unsigned int nelem); 00151 bool pathname_ok(const string &path, bool strict = true); 00152 string dap_version(); 00153 string open_temp_fstream(ofstream &f, const string &name_template, const string &suffix = ""); 00154 00155 } // namespace libdap 00156 00157 #endif