util.h
// -*- 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 1994-1999
// Please read the full copyright statement in the file COPYRIGHT.
//
// Authors:
// jhrg,jimg James Gallagher (jgallagher@gso.uri.edu)
// declarations for utility functions
//
// jhrg 9/21/94
#ifndef _util_h
#define _util_h 1
#include <cstdio>
#include <cmath>
#include <vector>
#ifndef _basetype_h
#include "BaseType.h"
#endif
using std::iostream;
namespace libdap
{
class Array;
inline bool double_eq(double lhs, double rhs, double epsilon = 1.0e-5)
{
return fabs(lhs - rhs) < epsilon;
}
string extract_string_argument(BaseType *arg) ;
double extract_double_value(BaseType *arg) ;
double *extract_double_array(Array *a) ;
void extract_double_array(Array *a, vector<double> &dest) ;
void set_array_using_double(Array *dest, double *src, int src_len) ;
bool is_host_big_endian();
string prune_spaces(const string &);
bool unique_names(vector<BaseType *> l, const string &var, const string &type, string &msg);
string systime();
const char *libdap_root();
extern "C" const char *libdap_version();
extern "C" const char *libdap_name();
#ifdef WIN32
void flush_stream(iostream ios, FILE *out);
#endif
void downcase(string &s);
bool is_quoted(const string &s);
string remove_quotes(const string &s);
Type get_type(const char *name);
string D2type_name(Type t);
string D4type_name(Type t);
string type_name(Type t);
bool is_simple_type(Type t);
bool is_vector_type(Type t);
bool is_constructor_type(Type t);
bool is_integer_type(Type t);
bool dir_exists(const string &dir);
// Jose Garcia
void append_long_to_string(long val, int base, string &str_val);
string long_to_string(long val, int base = 10);
// Jose Garcia
void append_double_to_string(const double &num, string &str);
string double_to_string(const double &num);
string path_to_filename(string path);
int glob( const char *c, const char *s );
time_t parse_time(const char * str, bool expand);
bool size_ok(unsigned int sz, unsigned int nelem);
bool pathname_ok(const string &path, bool strict = true);
string dap_version();
string open_temp_fstream(ofstream &f, const string &name_template, const string &suffix = "");
} // namespace libdap
#endif
libdap::downcase
void downcase(string &s)
Definition: util.cc:563
libdap::parse_time
time_t parse_time(const char *str, bool expand)
Definition: util_mit.cc:129
libdap::is_constructor_type
bool is_constructor_type(Type t)
Returns true if the instance is a constructor (i.e., Structure, Sequence or Grid) type variable...
Definition: util.cc:863
libdap::prune_spaces
string prune_spaces(const string &name)
Definition: util.cc:459
libdap::open_temp_fstream
string open_temp_fstream(ofstream &f, const string &name_template, const string &suffix)
Definition: util.cc:1216
libdap::extract_string_argument
string extract_string_argument(BaseType *arg)
Definition: util.cc:119
libdap::dir_exists
bool dir_exists(const string &dir)
Definition: util.cc:931
libdap::size_ok
bool size_ok(unsigned int sz, unsigned int nelem)
sanitize the size of an array. Test for integer overflow when dynamically allocating an array...
Definition: util.cc:1156
libdap::is_vector_type
bool is_vector_type(Type t)
Returns true if the instance is a vector (i.e., array) type variable.
Definition: util.cc:817
libdap::Type
Type
Identifies the data type.
Definition: Type.h:94
libdap
Definition: AlarmHandler.h:35
libdap::set_array_using_double
void set_array_using_double(Array *dest, double *src, int src_len)
Definition: util.cc:166
libdap::pathname_ok
bool pathname_ok(const string &path, bool strict)
Does the string name a potentially valid pathname? Test the given pathname to verify that it is a val...
Definition: util.cc:1177
libdap::extract_double_array
double * extract_double_array(Array *a)
Definition: util.cc:261
libdap::get_type
ObjectType get_type(const string &value)
Definition: mime_util.cc:326
libdap::D4type_name
string D4type_name(Type t)
Returns the type of the class instance as a string. Supports all DAP4 types and not the DAP2-only typ...
Definition: util.cc:694
libdap::path_to_filename
string path_to_filename(string path)
Definition: util.cc:1012
libdap::is_quoted
bool is_quoted(const string &s)
Definition: util.cc:574
libdap::is_simple_type
bool is_simple_type(Type t)
Returns true if the instance is a numeric, string or URL type variable.
Definition: util.cc:775
libdap::systime
string systime()
Definition: util.cc:542
libdap::extract_double_value
double extract_double_value(BaseType *arg)
Definition: util.cc:402
libdap::dap_version
string dap_version()
Definition: util.cc:1199
libdap::remove_quotes
string remove_quotes(const string &s)
Definition: util.cc:585
libdap::BaseType
The basic data type for the DODS DAP types.
Definition: BaseType.h:117
libdap::D2type_name
string D2type_name(Type t)
Returns the type of the class instance as a string. Supports all DAP2 types and not the DAP4-only typ...
Definition: util.cc:649
libdap::is_host_big_endian
bool is_host_big_endian()
Does this host use big-endian byte order?
Definition: util.cc:94
libdap::type_name
string type_name(Type t)
Definition: util.cc:760
libdap::libdap_version
const char * libdap_version()
Definition: util.cc:526
libdap::Array
A multidimensional array of identical data types.
Definition: Array.h:112
libdap::glob
int glob(const char *c, const char *s)
Definition: util.cc:1075
libdap::double_eq
bool double_eq(double lhs, double rhs, double epsilon=1.0e-5)
Definition: util.h:55
libdap::is_integer_type
bool is_integer_type(Type t)
Definition: util.cc:906