libdap++  Updated for version 3.13.1
util.cc
Go to the documentation of this file.
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
5 // Access Protocol.
6 
7 // Copyright (c) 2002,2003 OPeNDAP, Inc.
8 // Author: James Gallagher <jgallagher@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 // (c) COPYRIGHT URI/MIT 1994-1999
27 // Please read the full copyright statement in the file COPYRIGHT_URI.
28 //
29 // Authors:
30 // jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
31 
32 // Utility functions used by the api.
33 //
34 // jhrg 9/21/94
35 
36 #include "config.h"
37 
38 #include <fstream>
39 
40 #include <cassert>
41 #include <cstring>
42 #include <climits>
43 
44 #include <ctype.h>
45 #ifndef TM_IN_SYS_TIME
46 #include <time.h>
47 #else
48 #include <sys/time.h>
49 #endif
50 
51 #ifndef WIN32
52 #include <unistd.h> // for stat
53 #else
54 #include <io.h>
55 #include <fcntl.h>
56 #include <process.h>
57 #endif
58 
59 #include <sys/types.h>
60 #include <sys/stat.h>
61 
62 #include <string>
63 #include <sstream>
64 #include <vector>
65 #include <algorithm>
66 #include <stdexcept>
67 
68 #include "BaseType.h"
69 #include "Byte.h"
70 #include "Int16.h"
71 #include "Int32.h"
72 #include "UInt16.h"
73 #include "UInt32.h"
74 #include "Float32.h"
75 #include "Float64.h"
76 #include "Str.h"
77 #include "Array.h"
78 
79 #include "Error.h"
80 
81 #include "util.h"
82 #include "GNURegex.h"
83 #include "debug.h"
84 
85 using namespace std;
86 
87 namespace libdap {
88 
97 {
98  assert(arg);
99 
100  if (arg->type() != dods_str_c)
101  throw Error(malformed_expr,
102  "The function requires a DAP string argument.");
103 
104  if (!arg->read_p())
105  throw InternalErr(__FILE__, __LINE__,
106  "The CE Evaluator built an argument list where some constants held no values.");
107 
108  string s = static_cast<Str*>(arg)->value();
109 
110  DBG(cerr << "s: " << s << endl);
111 
112  return s;
113 }
114 
115 template<class T> static void set_array_using_double_helper(Array * a, double *src, int src_len)
116 {
117  T *values = new T[src_len];
118  // TODO Replace new with vector<T> (vector<T> values(src_len);)
119  for (int i = 0; i < src_len; ++i)
120  values[i] = (T) src[i];
121 
122 #ifdef VAL2BUF
123  a->val2buf(values, true);
124 #else
125  a->set_value(values, src_len);
126 #endif
127 
128  delete[]values;
129 }
130 
150 void set_array_using_double(Array * dest, double *src, int src_len)
151 {
152  // Simple types are Byte, ..., Float64, String and Url.
153  if ((dest->type() == dods_array_c && !dest->var()->is_simple_type())
154  || dest->var()->type() == dods_str_c
155  || dest->var()->type() == dods_url_c)
156  throw InternalErr(__FILE__, __LINE__,
157  "The function requires a DAP numeric-type array argument.");
158 
159  // Test sizes. Note that Array::length() takes any constraint into account
160  // when it returns the length. Even if this was removed, the 'helper'
161  // function this uses calls Vector::val2buf() which uses Vector::width()
162  // which in turn uses length().
163  if (dest->length() != src_len)
164  throw InternalErr(__FILE__, __LINE__,
165  "The source and destination array sizes don't match ("
166  + long_to_string(src_len) + " versus "
167  + long_to_string(dest->length()) + ").");
168 
169  // The types of arguments that the CE Parser will build for numeric
170  // constants are limited to Uint32, Int32 and Float64. See ce_expr.y.
171  // Expanded to work for any numeric type so it can be used for more than
172  // just arguments.
173  switch (dest->var()->type()) {
174  case dods_byte_c:
175  set_array_using_double_helper<dods_byte>(dest, src, src_len);
176  break;
177  case dods_uint16_c:
178  set_array_using_double_helper<dods_uint16>(dest, src, src_len);
179  break;
180  case dods_int16_c:
181  set_array_using_double_helper<dods_int16>(dest, src, src_len);
182  break;
183  case dods_uint32_c:
184  set_array_using_double_helper<dods_uint32>(dest, src, src_len);
185  break;
186  case dods_int32_c:
187  set_array_using_double_helper<dods_int32>(dest, src, src_len);
188  break;
189  case dods_float32_c:
190  set_array_using_double_helper<dods_float32>(dest, src, src_len);
191  break;
192  case dods_float64_c:
193  set_array_using_double_helper<dods_float64>(dest, src, src_len);
194  break;
195  default:
196  throw InternalErr(__FILE__, __LINE__,
197  "The argument list built by the CE parser contained an unsupported numeric type.");
198  }
199 
200  // Set the read_p property.
201  dest->set_read_p(true);
202 }
203 
204 template<class T> static double *extract_double_array_helper(Array * a)
205 {
206  int length = a->length();
207  // Could improve this using vector<T>. jhrg
208  T *b = new T[length];
209  a->value(b);
210 
211  double *dest = new double[length];
212  for (int i = 0; i < length; ++i)
213  dest[i] = (double) b[i];
214  delete[]b;
215 
216  return dest;
217 }
218 
224 {
225  // Simple types are Byte, ..., Float64, String and Url.
226  if ((a->type() == dods_array_c && !a->var()->is_simple_type())
227  || a->var()->type() == dods_str_c || a->var()->type() == dods_url_c)
228  throw Error(malformed_expr,
229  "The function requires a DAP numeric-type array argument.");
230 
231  if (!a->read_p())
232  throw InternalErr(__FILE__, __LINE__,
233  string("The Array '") + a->name() +
234  "'does not contain values.");
235 
236  // The types of arguments that the CE Parser will build for numeric
237  // constants are limited to Uint32, Int32 and Float64. See ce_expr.y.
238  // Expanded to work for any numeric type so it can be used for more than
239  // just arguments.
240  switch (a->var()->type()) {
241  case dods_byte_c:
242  return extract_double_array_helper<dods_byte>(a);
243  case dods_uint16_c:
244  return extract_double_array_helper<dods_uint16>(a);
245  case dods_int16_c:
246  return extract_double_array_helper<dods_int16>(a);
247  case dods_uint32_c:
248  return extract_double_array_helper<dods_uint32>(a);
249  case dods_int32_c:
250  return extract_double_array_helper<dods_int32>(a);
251  case dods_float32_c:
252  return extract_double_array_helper<dods_float32>(a);
253  case dods_float64_c:
254  return extract_double_array_helper<dods_float64>(a);
255  default:
256  throw InternalErr(__FILE__, __LINE__,
257  "The argument list built by the CE parser contained an unsupported numeric type.");
258  }
259 }
260 
269 {
270  // Simple types are Byte, ..., Float64, String and Url.
271  if (!arg->is_simple_type() || arg->type() == dods_str_c || arg->type()
272  == dods_url_c)
273  throw Error(malformed_expr,
274  "The function requires a DAP numeric-type argument.");
275 
276  if (!arg->read_p())
277  throw InternalErr(__FILE__, __LINE__,
278  "The CE Evaluator built an argument list where some constants held no values.");
279 
280  // The types of arguments that the CE Parser will build for numeric
281  // constants are limited to Uint32, Int32 and Float64. See ce_expr.y.
282  // Expanded to work for any numeric type so it can be used for more than
283  // just arguments.
284  switch (arg->type()) {
285  case dods_byte_c:
286  return (double)(static_cast<Byte*>(arg)->value());
287  case dods_uint16_c:
288  return (double)(static_cast<UInt16*>(arg)->value());
289  case dods_int16_c:
290  return (double)(static_cast<Int16*>(arg)->value());
291  case dods_uint32_c:
292  return (double)(static_cast<UInt32*>(arg)->value());
293  case dods_int32_c:
294  return (double)(static_cast<Int32*>(arg)->value());
295  case dods_float32_c:
296  return (double)(static_cast<Float32*>(arg)->value());
297  case dods_float64_c:
298  return static_cast<Float64*>(arg)->value();
299  default:
300  throw InternalErr(__FILE__, __LINE__,
301  "The argument list built by the CE parser contained an unsupported numeric type.");
302  }
303 }
304 
305 // Remove spaces from the start of a URL and from the start of any constraint
306 // expression it contains. 4/7/98 jhrg
307 
314 string
315 prune_spaces(const string &name)
316 {
317  // If the URL does not even have white space return.
318  if (name.find_first_of(' ') == name.npos)
319  return name;
320  else {
321  // Strip leading spaces from http://...
322  unsigned int i = name.find_first_not_of(' ');
323  string tmp_name = name.substr(i);
324 
325  // Strip leading spaces from constraint part (following `?').
326  unsigned int j = tmp_name.find('?') + 1;
327  i = tmp_name.find_first_not_of(' ', j);
328  tmp_name.erase(j, i - j);
329 
330  return tmp_name;
331  }
332 }
333 
334 // Compare elements in a list of (BaseType *)s and return true if there are
335 // no duplicate elements, otherwise return false.
336 
337 bool
338 unique_names(vector<BaseType *> l, const string &var_name,
339  const string &type_name, string &msg)
340 {
341  // copy the identifier names to a vector
342  vector<string> names(l.size());
343 
344  int nelem = 0;
345  typedef std::vector<BaseType *>::const_iterator citer ;
346  for (citer i = l.begin(); i != l.end(); i++) {
347  assert(*i);
348  names[nelem++] = (*i)->name();
349  DBG(cerr << "NAMES[" << nelem - 1 << "]=" << names[nelem-1] << endl);
350  }
351 
352  // sort the array of names
353  sort(names.begin(), names.end());
354 
355  // sort the array of names
356  sort(names.begin(), names.end());
357 
358  // look for any instance of consecutive names that are ==
359  for (int j = 1; j < nelem; ++j) {
360  if (names[j-1] == names[j]) {
361  ostringstream oss;
362  oss << "The variable `" << names[j]
363  << "' is used more than once in " << type_name << " `"
364  << var_name << "'";
365  msg = oss.str();
366 
367  return false;
368  }
369  }
370 
371  return true;
372 }
373 
374 const char *
376 {
377  return LIBDAP_ROOT;
378 }
379 
384 extern "C" const char *
386 {
387  return PACKAGE_VERSION;
388 }
389 
390 extern "C"
391  const char *
393 {
394  return PACKAGE_NAME;
395 }
396 
402 string
404 {
405  time_t TimBin;
406 
407  if (time(&TimBin) == (time_t) - 1)
408  return string("time() error");
409  else {
410 #if 0
411  string TimStr = ctime(&TimBin);
412 #endif
413  char *ctime_value = ctime(&TimBin);
414  if (ctime_value) {
415  string TimStr = ctime_value;
416  return TimStr.substr(0, TimStr.size() - 2); // remove the \n
417  }
418  else
419  return "Unknown";
420  }
421 }
422 
427 void
428 downcase(string &s)
429 {
430  for (unsigned int i = 0; i < s.length(); i++)
431  s[i] = tolower(s[i]);
432 }
433 
439 bool
440 is_quoted(const string &s)
441 {
442  return (!s.empty() && s[0] == '\"' && s[s.length()-1] == '\"');
443 }
444 
451 string
452 remove_quotes(const string &s)
453 {
454  if (is_quoted(s))
455  return s.substr(1, s.length() - 2);
456  else
457  return s;
458 }
459 
461 Type get_type(const char *name)
462 {
463  if (strcmp(name, "Byte") == 0)
464  return dods_byte_c;
465 
466  if (strcmp(name, "Int8") == 0)
467  return dods_int8_c;
468 
469  if (strcmp(name, "UInt8") == 0)
470  return dods_uint8_c;
471 
472  if (strcmp(name, "Int16") == 0)
473  return dods_int16_c;
474 
475  if (strcmp(name, "UInt16") == 0)
476  return dods_uint16_c;
477 
478  if (strcmp(name, "Int32") == 0)
479  return dods_int32_c;
480 
481  if (strcmp(name, "UInt32") == 0)
482  return dods_uint32_c;
483 
484  if (strcmp(name, "Int64") == 0)
485  return dods_int64_c;
486 
487  if (strcmp(name, "UInt64") == 0)
488  return dods_uint64_c;
489 
490  if (strcmp(name, "Float32") == 0)
491  return dods_float32_c;
492 
493  if (strcmp(name, "Float64") == 0)
494  return dods_float64_c;
495 
496  if (strcmp(name, "String") == 0)
497  return dods_str_c;
498 
499  if (strcmp(name, "URL") == 0)
500  return dods_url4_c;
501 
502  if (strcmp(name, "Url") == 0)
503  return dods_url_c;
504 
505  if (strcmp(name, "Array") == 0)
506  return dods_array_c;
507 
508  if (strcmp(name, "Structure") == 0)
509  return dods_structure_c;
510 
511  if (strcmp(name, "Sequence") == 0)
512  return dods_sequence_c;
513 
514  if (strcmp(name, "Grid") == 0)
515  return dods_grid_c;
516 
517  return dods_null_c;
518 }
519 
521 string
523 {
524  switch (t) {
525  case dods_null_c:
526  return string("Null");
527  case dods_byte_c:
528  return string("Byte");
529  case dods_int16_c:
530  return string("Int16");
531  case dods_uint16_c:
532  return string("UInt16");
533  case dods_int32_c:
534  return string("Int32");
535  case dods_uint32_c:
536  return string("UInt32");
537  case dods_float32_c:
538  return string("Float32");
539  case dods_float64_c:
540  return string("Float64");
541  case dods_str_c:
542  return string("String");
543  case dods_url_c:
544  return string("Url");
545  case dods_array_c:
546  return string("Array");
547  case dods_structure_c:
548  return string("Structure");
549  case dods_sequence_c:
550  return string("Sequence");
551  case dods_grid_c:
552  return string("Grid");
553 
554  case dods_int8_c:
555  return string("Int8");
556  case dods_uint8_c:
557  return string("UInt8");
558  case dods_int64_c:
559  return string("Int64");
560  case dods_uint64_c:
561  return string("UInt64");
562  case dods_url4_c:
563  return string("URL");
564  case dods_group_c:
565  return string("Group");
566  case dods_enum_c:
567  return string("Enum");
568 
569  default:
570  throw InternalErr(__FILE__, __LINE__, "Unknown type.");
571  }
572 }
573 
579 bool
581 {
582  switch (t) {
583 
584  case dods_byte_c:
585 
586  case dods_int8_c:
587  case dods_uint8_c:
588 
589  case dods_int16_c:
590  case dods_uint16_c:
591  case dods_int32_c:
592  case dods_uint32_c:
593 
594  case dods_int64_c:
595  case dods_uint64_c:
596 
597  case dods_float32_c:
598  case dods_float64_c:
599  case dods_str_c:
600  case dods_url_c:
601 
602  case dods_url4_c:
603  case dods_enum_c:
604  return true;
605 
606  case dods_null_c:
607  case dods_array_c:
608  case dods_structure_c:
609  case dods_sequence_c:
610  case dods_grid_c:
611  case dods_group_c:
612  return false;
613  }
614 
615  return false;
616 }
617 
621 bool
623 {
624  switch (t) {
625  case dods_null_c:
626  case dods_byte_c:
627 
628  case dods_int8_c:
629  case dods_uint8_c:
630 
631  case dods_int16_c:
632  case dods_uint16_c:
633 
634  case dods_int32_c:
635  case dods_uint32_c:
636 
637  case dods_int64_c:
638  case dods_uint64_c:
639 
640  case dods_float32_c:
641  case dods_float64_c:
642 
643  case dods_str_c:
644  case dods_url_c:
645 
646  case dods_url4_c:
647  case dods_enum_c:
648  return false;
649 
650  case dods_array_c:
651  return true;
652 
653  case dods_structure_c:
654  case dods_sequence_c:
655  case dods_grid_c:
656  case dods_group_c:
657  return false;
658  }
659 
660  return false;
661 }
662 
667 bool
669 {
670  switch (t) {
671  case dods_null_c:
672  case dods_byte_c:
673 
674  case dods_int8_c:
675  case dods_uint8_c:
676 
677  case dods_int16_c:
678  case dods_uint16_c:
679  case dods_int32_c:
680  case dods_uint32_c:
681 
682  case dods_int64_c:
683  case dods_uint64_c:
684 
685  case dods_float32_c:
686  case dods_float64_c:
687  case dods_str_c:
688  case dods_url_c:
689 
690  case dods_url4_c:
691  case dods_enum_c:
692 
693  case dods_array_c:
694  return false;
695 
696  case dods_structure_c:
697  case dods_sequence_c:
698  case dods_grid_c:
699  case dods_group_c:
700  return true;
701  }
702 
703  return false;
704 }
705 
711 {
712  switch (t) {
713  case dods_byte_c:
714  case dods_int8_c:
715  case dods_uint8_c:
716  case dods_int16_c:
717  case dods_uint16_c:
718  case dods_int32_c:
719  case dods_uint32_c:
720  case dods_int64_c:
721  case dods_uint64_c:
722  return true;
723  default:
724  return false;
725  }
726 }
727 
734 bool
735 dir_exists(const string &dir)
736 {
737  struct stat buf;
738 
739  return (stat(dir.c_str(), &buf) == 0) && (buf.st_mode & S_IFDIR);
740 }
741 
742 // Jose Garcia
743 void
744 append_long_to_string(long val, int base, string &str_val)
745 {
746  // The array digits contains 36 elements which are the
747  // posible valid digits for out bases in the range
748  // [2,36]
749  char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
750  // result of val / base
751  ldiv_t r;
752 
753  if (base > 36 || base < 2) {
754  // no conversion if wrong base
755  std::invalid_argument ex("The parameter base has an invalid value.");
756  throw ex;
757  }
758  if (val < 0)
759  str_val += '-';
760  r = ldiv(labs(val), base);
761 
762  // output digits of val/base first
763  if (r.quot > 0)
764  append_long_to_string(r.quot, base, str_val);
765 
766  // output last digit
767 
768  str_val += digits[(int)r.rem];
769 }
770 
771 // base defaults to 10
772 string
773 long_to_string(long val, int base)
774 {
775  string s;
776  append_long_to_string(val, base, s);
777  return s;
778 }
779 
780 // Jose Garcia
781 void append_double_to_string(const double &num, string &str)
782 {
783  // s having 100 characters should be enough for sprintf to do its job.
784  // I want to banish all instances of sprintf. 10/5/2001 jhrg
785  ostringstream oss;
786  oss.precision(9);
787  oss << num;
788  str += oss.str();
789 }
790 
791 string
792 double_to_string(const double &num)
793 {
794  string s;
795  append_double_to_string(num, s);
796  return s;
797 }
798 
799 // Given a pathname, return the file at the end of the path. This is used
800 // when reporting errors (maybe other times, too) to keep the server from
801 // revealing too much about its organization when sending error responses
802 // back to clients. 10/11/2000 jhrg
803 // MT-safe. 08/05/02 jhrg
804 
805 #ifdef WIN32
806 static const char path_sep[] =
807  {"\\"
808  };
809 #else
810 static const char path_sep[] =
811  {"/"
812  };
813 #endif
814 
823 string
824 path_to_filename(string path)
825 {
826  string::size_type pos = path.rfind(path_sep);
827 
828  return (pos == string::npos) ? path : path.substr(++pos);
829 }
830 
831 #define CHECK_BIT( tab, bit ) ( tab[ (bit)/8 ] & (1<<( (bit)%8 )) )
832 #define BITLISTSIZE 16 /* bytes used for [chars] in compiled expr */
833 
834 /*
835  * globchars() - build a bitlist to check for character group match
836  */
837 
838 static void globchars(const char *s, const char *e, char *b) {
839  int neg = 0;
840 
841  memset(b, '\0', BITLISTSIZE);
842 
843  if (*s == '^')
844  neg++, s++;
845 
846  while (s < e) {
847  int c;
848 
849  if (s + 2 < e && s[1] == '-') {
850  for (c = s[0]; c <= s[2]; c++)
851  b[c / 8] |= (1 << (c % 8));
852  s += 3;
853  }
854  else {
855  c = *s++;
856  b[c / 8] |= (1 << (c % 8));
857  }
858  }
859 
860  if (neg) {
861  int i;
862  for (i = 0; i < BITLISTSIZE; i++)
863  b[i] ^= 0377;
864  }
865 
866  /* Don't include \0 in either $[chars] or $[^chars] */
867 
868  b[0] &= 0376;
869 }
870 
887 int
888 glob(const char *c, const char *s)
889 {
890  if (!c || !s)
891  return 1;
892 
893  char bitlist[BITLISTSIZE];
894  int i = 0;
895  for (;;) {
896  ++i;
897  switch (*c++) {
898  case '\0':
899  return *s ? -1 : 0;
900 
901  case '?':
902  if (!*s++)
903  return i/*1*/;
904  break;
905 
906  case '[': {
907  /* scan for matching ] */
908 
909  const char *here = c;
910  do {
911  if (!*c++)
912  return i/*1*/;
913  } while (here == c || *c != ']');
914  c++;
915 
916  /* build character class bitlist */
917 
918  globchars(here, c, bitlist);
919 
920  if (!CHECK_BIT( bitlist, *(unsigned char *)s ))
921  return i/*1*/;
922  s++;
923  break;
924  }
925 
926  case '*': {
927  const char *here = s;
928 
929  while (*s)
930  s++;
931 
932  /* Try to match the rest of the pattern in a recursive */
933  /* call. If the match fails we'll back up chars, retrying. */
934 
935  while (s != here) {
936  int r;
937 
938  /* A fast path for the last token in a pattern */
939 
940  r = *c ? glob(c, s) : *s ? -1 : 0;
941 
942  if (!r)
943  return 0;
944  else if (r < 0)
945  return i/*1*/;
946 
947  --s;
948  }
949  break;
950  }
951 
952  case '\\':
953  /* Force literal match of next char. */
954 
955  if (!*c || *s++ != *c++)
956  return i/*1*/;
957  break;
958 
959  default:
960  if (*s++ != c[-1])
961  return i/*1*/;
962  break;
963  }
964  }
965 
966  return 1; // Should never get here; this quiets gcc's warning
967 }
968 
971 
977 bool
978 size_ok(unsigned int sz, unsigned int nelem)
979 {
980  return (sz > 0 && nelem < UINT_MAX / sz);
981 }
982 
999 bool
1000 pathname_ok(const string &path, bool strict)
1001 {
1002  if (path.length() > 255)
1003  return false;
1004 
1005  Regex name("[-0-9A-z_./]+");
1006  if (!strict)
1007  name = "[:print:]+";
1008 
1009  string::size_type len = path.length();
1010  int result = name.match(path.c_str(), len);
1011  // Protect against casting too big an uint to int
1012  // if LEN is bigger than the max int32, the second test can't work
1013  if (len > INT_MAX || result != static_cast<int>(len))
1014  return false;
1015 
1016  return true;
1017 }
1018 
1020 
1025 string
1027 {
1028  return (string)"OPeNDAP DAP/" + libdap_version() + ": compiled on " + __DATE__ + ":" + __TIME__ ;
1029 }
1030 
1031 } // namespace libdap
1032 
virtual bool read_p()
Has this variable been read?
Definition: BaseType.cc:579
void downcase(string &s)
Definition: util.cc:428
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:668
#define malformed_expr
Definition: Error.h:64
string prune_spaces(const string &name)
Definition: util.cc:315
virtual int length() const
Definition: Vector.cc:519
Holds an unsigned 16-bit integer.
Definition: UInt16.h:57
virtual void set_read_p(bool state)
Indicates that the data is ready to send.
Definition: Vector.cc:355
string extract_string_argument(BaseType *arg)
Definition: util.cc:96
bool dir_exists(const string &dir)
Definition: util.cc:735
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:978
bool is_vector_type(Type t)
Returns true if the instance is a vector (i.e., array) type variable.
Definition: util.cc:622
Type
Identifies the data type.
Definition: BaseType.h:137
Type type() const
Returns the type of the class instance.
Definition: BaseType.cc:282
Holds a 32-bit floating point value.
Definition: Float32.h:59
A class for software fault reporting.
Definition: InternalErr.h:64
virtual BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=0)
Definition: Vector.cc:380
Holds character string data.
Definition: Str.h:62
void set_array_using_double(Array *dest, double *src, int src_len)
Definition: util.cc:150
#define DBG(x)
Definition: debug.h:58
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:1000
#define PACKAGE_NAME
Definition: config.h:798
double * extract_double_array(Array *a)
Definition: util.cc:223
Holds a 16-bit signed integer value.
Definition: Int16.h:57
ObjectType get_type(const string &value)
Definition: mime_util.cc:308
string path_to_filename(string path)
Definition: util.cc:824
bool is_quoted(const string &s)
Definition: util.cc:440
bool is_simple_type(Type t)
Returns true if the instance is a numeric, string or URL type variable.
Definition: util.cc:580
string systime()
Definition: util.cc:403
const char * libdap_root()
Definition: util.cc:375
void append_long_to_string(long val, int base, string &str_val)
Definition: util.cc:744
double extract_double_value(BaseType *arg)
Definition: util.cc:268
string name() const
Returns the name of the class instance.
Definition: BaseType.cc:254
string long_to_string(long val, int base)
Definition: util.cc:773
#define CHECK_BIT(tab, bit)
Definition: util.cc:831
string dap_version()
Definition: util.cc:1026
string double_to_string(const double &num)
Definition: util.cc:792
string remove_quotes(const string &s)
Definition: util.cc:452
The basic data type for the DODS DAP types.
Definition: BaseType.h:199
#define LIBDAP_ROOT
Definition: config.h:764
Holds a 64-bit (double precision) floating point value.
Definition: Float64.h:60
Holds a single byte.
Definition: Byte.h:60
bool unique_names(vector< BaseType * > l, const string &var_name, const string &type_name, string &msg)
Definition: util.cc:338
virtual bool is_simple_type()
Returns true if the instance is a numeric, string or URL type variable.
Definition: BaseType.cc:358
#define PACKAGE_VERSION
Definition: config.h:810
A class for error processing.
Definition: Error.h:90
Holds a 32-bit unsigned integer.
Definition: UInt32.h:59
string type_name(Type t)
Returns the type of the class instance as a string.
Definition: util.cc:522
const char * libdap_version()
Definition: util.cc:385
A multidimensional array of identical data types.
Definition: Array.h:103
#define BITLISTSIZE
Definition: util.cc:832
int glob(const char *c, const char *s)
Definition: util.cc:888
bool is_integer_type(Type t)
Definition: util.cc:710
Holds a 32-bit signed integer.
Definition: Int32.h:64
void append_double_to_string(const double &num, string &str)
Definition: util.cc:781
const char * libdap_name()
Definition: util.cc:392