summaryrefslogtreecommitdiffstats
path: root/c++/src/H5PredType.cpp
blob: 6dbee98f34ee5c6c44c11c928f79f34fd0075ded (plain)
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Copyright by The HDF Group.                                               *
 * Copyright by the Board of Trustees of the University of Illinois.         *
 * All rights reserved.                                                      *
 *                                                                           *
 * This file is part of HDF5.  The full HDF5 copyright notice, including     *
 * terms governing use, modification, and redistribution, is contained in    *
 * the files COPYING and Copyright.html.  COPYING can be found at the root   *
 * of the source code distribution tree; Copyright.html can be found at the  *
 * root level of an installed copy of the electronic HDF5 document set and   *
 * is linked from the top-level documents page.  It can also be found at     *
 * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
 * access to either file, you may request a copy from help@hdfgroup.org.     *
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include <string>

#include "H5Include.h"
#include "H5Exception.h"
#include "H5IdComponent.h"
#include "H5PropList.h"
#include "H5Object.h"
#include "H5DcreatProp.h"
#include "H5CommonFG.h"
#include "H5DataType.h"
#include "H5AtomType.h"
#include "H5Library.h"
#include "H5PredType.h"

#ifndef H5_NO_NAMESPACE
namespace H5 {
#endif

#ifndef DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function:	PredType overloaded constructor
///\brief	Creates a PredType object using the id of an existing
///		predefined datatype.
///\param	predtype_id - IN: Id of a predefined datatype
// Description
// 		This constructor creates a PredType object by copying
//		the provided HDF5 predefined datatype.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
PredType::PredType( const hid_t predtype_id ) : AtomType( predtype_id )
{
    if (predtype_id == H5CPP_EXITED)
	id = predtype_id;
    else
	id = H5Tcopy(predtype_id);
}

//--------------------------------------------------------------------------
// Function:	PredType default constructor
///\brief	Default constructor: Creates a stub predefined datatype
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
PredType::PredType() : AtomType() {}
#endif // DOXYGEN_SHOULD_SKIP_THIS

//--------------------------------------------------------------------------
// Function:	PredType copy constructor
///\brief	Copy constructor: makes a copy of the original PredType object.
///\param	original - IN: PredType instance to copy
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
PredType::PredType( const PredType& original ) : AtomType( original ) {}

#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Flag to terminate HDF5 library in DataType::~DataType
const PredType PredType::AtExit(H5CPP_EXITED);

// Definition of pre-defined types
const PredType PredType::C_S1( H5T_C_S1 );
const PredType PredType::FORTRAN_S1( H5T_FORTRAN_S1 );

const PredType PredType::STD_I8BE( H5T_STD_I8BE );
const PredType PredType::STD_I8LE( H5T_STD_I8LE );
const PredType PredType::STD_I16BE( H5T_STD_I16BE );
const PredType PredType::STD_I16LE( H5T_STD_I16LE );
const PredType PredType::STD_I32BE( H5T_STD_I32BE );
const PredType PredType::STD_I32LE( H5T_STD_I32LE );
const PredType PredType::STD_I64BE( H5T_STD_I64BE );
const PredType PredType::STD_I64LE( H5T_STD_I64LE );
const PredType PredType::STD_U8BE( H5T_STD_U8BE );
const PredType PredType::STD_U8LE( H5T_STD_U8LE );
const PredType PredType::STD_U16BE( H5T_STD_U16BE );
const PredType PredType::STD_U16LE( H5T_STD_U16LE );
const PredType PredType::STD_U32BE( H5T_STD_U32BE );
const PredType PredType::STD_U32LE( H5T_STD_U32LE );
const PredType PredType::STD_U64BE( H5T_STD_U64BE );
const PredType PredType::STD_U64LE( H5T_STD_U64LE );
const PredType PredType::STD_B8BE( H5T_STD_B8BE );
const PredType PredType::STD_B8LE( H5T_STD_B8LE );

const PredType PredType::STD_B16BE( H5T_STD_B16BE );
const PredType PredType::STD_B16LE( H5T_STD_B16LE );
const PredType PredType::STD_B32BE( H5T_STD_B32BE );
const PredType PredType::STD_B32LE( H5T_STD_B32LE );
const PredType PredType::STD_B64BE( H5T_STD_B64BE );
const PredType PredType::STD_B64LE( H5T_STD_B64LE );
const PredType PredType::STD_REF_OBJ( H5T_STD_REF_OBJ );
const PredType PredType::STD_REF_DSETREG( H5T_STD_REF_DSETREG );

const PredType PredType::IEEE_F32BE( H5T_IEEE_F32BE );
const PredType PredType::IEEE_F32LE( H5T_IEEE_F32LE );
const PredType PredType::IEEE_F64BE( H5T_IEEE_F64BE );
const PredType PredType::IEEE_F64LE( H5T_IEEE_F64LE );

const PredType PredType::UNIX_D32BE( H5T_UNIX_D32BE );
const PredType PredType::UNIX_D32LE( H5T_UNIX_D32LE );
const PredType PredType::UNIX_D64BE( H5T_UNIX_D64BE );
const PredType PredType::UNIX_D64LE( H5T_UNIX_D64LE );

const PredType PredType::INTEL_I8( H5T_INTEL_I8 );
const PredType PredType::INTEL_I16( H5T_INTEL_I16 );
const PredType PredType::INTEL_I32( H5T_INTEL_I32 );
const PredType PredType::INTEL_I64( H5T_INTEL_I64 );
const PredType PredType::INTEL_U8( H5T_INTEL_U8 );
const PredType PredType::INTEL_U16( H5T_INTEL_U16 );
const PredType PredType::INTEL_U32( H5T_INTEL_U32 );
const PredType PredType::INTEL_U64( H5T_INTEL_U64 );
const PredType PredType::INTEL_B8( H5T_INTEL_B8 );
const PredType PredType::INTEL_B16( H5T_INTEL_B16 );
const PredType PredType::INTEL_B32( H5T_INTEL_B32 );
const PredType PredType::INTEL_B64( H5T_INTEL_B64 );
const PredType PredType::INTEL_F32( H5T_INTEL_F32 );
const PredType PredType::INTEL_F64( H5T_INTEL_F64 );

const PredType PredType::ALPHA_I8( H5T_ALPHA_I8 );
const PredType PredType::ALPHA_I16( H5T_ALPHA_I16 );
const PredType PredType::ALPHA_I32( H5T_ALPHA_I32 );
const PredType PredType::ALPHA_I64( H5T_ALPHA_I64 );
const PredType PredType::ALPHA_U8( H5T_ALPHA_U8 );
const PredType PredType::ALPHA_U16( H5T_ALPHA_U16 );
const PredType PredType::ALPHA_U32( H5T_ALPHA_U32 );
const PredType PredType::ALPHA_U64( H5T_ALPHA_U64 );
const PredType PredType::ALPHA_B8( H5T_ALPHA_B8 );
const PredType PredType::ALPHA_B16( H5T_ALPHA_B16 );
const PredType PredType::ALPHA_B32( H5T_ALPHA_B32 );
const PredType PredType::ALPHA_B64( H5T_ALPHA_B64 );
const PredType PredType::ALPHA_F32( H5T_ALPHA_F32 );
const PredType PredType::ALPHA_F64( H5T_ALPHA_F64 );

const PredType PredType::MIPS_I8( H5T_MIPS_I8 );
const PredType PredType::MIPS_I16( H5T_MIPS_I16 );
const PredType PredType::MIPS_I32( H5T_MIPS_I32 );
const PredType PredType::MIPS_I64( H5T_MIPS_I64 );
const PredType PredType::MIPS_U8( H5T_MIPS_U8 );
const PredType PredType::MIPS_U16( H5T_MIPS_U16 );
const PredType PredType::MIPS_U32( H5T_MIPS_U32 );
const PredType PredType::MIPS_U64( H5T_MIPS_U64 );
const PredType PredType::MIPS_B8( H5T_MIPS_B8 );
const PredType PredType::MIPS_B16( H5T_MIPS_B16 );
const PredType PredType::MIPS_B32( H5T_MIPS_B32 );
const PredType PredType::MIPS_B64( H5T_MIPS_B64 );
const PredType PredType::MIPS_F32( H5T_MIPS_F32 );
const PredType PredType::MIPS_F64( H5T_MIPS_F64 );

const PredType PredType::NATIVE_CHAR( H5T_NATIVE_CHAR );
const PredType PredType::NATIVE_INT( H5T_NATIVE_INT );
const PredType PredType::NATIVE_FLOAT( H5T_NATIVE_FLOAT );
const PredType PredType::NATIVE_SCHAR( H5T_NATIVE_SCHAR );
const PredType PredType::NATIVE_UCHAR( H5T_NATIVE_UCHAR );
const PredType PredType::NATIVE_SHORT( H5T_NATIVE_SHORT );
const PredType PredType::NATIVE_USHORT( H5T_NATIVE_USHORT );
const PredType PredType::NATIVE_UINT( H5T_NATIVE_UINT );
const PredType PredType::NATIVE_LONG( H5T_NATIVE_LONG );
const PredType PredType::NATIVE_ULONG( H5T_NATIVE_ULONG );
const PredType PredType::NATIVE_LLONG( H5T_NATIVE_LLONG );
const PredType PredType::NATIVE_ULLONG( H5T_NATIVE_ULLONG );
const PredType PredType::NATIVE_DOUBLE( H5T_NATIVE_DOUBLE );
#if H5_SIZEOF_LONG_DOUBLE !=0
const PredType PredType::NATIVE_LDOUBLE( H5T_NATIVE_LDOUBLE );
#endif
const PredType PredType::NATIVE_B8( H5T_NATIVE_B8 );
const PredType PredType::NATIVE_B16( H5T_NATIVE_B16 );
const PredType PredType::NATIVE_B32( H5T_NATIVE_B32 );
const PredType PredType::NATIVE_B64( H5T_NATIVE_B64 );
const PredType PredType::NATIVE_OPAQUE( H5T_NATIVE_OPAQUE );
const PredType PredType::NATIVE_HSIZE( H5T_NATIVE_HSIZE );
const PredType PredType::NATIVE_HSSIZE( H5T_NATIVE_HSSIZE );
const PredType PredType::NATIVE_HERR( H5T_NATIVE_HERR );
const PredType PredType::NATIVE_HBOOL( H5T_NATIVE_HBOOL );

const PredType PredType::NATIVE_INT8( H5T_NATIVE_INT8 );
const PredType PredType::NATIVE_UINT8( H5T_NATIVE_UINT8 );
const PredType PredType::NATIVE_INT16( H5T_NATIVE_INT16 );
const PredType PredType::NATIVE_UINT16( H5T_NATIVE_UINT16 );
const PredType PredType::NATIVE_INT32( H5T_NATIVE_INT32 );
const PredType PredType::NATIVE_UINT32( H5T_NATIVE_UINT32 );
const PredType PredType::NATIVE_INT64( H5T_NATIVE_INT64 );
const PredType PredType::NATIVE_UINT64( H5T_NATIVE_UINT64 );

// LEAST types
#if H5_SIZEOF_INT_LEAST8_T != 0
const PredType PredType::NATIVE_INT_LEAST8( H5T_NATIVE_INT_LEAST8 );
#endif /* H5_SIZEOF_INT_LEAST8_T */
#if H5_SIZEOF_UINT_LEAST8_T != 0
const PredType PredType::NATIVE_UINT_LEAST8( H5T_NATIVE_UINT_LEAST8 );
#endif /* H5_SIZEOF_UINT_LEAST8_T */

#if H5_SIZEOF_INT_LEAST16_T != 0
const PredType PredType::NATIVE_INT_LEAST16( H5T_NATIVE_INT_LEAST16 );
#endif /* H5_SIZEOF_INT_LEAST16_T */
#if H5_SIZEOF_UINT_LEAST16_T != 0
const PredType PredType::NATIVE_UINT_LEAST16( H5T_NATIVE_UINT_LEAST16 );
#endif /* H5_SIZEOF_UINT_LEAST16_T */

#if H5_SIZEOF_INT_LEAST32_T != 0
const PredType PredType::NATIVE_INT_LEAST32( H5T_NATIVE_INT_LEAST32 );
#endif /* H5_SIZEOF_INT_LEAST32_T */
#if H5_SIZEOF_UINT_LEAST32_T != 0
const PredType PredType::NATIVE_UINT_LEAST32( H5T_NATIVE_UINT_LEAST32 );
#endif /* H5_SIZEOF_UINT_LEAST32_T */

#if H5_SIZEOF_INT_LEAST64_T != 0
const PredType PredType::NATIVE_INT_LEAST64( H5T_NATIVE_INT_LEAST64 );
#endif /* H5_SIZEOF_INT_LEAST64_T */
#if H5_SIZEOF_UINT_LEAST64_T != 0
const PredType PredType::NATIVE_UINT_LEAST64( H5T_NATIVE_UINT_LEAST64 );
#endif /* H5_SIZEOF_UINT_LEAST64_T */

// FAST types
#if H5_SIZEOF_INT_FAST8_T != 0
const PredType PredType::NATIVE_INT_FAST8( H5T_NATIVE_INT_FAST8 );
#endif /* H5_SIZEOF_INT_FAST8_T */
#if H5_SIZEOF_UINT_FAST8_T != 0
const PredType PredType::NATIVE_UINT_FAST8( H5T_NATIVE_UINT_FAST8 );
#endif /* H5_SIZEOF_UINT_FAST8_T */

#if H5_SIZEOF_INT_FAST16_T != 0
const PredType PredType::NATIVE_INT_FAST16( H5T_NATIVE_INT_FAST16 );
#endif /* H5_SIZEOF_INT_FAST16_T */
#if H5_SIZEOF_UINT_FAST16_T != 0
const PredType PredType::NATIVE_UINT_FAST16( H5T_NATIVE_UINT_FAST16 );
#endif /* H5_SIZEOF_UINT_FAST16_T */

#if H5_SIZEOF_INT_FAST32_T != 0
const PredType PredType::NATIVE_INT_FAST32( H5T_NATIVE_INT_FAST32 );
#endif /* H5_SIZEOF_INT_FAST32_T */
#if H5_SIZEOF_UINT_FAST32_T != 0
const PredType PredType::NATIVE_UINT_FAST32( H5T_NATIVE_UINT_FAST32 );
#endif /* H5_SIZEOF_UINT_FAST32_T */

#if H5_SIZEOF_INT_FAST64_T != 0
const PredType PredType::NATIVE_INT_FAST64( H5T_NATIVE_INT_FAST64 );
#endif /* H5_SIZEOF_INT_FAST64_T */
#if H5_SIZEOF_UINT_FAST64_T != 0
const PredType PredType::NATIVE_UINT_FAST64( H5T_NATIVE_UINT_FAST64 );
#endif /* H5_SIZEOF_UINT_FAST64_T */
#endif // DOXYGEN_SHOULD_SKIP_THIS

//--------------------------------------------------------------------------
// Function:	PredType::operator=
///\brief	Assignment operator.
///\param	rhs - IN: Reference to the predefined datatype
///\return	Reference to PredType instance
///\exception	H5::DataTypeIException
// Description
//		Makes a copy of the type on the right hand side and stores
//		the new id in the left hand side object.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
PredType& PredType::operator=( const PredType& rhs )
{
    if (this != &rhs)
	copy(rhs);
    return(*this);
}

#ifndef DOXYGEN_SHOULD_SKIP_THIS
// These dummy functions do not inherit from DataType - they'll
// throw an DataTypeIException if invoked.
void PredType::commit(H5Location& loc, const char* name )
{
   throw DataTypeIException("PredType::commit", "Error: Attempted to commit a predefined datatype.  Invalid operation!" );
}

void PredType::commit(H5Location& loc, const H5std_string& name )
{
   commit( loc, name.c_str());
}

bool PredType::committed()
{
   throw DataTypeIException("PredType::committed", "Error: Attempting to check for commit status on a predefined datatype." );
}
#endif // DOXYGEN_SHOULD_SKIP_THIS

// Default destructor
//--------------------------------------------------------------------------
// Function:	PredType destructor
///\brief	Noop destructor.
// Programmer	Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
PredType::~PredType() {}

#ifndef H5_NO_NAMESPACE
} // end namespace
#endif