48 #include "InternalErr.h"
64 : Str(n,d),dset_id(-1),ty_id(-1), array_flag(0)
75 size_t size = H5Tget_size(ty_id);
76 DBG(cerr <<
">read() size=" << size << endl);
81 if (array_flag == 1) {
82 DBG(cerr <<
"=read(): array is dected." << endl);
88 throw InternalErr(__FILE__, __LINE__,
"cannot return the size of datatype");
95 string str(chr.begin(),chr.end());
99 if (H5Tclose(ty_id) < 0) {
100 throw InternalErr(__FILE__, __LINE__,
"Unable to close the datatype.");
102 if (H5Dclose(dset_id) < 0) {
103 throw InternalErr(__FILE__, __LINE__,
"Unable to close the dset.");
109 BaseType *q = get_parent();
111 int i = H5Tget_nmembers(ty_id);
115 hid_t s2_str_tid = H5Tcreate(H5T_COMPOUND,
sizeof(
s2_str_t));
118 vector<s2_str_t> buf(i);
119 string myname = name();
123 throw InternalErr(__FILE__, __LINE__,
"H5Tget_nmembers() failed.");
125 if (s2_str_tid < 0) {
126 throw InternalErr(__FILE__, __LINE__,
"cannot create a new datatype");
129 DBG(cerr <<
"=read() ty_id=" << ty_id <<
" name=" << myname <<
130 " size=" << i << endl);
132 if (q->is_constructor_type()) {
134 hid_t type = H5Tcopy(H5T_C_S1);
136 throw InternalErr(__FILE__, __LINE__,
"cannot copy");
138 if (H5Tset_size(type, (
size_t) size) < 0) {
139 throw InternalErr(__FILE__, __LINE__,
"Unable to set size of datatype.");
141 if (H5Tset_strpad(type, H5T_STR_NULLTERM) < 0) {
142 throw InternalErr(__FILE__, __LINE__,
"H5Tset_strpad() failed.");
144 if (H5Tinsert(s2_str_tid, myname.c_str(), 0, type) < 0) {
145 throw InternalErr(__FILE__, __LINE__,
"Unable to add to datatype.");
149 stemp_tid = H5Tcreate(H5T_COMPOUND,
sizeof(
s2_str_t));
151 throw InternalErr(__FILE__, __LINE__,
"cannot create a new datatype");
153 if (H5Tinsert(stemp_tid, parent_name.c_str(), 0, s2_str_tid) < 0) {
154 throw InternalErr(__FILE__, __LINE__,
"Unable to add datatype.");
156 s2_str_tid = stemp_tid;
159 parent_name = q->name();
171 if (H5Dread(dset_id, s2_str_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &buf[0]) < 0) {
175 throw InternalErr(__FILE__, __LINE__,
"hdf5_dods server failed when getting int32 data for structure");
180 string str = buf[j].a;
HDF5Str(const string &n, const string &d)
Constructor.
This class converts HDF5 compound type into DAP structure for the default option. ...
string get_dap_type(hid_t type)
returns the string representation of HDF5 type.
int get_array_index()
returns the array index of this Structure if it's a part of array of structures.
Data structure and retrieval processing header for the default option.
void get_data(hid_t dset, void *buf)
will get all data of a dset dataset and put it into buf.
void set_tid(hid_t type)
remembers HDF5 datatype id.
virtual bool read()
Reads HDF5 string data into local buffer.
This class that translates HDF5 string into DAP string for the default option.
void set_did(hid_t dset)
remembers HDF5 dataset id.
hid_t get_did()
returns HDF5 dataset id.
hid_t get_tid()
returns HDF5 datatype id.
virtual BaseType * ptr_duplicate()
Clone this instance.
struct s2_str_t s2_str_t
A temporary structure for retrieving data from HDF5 compound data type.