libdap  Updated for version 3.19.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
D4Enum.cc
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) 2013 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 #include "config.h"
27 
28 // #define DODS_DEBUG
29 
30 #include <cassert>
31 #include <sstream>
32 
33 #include <libxml/encoding.h>
34 
35 #include "Byte.h" // synonymous with UInt8 and Char
36 #include "Int8.h"
37 #include "Int16.h"
38 #include "UInt16.h"
39 #include "Int32.h"
40 #include "UInt32.h"
41 #include "Int64.h"
42 #include "UInt64.h"
43 
44 #include "D4Group.h"
45 #include "D4Enum.h"
46 #include "D4EnumDefs.h"
47 #include "D4Attributes.h"
48 
49 #include "Float32.h"
50 #include "Float64.h"
51 
52 #include "D4StreamMarshaller.h"
53 #include "D4StreamUnMarshaller.h"
54 
55 #include "Operators.h"
56 #include "InternalErr.h"
57 #include "dods-datatypes.h"
58 #include "dods-limits.h"
59 #include "util.h"
60 #include "debug.h"
61 
62 using std::cerr;
63 using std::endl;
64 
65 namespace libdap {
66 
67 // Private
68 void D4Enum::m_duplicate(const D4Enum &src)
69 {
70  d_buf = src.d_buf;
71  d_element_type = src.d_element_type;
72  d_enum_def = src.d_enum_def;
73 #if 0
74  // The enum_def is a weak pointer managed by D4Group. We just copy it
75  // and do not delete it. jhrg 1019/15
76  d_enum_def = src.d_enum_def == 0 ? 0 : new D4EnumDef(*(src.d_enum_def));
77 #endif
78  d_is_signed = src.d_is_signed;
79 }
80 
81 
90 std::vector<BaseType *> *
92  BaseType *my_pretty_pony;
93 
94  DBG(cerr << __func__ << "() - BEGIN" << endl;);
95 
96 
97  switch (d_element_type) {
98  case dods_byte_c:
99  case dods_int8_c:
100  case dods_uint8_c:
101  {
102  Byte *var = new Byte(name());
103  dods_byte val;
104  this->value(&val);
105  var->set_value(val);
106  my_pretty_pony = var;
107  break;
108  }
109  case dods_uint16_c:
110  {
111  UInt16 *var = new UInt16(name());
112  dods_uint16 val;
113  this->value(&val);
114  var->set_value(val);
115  my_pretty_pony = var;
116  break;
117  }
118  case dods_uint32_c:
119  {
120  UInt32 *var = new UInt32(name());
121  dods_uint32 val;
122  this->value(&val);
123  var->set_value(val);
124  my_pretty_pony = var;
125  break;
126  }
127  case dods_uint64_c:
128  {
129  UInt64 *var = new UInt64(name());
130  dods_uint64 val;
131  this->value(&val);
132  var->set_value(val);
133  my_pretty_pony = var;
134  break;
135  }
136  case dods_int16_c:
137  {
138  Int16 *var = new Int16(name());
139  dods_int16 val;
140  this->value(&val);
141  var->set_value(val);
142  my_pretty_pony = var;
143  break;
144  }
145  case dods_int32_c:
146  {
147  Int32 *var = new Int32(name());
148  dods_int32 val;
149  this->value(&val);
150  var->set_value(val);
151  my_pretty_pony = var;
152  break;
153  }
154  case dods_int64_c:
155  {
156  Int64 *var = new Int64(name());
157  dods_int64 val;
158  this->value(&val);
159  var->set_value(val);
160  my_pretty_pony = var;
161  break;
162  }
163  default:
164  {
165  ostringstream oss;
166  oss << __func__ << "() - ERROR! Unknown D4Enum type:"<< d_element_type << " name: " << name() << endl;
167  throw InternalErr(__FILE__,__LINE__,oss.str());
168  break;
169  }
170  }
171 
172  DBG( cerr << __func__ << "() - Processing Enum type:"<<
173  my_pretty_pony->type_name() << " name: " << my_pretty_pony->name() << endl;);
177  AttrTable d2_attrs = *(this->attributes()->get_AttrTable(name()));
178  my_pretty_pony->set_attr_table(d2_attrs);
179 
180  // cerr << "D4Enum::transform_to_dap2() - my_pretty_pony attrs: "<< endl;
181  // my_pretty_pony->get_attr_table().print(cerr);
182 
187  long long my_value;
188  this->value(&my_value);
189  DBG(cerr << __func__ << "() - value: "<< my_value << endl;);
190 
191  string my_label="";
192  AttrTable *enum_def = new AttrTable();
193  enum_def->set_name("d4:enum_def");
194 
195  D4EnumDef::D4EnumValueIter dIter = d_enum_def->value_begin();
196  D4EnumDef::D4EnumValueIter dEnd = d_enum_def->value_end();
197  while( dIter!=dEnd){
198  long long a_value = (*dIter).value;
199  string a_label = (*dIter).label;
200  ostringstream oss;
201  oss << a_value;
202  DBG(cerr << __func__ << "() - a_value: "<< a_value << endl;);
203  enum_def->append_attr(a_label,my_pretty_pony->type_name(),oss.str());
204  if(a_value == my_value){
205  my_label = (*dIter).label;
206  }
207  dIter++;
208  }
209  if(!my_label.empty())
210  my_pretty_pony->get_attr_table().append_attr("d4:enum_label","String",my_label);
211  my_pretty_pony->get_attr_table().append_container(enum_def,enum_def->get_name());
212 
213  vector<BaseType *> *result = new vector<BaseType *>();
214  result->push_back(my_pretty_pony);
215  DBG(cerr << __func__ << "() - END" << endl;);
216  return result;
217 }
218 
219 void D4Enum::m_check_value(int64_t v) const
220 {
221  switch (d_element_type) {
222  case dods_byte_c:
223  case dods_uint8_c:
224  if ((uint64_t)v > DODS_UCHAR_MAX || v < 0) {
225  ostringstream oss;
226  oss << "The value " << v << " will not fit in an unsigned byte. (" << __func__ << ")";
227  throw Error(oss.str());
228  }
229  break;
230  case dods_uint16_c:
231  if ((uint64_t)v > DODS_USHRT_MAX || v < 0) {
232  ostringstream oss;
233  oss << "The value " << v << " will not fit in an unsigned 16-bit integer. (" << __func__ << ")";
234  throw Error(oss.str());
235  }
236  break;
237  case dods_uint32_c:
238  if ((uint64_t)v > DODS_UINT_MAX || v < 0) {
239  ostringstream oss;
240  oss << "The value " << v << " will not fit in an unsigned 32-bit integer. (" << __func__ << ")";
241  throw Error(oss.str());
242  }
243  break;
244  case dods_uint64_c:
245  // If 'v' can never be bigger than ULLONG_MAX
246  break;
247 
248  case dods_int8_c:
249  if (v > DODS_SCHAR_MAX || v < DODS_SCHAR_MIN) {
250  ostringstream oss;
251  oss << "The value " << v << " will not fit in an unsigned byte. (" << __func__ << ")";
252  throw Error(oss.str());
253  }
254 
255  break;
256  case dods_int16_c:
257  if (v > DODS_SHRT_MAX || v < DODS_SHRT_MIN) {
258  ostringstream oss;
259  oss << "The value " << v << " will not fit in an unsigned byte. (" << __func__ << ")";
260  throw Error(oss.str());
261  }
262  break;
263  case dods_int32_c:
264  if (v > DODS_INT_MAX || v < DODS_INT_MIN) {
265  ostringstream oss;
266  oss << "The value " << v << " will not fit in an unsigned byte. (" << __func__ << ")";
267  throw Error(oss.str());
268  }
269  break;
270  case dods_int64_c:
271  // There's no value 'v' can have that won't fit into a 64-bit int.
272  break;
273  default:
274  assert(!"illegal type for D4Enum");
275  }
276 }
277 
278 D4Enum::D4Enum(const string &name, const string &enum_type) :
279  BaseType(name, dods_enum_c, true /*is_dap4*/), d_buf(0), d_element_type(dods_null_c), d_enum_def(0)
280 {
281  d_element_type = get_type(enum_type.c_str());
282 
283  if (!is_integer_type(d_element_type)) d_element_type = dods_uint64_c;
284  set_is_signed(d_element_type);
285 }
286 
287 D4Enum::D4Enum(const string &name, Type type) :
288  BaseType(name, dods_enum_c, true /*is_dap4*/), d_buf(0), d_element_type(type), d_enum_def(0)
289 {
290  if (!is_integer_type(d_element_type)) d_element_type = dods_uint64_c;
291  set_is_signed(d_element_type);
292 }
293 
294 D4Enum::D4Enum(const string &name, const string &dataset, Type type) :
295  BaseType(name, dataset, dods_enum_c, true /*is_dap4*/), d_buf(0), d_element_type(type), d_enum_def(0)
296 {
297  if (!is_integer_type(d_element_type)) d_element_type = dods_uint64_c;
298  set_is_signed(d_element_type);
299 }
300 
301 // Explicit instantiation of the template member function 'value(T *)'.
302 // This is required in order to have the library contain these member
303 // functions when its own code does not use them. Normally, C++ instantiates
304 // templates when they are used, and this forces that process so the
305 // library file contains the various versions of the member function.
306 template void D4Enum::value<dods_byte>(dods_byte *v) const;
307 template void D4Enum::value<dods_int16>(dods_int16 *v) const;
308 template void D4Enum::value<dods_uint16>(dods_uint16 *v) const;
309 template void D4Enum::value<dods_int32>(dods_int32 *v) const;
310 template void D4Enum::value<dods_uint32>(dods_uint32 *v) const;
311 template void D4Enum::value<dods_int64>(dods_int64 *v) const;
312 template void D4Enum::value<dods_uint64>(dods_uint64 *v) const;
313 
314 template void D4Enum::set_value<dods_byte>(dods_byte v, bool check_value);
315 template void D4Enum::set_value<dods_int16>(dods_int16 v, bool check_value);
316 template void D4Enum::set_value<dods_uint16>(dods_uint16 v, bool check_value);
317 template void D4Enum::set_value<dods_int32>(dods_int32 v, bool check_value);
318 template void D4Enum::set_value<dods_uint32>(dods_uint32 v, bool check_value);
319 template void D4Enum::set_value<dods_int64>(dods_int64 v, bool check_value);
320 template void D4Enum::set_value<dods_uint64>(dods_uint64 v, bool check_value);
321 
322 void
323 D4Enum::set_enumeration(D4EnumDef *enum_def) {
324  d_enum_def = enum_def;
325  d_element_type = enum_def->type();
326 }
327 
328 void
330 {
331  DBG(cerr << __func__ << ": element type: " << ::libdap::type_name(d_element_type) << endl);
332 
333  switch (d_element_type) {
334  case dods_byte_c:
335  case dods_uint8_c:
336  case dods_int8_c: {
337  dods_byte v = static_cast<dods_byte>(d_buf);
338  checksum.AddData(reinterpret_cast<uint8_t*>(&v), sizeof(uint8_t));
339  break;
340  }
341  case dods_uint16_c:
342  case dods_int16_c: {
343  dods_int16 v = static_cast<dods_int16>(d_buf);
344  checksum.AddData(reinterpret_cast<uint8_t*>(&v), sizeof(uint16_t));
345  break;
346  }
347  case dods_uint32_c:
348  case dods_int32_c: {
349  dods_int32 v = static_cast<dods_int32>(d_buf);
350  checksum.AddData(reinterpret_cast<uint8_t*>(&v), sizeof(uint32_t));
351  break;
352  }
353  case dods_uint64_c:
354  case dods_int64_c:
355  checksum.AddData(reinterpret_cast<uint8_t*>(&d_buf), sizeof(uint64_t));
356  break;
357 
358  default:
359  assert(!"illegal type for D4Enum");
360  }
361 }
362 
363 void
364 D4Enum::set_is_signed(Type t)
365 {
366  switch (t) {
367  case dods_byte_c:
368  case dods_uint8_c:
369  case dods_uint16_c:
370  case dods_uint32_c:
371  case dods_uint64_c:
372  d_is_signed = false;
373  break;
374 
375  case dods_int8_c:
376  case dods_int16_c:
377  case dods_int32_c:
378  case dods_int64_c:
379  d_is_signed = true;
380  break;
381 
382  default:
383  assert(!"illegal type for D4Enum");
384  throw InternalErr(__FILE__, __LINE__, "Illegal type");
385  }
386 }
387 
388 
401 void
402 D4Enum::serialize(D4StreamMarshaller &m, DMR &, /*ConstraintEvaluator &,*/ bool)
403 {
404  if (!read_p())
405  read(); // read() throws Error
406 
407  switch (d_element_type) {
408  case dods_byte_c:
409  case dods_uint8_c:
410  m.put_byte(d_buf);
411  break;
412  case dods_uint16_c:
413  m.put_uint16(d_buf);
414  break;
415  case dods_uint32_c:
416  m.put_uint32(d_buf);
417  break;
418  case dods_uint64_c:
419  m.put_uint64(d_buf);
420  break;
421 
422  case dods_int8_c:
423  m.put_int8(d_buf);
424  break;
425  case dods_int16_c:
426  m.put_int16(d_buf);
427  break;
428  case dods_int32_c:
429  m.put_int32(d_buf);
430  break;
431  case dods_int64_c:
432  m.put_int64(d_buf);
433  break;
434  default:
435  assert(!"illegal type for D4Enum");
436  }
437 }
438 
439 void
441 {
442  switch (d_element_type) {
443  case dods_byte_c:
444  case dods_uint8_c: {
445  dods_byte v;
446  um.get_byte(v);
447  d_buf = v;
448  break;
449  }
450  case dods_uint16_c: {
451  dods_uint16 v;
452  um.get_uint16(v);
453  d_buf = v;
454  break;
455  }
456  case dods_uint32_c: {
457  dods_uint32 v;
458  um.get_uint32(v);
459  d_buf = v;
460  break;
461  }
462  case dods_uint64_c: {
463  dods_uint64 v;
464  um.get_uint64(v);
465  d_buf = v;
466  break;
467  }
468 
469  case dods_int8_c: {
470  dods_int8 v;
471  um.get_int8(v);
472  d_buf = v;
473  break;
474  }
475  case dods_int16_c: {
476  dods_int16 v;
477  um.get_int16(v);
478  d_buf = v;
479  break;
480  }
481  case dods_int32_c: {
482  dods_int32 v;
483  um.get_int32(v);
484  d_buf = v;
485  break;
486  }
487  case dods_int64_c: {
488  dods_int64 v;
489  um.get_int64(v);
490  d_buf = v;
491  break;
492  }
493  default:
494  assert(!"illegal type for D4Enum");
495  }
496 }
497 
498 unsigned int D4Enum::val2buf(void *val, bool)
499 {
500  if (!val)
501  throw InternalErr("The incoming pointer does not contain any data.");
502 
503  switch (d_element_type) {
504  case dods_byte_c:
505  case dods_uint8_c:
506  d_buf = *(dods_byte*)val;
507  break;
508  case dods_uint16_c:
509  d_buf = *(dods_uint16*)val;
510  break;
511  case dods_uint32_c:
512  d_buf = *(dods_uint32*)val;
513  break;
514  case dods_uint64_c:
515  d_buf = *(dods_uint64*)val;
516  break;
517 
518  case dods_int8_c:
519  d_buf = *(dods_int8*)val;
520  break;
521  case dods_int16_c:
522  d_buf = *(dods_int16*)val;
523  break;
524  case dods_int32_c:
525  d_buf = *(dods_int32*)val;
526  break;
527  case dods_int64_c:
528  d_buf = *(dods_int64*)val;
529  break;
530  default:
531  assert(!"illegal type for D4Enum");
532  }
533 
534  return width();
535 }
536 
537 unsigned int D4Enum::buf2val(void **val)
538 {
539  if (!val)
540  throw InternalErr("NULL pointer");
541 
542  switch (d_element_type) {
543  case dods_byte_c:
544  case dods_uint8_c:
545  if (!*val) *val = new dods_byte;
546  *(dods_byte *) * val = d_buf;
547  break;
548  case dods_uint16_c:
549  if (!*val) *val = new dods_uint16;
550  *(dods_uint16 *) * val = d_buf;
551  break;
552  case dods_uint32_c:
553  if (!*val) *val = new dods_uint32;
554  *(dods_uint32 *) * val = d_buf;
555  break;
556  case dods_uint64_c:
557  if (!*val) *val = new dods_uint64;
558  *(dods_uint64 *) * val = d_buf;
559  break;
560 
561  case dods_int8_c:
562  if (!*val) *val = new dods_int8;
563  *(dods_int8*) * val = d_buf;
564  break;
565  case dods_int16_c:
566  if (!*val) *val = new dods_int16;
567  *(dods_int16 *) * val = d_buf;
568  break;
569  case dods_int32_c:
570  if (!*val) *val = new dods_int32;
571  *(dods_int32 *) * val = d_buf;
572  break;
573  case dods_int64_c:
574  if (!*val) *val = new dods_int64;
575  *(dods_int64 *) * val = d_buf;
576  break;
577  default:
578  assert(!"illegal type for D4Enum");
579  }
580 
581  return width();
582 }
583 
584 void D4Enum::print_val(ostream &out, string space, bool print_decl_p)
585 {
586  if (print_decl_p) {
587  print_decl(out, space, false);
588  out << " = ";
589  }
590 
591  DBG(cerr << "Enum union value: " << hex << d_buf << dec << endl);
592 
593  if (is_signed()) {
594  int64_t v;
595  value(&v);
596  out << v;
597  }
598  else {
599  uint64_t v;
600  value(&v);
601  out << v;
602  }
603 
604  if (print_decl_p)
605  out << ";" << endl;
606 }
607 
614 void
615 D4Enum::print_xml_writer(XMLWriter &xml, bool constrained)
616 {
617  if (constrained && !send_p())
618  return;
619 
620  if (xmlTextWriterStartElement(xml.get_writer(), (const xmlChar*)"Enum") < 0)
621  throw InternalErr(__FILE__, __LINE__, "Could not write Enum element");
622 
623  if (!name().empty())
624  if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "name", (const xmlChar*)name().c_str()) < 0)
625  throw InternalErr(__FILE__, __LINE__, "Could not write attribute for name");
626 
627 
628  string path = d_enum_def->name();
629  // Not every D4EnumDef is a member of an instance of D4EnumDefs - the D4EnumDefs instance
630  // holds a reference to the D4Group that holds the Enum definitions.
631  // TODO Should this be changed - so the EnumDef holds a reference to its parent Group?
632  if (d_enum_def->parent()) {
633  // print the FQN for the enum def; D4Group::FQN() includes the trailing '/'
634  path = static_cast<D4Group*>(d_enum_def->parent()->parent())->FQN() + path;
635  }
636  if (xmlTextWriterWriteAttribute(xml.get_writer(), (const xmlChar*) "enum", (const xmlChar*)path.c_str()) < 0)
637  throw InternalErr(__FILE__, __LINE__, "Could not write attribute for enum");
638 
639  attributes()->print_dap4(xml);
640 
641  if (get_attr_table().get_size() > 0)
643 
644  if (xmlTextWriterEndElement(xml.get_writer()) < 0)
645  throw InternalErr(__FILE__, __LINE__, "Could not end Enum element");
646 }
647 
648 
649 bool
651 {
652  // Get the arg's value.
653  if (!read_p() && !read())
654  throw InternalErr(__FILE__, __LINE__, "This value not read!");
655 
656  // Get the second arg's value.
657  if (!b->read_p() && !b->read())
658  throw InternalErr(__FILE__, __LINE__, "This value not read!");
659 
660  switch (b->type()) {
661  case dods_int8_c:
662  return Cmp<dods_int64, dods_int8>(op, d_buf, static_cast<Int8*>(b)->value());
663  case dods_byte_c:
664  return SUCmp<dods_int64, dods_byte>(op, d_buf, static_cast<Byte*>(b)->value());
665  case dods_int16_c:
666  return Cmp<dods_int64, dods_int16>(op, d_buf, static_cast<Int16*>(b)->value());
667  case dods_uint16_c:
668  return SUCmp<dods_int64, dods_uint16>(op, d_buf, static_cast<UInt16*>(b)->value());
669  case dods_int32_c:
670  return Cmp<dods_int64, dods_int32>(op, d_buf, static_cast<Int32*>(b)->value());
671  case dods_uint32_c:
672  return SUCmp<dods_int64, dods_uint32>(op, d_buf, static_cast<UInt32*>(b)->value());
673 #if 0
674  // FIXME
675  case dods_int64_c:
676  return Cmp<dods_int64, dods_int64>(op, d_buf, static_cast<D4Enum*>(b)->value());
677  case dods_uint64_c:
678  return SUCmp<dods_int64, dods_uint64>(op, d_buf, static_cast<D4Enum*>(b)->value());
679 #endif
680  case dods_float32_c:
681  return Cmp<dods_int64, dods_float32>(op, d_buf, static_cast<Float32*>(b)->value());
682  case dods_float64_c:
683  return Cmp<dods_int64, dods_float64>(op, d_buf, static_cast<Float64*>(b)->value());
684  default:
685  return false;
686  }
687 
688  return false;
689 }
690 
699 void
700 D4Enum::dump(ostream &strm) const
701 {
702  strm << DapIndent::LMarg << "D4Enum::dump - (" << (void *) this << ")" << endl;
703  DapIndent::Indent();
704  BaseType::dump(strm);
705  strm << DapIndent::LMarg << "value: " << d_buf << endl;
706  DapIndent::UnIndent();
707 }
708 
709 } // namespace libdap
710 
libdap::BaseType::set_attr_table
virtual void set_attr_table(const AttrTable &at)
Definition: BaseType.cc:581
libdap::UInt64
Holds a 64-bit unsigned integer.
Definition: UInt64.h:49
libdap::D4Enum
Holds a DAP4 enumeration.
Definition: D4Enum.h:61
libdap::D4Enum::buf2val
unsigned int buf2val(void **)
Reads the class data.
Definition: D4Enum.cc:537
libdap::D4Enum::value
void value(T *v) const
Get the value of an Enum Get the value of this instance. The caller is responsible for using a type T...
Definition: D4Enum.h:140
libdap::is_integer_type
bool is_integer_type(Type t)
Definition: util.cc:906
libdap::XMLWriter
Definition: XMLWriter.h:39
libdap::BaseType::name
virtual string name() const
Returns the name of the class instance.
Definition: BaseType.cc:311
libdap::BaseType::print_decl
virtual void print_decl(FILE *out, string space=" ", bool print_semi=true, bool constraint_info=false, bool constrained=false)
Print an ASCII representation of the variable structure.
Definition: BaseType.cc:994
libdap::Error
A class for error processing.
Definition: Error.h:90
libdap::InternalErr
A class for software fault reporting.
Definition: InternalErr.h:64
libdap::AttrTable::set_name
virtual void set_name(const string &n)
Set the name of this attribute table.
Definition: AttrTable.cc:244
libdap::Int16
Holds a 16-bit signed integer value.
Definition: Int16.h:59
libdap::D4Group
Definition: D4Group.h:43
libdap::UInt32
Holds a 32-bit unsigned integer.
Definition: UInt32.h:59
libdap::BaseType::attributes
virtual D4Attributes * attributes()
Definition: BaseType.cc:590
libdap::Byte
Holds a single byte.
Definition: Byte.h:60
libdap::D4Enum::deserialize
virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr)
Definition: D4Enum.cc:440
libdap::Type
Type
Identifies the data type.
Definition: Type.h:94
libdap::D4Attributes::get_AttrTable
AttrTable * get_AttrTable(const std::string name)
copy attributes from DAP4 to DAP2
Definition: D4Attributes.cc:343
libdap
Definition: AlarmHandler.h:35
libdap::D4Enum::print_xml_writer
virtual void print_xml_writer(XMLWriter &xml, bool constrained)
Definition: D4Enum.cc:615
libdap::Int8
Holds an 8-bit signed integer value.
Definition: Int8.h:42
libdap::Float32
Holds a 32-bit floating point value.
Definition: Float32.h:61
libdap::BaseType::send_p
virtual bool send_p()
Should this variable be sent?
Definition: BaseType.cc:545
libdap::D4Enum::ops
virtual bool ops(BaseType *b, int op)
Evaluate relational operators.
Definition: D4Enum.cc:650
libdap::D4Enum::width
virtual unsigned int width(bool=false) const
Return the number of bytes in an instance of an Enum. This returns the number of bytes an instance of...
Definition: D4Enum.h:175
libdap::D4Enum::compute_checksum
virtual void compute_checksum(Crc32 &checksum)
include the data for this variable in the checksum DAP4 includes a checksum with every data response....
Definition: D4Enum.cc:329
libdap::AttrTable::print_xml_writer
void print_xml_writer(XMLWriter &xml)
Definition: AttrTable.cc:1424
libdap::BaseType::dump
virtual void dump(ostream &strm) const
dumps information about this object
Definition: BaseType.cc:282
libdap::D4StreamUnMarshaller
Read data from the stream made by D4StreamMarshaller.
Definition: D4StreamUnMarshaller.h:65
libdap::D4Enum::serialize
virtual void serialize(D4StreamMarshaller &m, DMR &dmr, bool filter=false)
Serialize a D4Enum Use the (integer) data type associated with an Enumeration definition to serialize...
Definition: D4Enum.cc:402
libdap::BaseType::read_p
virtual bool read_p()
Has this variable been read?
Definition: BaseType.cc:471
libdap::AttrTable
Contains the attributes for a dataset.
Definition: AttrTable.h:142
libdap::UInt16
Holds an unsigned 16-bit integer.
Definition: UInt16.h:57
libdap::BaseType::type
virtual Type type() const
Returns the type of the class instance.
Definition: BaseType.cc:356
libdap::get_type
ObjectType get_type(const string &value)
Definition: mime_util.cc:326
libdap::D4Enum::dump
virtual void dump(ostream &strm) const
dumps information about this object
Definition: D4Enum.cc:700
Crc32::AddData
void AddData(const uint8_t *pData, const uint32_t length)
Definition: crc.h:98
libdap::DMR
Definition: DMR.h:55
libdap::BaseType::read
virtual bool read()
Read data into a local buffer.
Definition: BaseType.cc:890
libdap::BaseType::FQN
virtual std::string FQN() const
Definition: BaseType.cc:323
libdap::Int32
Holds a 32-bit signed integer.
Definition: Int32.h:65
libdap::type_name
string type_name(Type t)
Definition: util.cc:760
libdap::BaseType::var
virtual BaseType * var(const string &name="", bool exact_match=true, btp_stack *s=0)
Returns a pointer to a member of a constructor class.
Definition: BaseType.cc:749
libdap::D4Enum::val2buf
unsigned int val2buf(void *, bool)
Loads class data.
Definition: D4Enum.cc:498
libdap::Int64
Holds a64-bit signed integer.
Definition: Int64.h:49
libdap::BaseType::get_attr_table
virtual AttrTable & get_attr_table()
Definition: BaseType.cc:573
libdap::BaseType
The basic data type for the DODS DAP types.
Definition: BaseType.h:117
libdap::AttrTable::append_container
virtual AttrTable * append_container(const string &name)
Add a container to the attribute table.
Definition: AttrTable.cc:409
Crc32
Definition: crc.h:76
libdap::D4Enum::transform_to_dap2
virtual std::vector< BaseType * > * transform_to_dap2(AttrTable *parent_attr_table)
DAP4 to DAP2 transform.
Definition: D4Enum.cc:91
libdap::Float64
Holds a 64-bit (double precision) floating point value.
Definition: Float64.h:60
libdap::D4Enum::print_val
virtual void print_val(ostream &out, string space="", bool print_decl_p=true)
Prints the value of the variable.
Definition: D4Enum.cc:584
libdap::AttrTable::get_name
virtual string get_name() const
Get the name of this attribute table.
Definition: AttrTable.cc:237
libdap::BaseType::type_name
virtual string type_name() const
Returns the type of the class instance as a string.
Definition: BaseType.cc:370
libdap::AttrTable::append_attr
virtual unsigned int append_attr(const string &name, const string &type, const string &value)
Add an attribute to the table.
Definition: AttrTable.cc:306
libdap::D4StreamMarshaller
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4's receiv...
Definition: D4StreamMarshaller.h:71