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