-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathByte.h
More file actions
151 lines (123 loc) · 4.73 KB
/
Byte.h
File metadata and controls
151 lines (123 loc) · 4.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// -*- 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_URI.
//
// Authors:
// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
// Interface for Byte type.
//
// jhrg 9/7/94
#ifndef _byte_h
#define _byte_h 1
#ifndef _dods_datatypes_h
#include "dods-datatypes.h"
#endif
#ifndef _basetype_h
#include "BaseType.h"
#endif
#ifndef constraint_evaluator_h
#include "ConstraintEvaluator.h"
#endif
namespace libdap {
/** This class is used to hold eight bits of information. No sign
information is implied in its value.
@brief Holds a single byte.
@see BaseType
*/
class Byte : public BaseType {
protected:
/// Stored scalar byte value.
dods_byte d_buf;
public:
Byte(const string &n);
Byte(const string &n, const string &d);
~Byte() override {}
/**
* @brief Copy-constructs a byte variable from another instance.
*
* The new instance copies the source value and metadata.
*
* @param copy_from Source instance to copy.
*/
Byte(const Byte ©_from);
/**
* @brief Assigns from another byte variable.
*
* Replaces this instance's value and metadata with those of `rhs`.
*
* @param rhs Source instance.
* @return This instance after assignment.
*/
Byte &operator=(const Byte &rhs);
unsigned int width(bool = false) const override { return sizeof(dods_byte); }
/**
* @brief Returns the storage width in bytes.
*
* @param constrained Ignored for scalar byte values.
* @return Number of bytes used by the byte value.
*/
int64_t width_ll(bool constrained = false) const override { return sizeof(dods_byte); }
BaseType *ptr_duplicate() override;
// DAP2
bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval) override;
bool deserialize(UnMarshaller &um, DDS *, bool) override;
// DAP4
void compute_checksum(Crc32 &checksum) override;
void serialize(D4StreamMarshaller &m, DMR &dmr, bool filter = false) override;
void deserialize(D4StreamUnMarshaller &um, DMR &dmr) override;
unsigned int val2buf(void *val, bool reuse = false) override;
unsigned int buf2val(void **val) override;
virtual bool set_value(const dods_byte value);
virtual dods_byte value() const;
/**
* @brief Writes this value using C stdio output.
*
* @param out Output file stream.
* @param space Indentation prefix.
* @param print_decl_p True to include declaration text.
* @param is_root_grp True when printing in the root group context.
*/
void print_val(FILE *out, string space = "", bool print_decl_p = true, bool is_root_grp = true) override;
/**
* @brief Writes this value using C++ stream output.
*
* @param out Output stream.
* @param space Indentation prefix.
* @param print_decl_p True to include declaration text.
* @param is_root_grp True when printing in the root group context.
*/
void print_val(ostream &out, string space = "", bool print_decl_p = true, bool is_root_grp = true) override;
bool ops(BaseType *b, int op) override;
bool d4_ops(BaseType *b, int op) override;
/**
* @brief Converts this DAP4 value into equivalent DAP2 value objects.
*
* @param parent_attr_table Destination attribute table for converted metadata.
* @param show_shared_dims True to include shared-dimension annotations.
* @return A heap-allocated list of DAP2 values corresponding to this object.
*/
std::vector<BaseType *> *transform_to_dap2(AttrTable *parent_attr_table, bool show_shared_dims = false) override;
void dump(ostream &strm) const override;
};
} // namespace libdap
#endif // _byte_h