-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHdfObjAttribute.cpp
More file actions
executable file
·229 lines (213 loc) · 4.89 KB
/
Copy pathHdfObjAttribute.cpp
File metadata and controls
executable file
·229 lines (213 loc) · 4.89 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
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
// HdfObjAttribute.cpp: implementation of the CAttribute class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "HDFPlugin.h"
#include "HdfObjAttribute.h"
#include "HdfObjDataset.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CAttribute::CAttribute(LPCTSTR name)
{
m_pName = name;
m_pValue = NULL;
m_pDims = NULL;
m_nRank = 1;
}
CAttribute::~CAttribute()
{
}
void CAttribute::SetName(LPCTSTR name)
{
m_pName = name;
}
LPCTSTR CAttribute::GetName()
{
return m_pName;
}
void CAttribute::SetValue(void* value)
{
m_pValue = value;
}
void* CAttribute::GetValue()
{
return m_pValue;
}
CString CAttribute::ValueToStr()
{
char tmp_char;
unsigned char tmp_uchar;
_int8 tmp_int8;
_int16 tmp_int16;
_int32 tmp_int32;
_int64 tmp_int64;
unsigned _int8 tmp_uint8;
unsigned _int16 tmp_uint16;
unsigned _int32 tmp_uint32;
unsigned _int64 tmp_uint64;
float tmp_float;
double tmp_double;
int i=0;
unsigned char *vp = (unsigned char *)m_pValue;
int n = 1;
if (m_pDims)
{
for (int i=0; i<m_nRank; i++)
{
n *= m_pDims[i];
}
}
CString allValue;
CString oneValue;
switch (m_nNT)
{
case CDataset::HDF_NT_CHAR:
memcpy(&tmp_char, vp, 1);
oneValue.Format("%c",tmp_char);
allValue += oneValue;
for (i=1; i<n; i++)
{
memcpy(&tmp_char, vp+i, 1);
oneValue.Format("%c",tmp_char);
allValue += oneValue;
}
break;
case CDataset::HDF_NT_UCHAR:
memcpy(&tmp_uchar, vp, 1);
oneValue.Format("%c",tmp_uchar);
allValue += oneValue;
for (i=1; i<n; i++)
{
memcpy(&tmp_uchar, vp+i, 1);
oneValue.Format("%c",tmp_uchar);
allValue += oneValue;
}
break;
case CDataset::HDF_NT_INT8:
memcpy(&tmp_int8, vp, 1);
oneValue.Format("%d",tmp_int8);
allValue += oneValue;
for (i=1; i<n; i++)
{
memcpy(&tmp_int8, vp+i, 1);
oneValue.Format(", %d",tmp_int8);
allValue += oneValue;
}
break;
case CDataset::HDF_NT_INT16:
memcpy(&tmp_int16, vp, 2);
oneValue.Format("%d",tmp_int16);
allValue += oneValue;
for (i=1; i<n; i++)
{
memcpy(&tmp_int16, vp+i*2, 2);
oneValue.Format(", %d",tmp_int16);
allValue += oneValue;
}
break;
case CDataset::HDF_NT_INT32:
memcpy(&tmp_int32, vp, 4);
oneValue.Format("%d",tmp_int32);
allValue += oneValue;
for (i=1; i<n; i++)
{
memcpy(&tmp_int32, vp+i*4, 4);
oneValue.Format(", %d",tmp_int32);
allValue += oneValue;
}
break;
case CDataset::HDF_NT_INT64:
memcpy(&tmp_int64, vp, 8);
oneValue.Format("%d",tmp_int64);
allValue += oneValue;
for (i=1; i<n; i++)
{
memcpy(&tmp_int64, vp+i*8, 8);
oneValue.Format(", %d",tmp_int64);
allValue += oneValue;
}
break;
case CDataset::HDF_NT_UINT8:
memcpy(&tmp_uint8, vp, 1);
oneValue.Format("%u", tmp_uint8);
allValue += oneValue;
for (i=1; i<n; i++)
{
memcpy(&tmp_uint8, vp+i, 1);
oneValue.Format(", %u", tmp_uint8);
allValue += oneValue;
}
break;
case CDataset::HDF_NT_UINT16:
memcpy(&tmp_uint16, vp, 2);
oneValue.Format("%u", tmp_uint16);
allValue += oneValue;
for (i=1; i<n; i++)
{
memcpy(&tmp_uint16, vp+i*2, 2);
oneValue.Format(", %u", tmp_uint16);
allValue += oneValue;
}
break;
case CDataset::HDF_NT_UINT32:
memcpy(&tmp_uint32, vp, 4);
oneValue.Format("%u", tmp_uint32);
allValue += oneValue;
for (i=1; i<n; i++)
{
memcpy(&tmp_uint32, vp+i*4, 4);
oneValue.Format(", %u", tmp_uint32);
allValue += oneValue;
}
break;
case CDataset::HDF_NT_UINT64:
memcpy(&tmp_uint64, vp, 8);
oneValue.Format("%u", tmp_uint64);
allValue += oneValue;
for (i=1; i<n; i++)
{
memcpy(&tmp_uint64, vp+i*8, 8);
oneValue.Format(", %u", tmp_uint64);
allValue += oneValue;
}
break;
case CDataset::HDF_NT_FLOAT:
memcpy(&tmp_float, vp, 4);
oneValue.Format("%g",tmp_float);
allValue += oneValue;
for (i=1; i<n; i++)
{
memcpy(&tmp_float, vp+i*4, 4);
oneValue.Format(", %g",tmp_float);
allValue += oneValue;
}
break;
case CDataset::HDF_NT_DOUBLE:
memcpy(&tmp_double, vp, 8);
oneValue.Format("%g",tmp_double);
allValue += oneValue;
for (i=1; i<n; i++)
{
memcpy(&tmp_double, vp+i*8, 8);
oneValue.Format(", %g",tmp_double);
allValue += oneValue;
}
break;
case CDataset::HDF_NT_STRING:
allValue += (char *)vp;
break;
default:
break;
}
return allValue;
}
void CAttribute::SetDims(int* dims)
{
m_pDims = dims;
}