54 for_each (this->
vars.begin (), this->
vars.end (),
66 for_each (this->
attrs.begin (), this->
attrs.end (),
72 for_each (this->
dims.begin (), this->
dims.end (),
74 for_each (this->
attrs.begin (), this->
attrs.end (),
88 if ((root_id = H5Gopen(file_id,
"/",H5P_DEFAULT))<0){
89 throw1 (
"Cannot open the HDF5 root group " );
91 this->rootid =root_id;
93 this->Retrieve_H5_Obj(root_id,
"/",include_attr);
99 if (
true == include_attr) {
107 if (H5Oget_info(root_id,&oinfo) < 0)
108 throw1(
"Error obtaining the info for the root group");
110 num_attrs = oinfo.num_attrs;
111 bool temp_unsup_attr_atype =
false;
113 for (
int j = 0; j < num_attrs; j ++) {
116 this->Retrieve_H5_Attr_Info(attr,root_id,j, temp_unsup_attr_atype);
123 this->root_attrs.push_back(attr);
126 this->unsupported_attr_dtype = temp_unsup_attr_atype;
138 if (H5Gget_info(grp_id,&g_info) <0)
139 throw2 (
"Counting hdf5 group elements error for ", gname);
140 nelems = g_info.nlinks;
142 ssize_t oname_size = 0;
143 for (hsize_t i = 0; i < nelems; i++) {
154 size_t dummy_name_len = 1;
157 H5Lget_name_by_idx(grp_id,
".",H5_INDEX_NAME,H5_ITER_NATIVE,i,
NULL,
158 dummy_name_len, H5P_DEFAULT);
160 throw2(
"Error getting the size of the hdf5 object from the group: ", gname);
164 oname.resize((
size_t)oname_size+1);
168 if (H5Lget_name_by_idx(grp_id,
".",H5_INDEX_NAME,H5_ITER_NATIVE,i,&oname[0],
169 (
size_t)(oname_size+1), H5P_DEFAULT) < 0)
170 throw2(
"Error getting the hdf5 object name from the group: ",gname);
174 if (H5Lget_info(grp_id,&oname[0],&linfo,H5P_DEFAULT)<0)
175 throw2 (
"HDF5 link name error from ", gname);
178 if(H5L_TYPE_SOFT == linfo.type || H5L_TYPE_EXTERNAL == linfo.type)
184 if (H5Oget_info_by_idx(grp_id,
".", H5_INDEX_NAME, H5_ITER_NATIVE,
185 i, &oinfo, H5P_DEFAULT)<0)
186 throw2(
"Error obtaining the info for the object ",
string(oname.begin(),oname.end()));
188 H5O_type_t obj_type = oinfo.type;
192 case H5O_TYPE_GROUP: {
195 string full_path_name;
196 string temp_oname(oname.begin(),oname.end());
199 full_path_name = ((string(gname) !=
"/")
200 ?(
string(gname)+
"/"+temp_oname.substr(0,temp_oname.size()-1)):(
"/"+temp_oname.substr(0,temp_oname.size()-1)));
204 cgroup = H5Gopen(grp_id, full_path_name.c_str(),H5P_DEFAULT);
206 throw2(
"Error opening the group ",full_path_name);
209 group->
path = full_path_name;
210 group->
newname = full_path_name;
213 if (
true == include_attr) {
215 int num_attrs = oinfo.num_attrs;
216 bool temp_unsup_attr_dtype =
false;
218 for (
int j = 0; j < num_attrs; j ++) {
221 Retrieve_H5_Attr_Info(attr,cgroup,j, temp_unsup_attr_dtype);
222 group->
attrs.push_back(attr);
228 this->groups.push_back(group);
229 Retrieve_H5_Obj(cgroup,full_path_name.c_str(),include_attr);
234 case H5O_TYPE_DATASET:{
243 string temp_oname(oname.begin(),oname.end());
244 string full_path_name = ((string(gname) !=
"/")
245 ?(
string(gname)+
"/"+temp_oname.substr(0,temp_oname.size()-1)):(
"/"+temp_oname.substr(0,temp_oname.size()-1)));
249 var->
name = temp_oname.substr(0,temp_oname.size()-1);
255 cdset = H5Dopen(grp_id, full_path_name.c_str(),H5P_DEFAULT);
257 throw2(
"Error opening the HDF5 dataset ",full_path_name);
260 bool temp_unsup_var_dtype =
false;
261 Retrieve_H5_VarType(var,cdset,full_path_name,temp_unsup_var_dtype);
263 if (!this->unsupported_var_dtype && temp_unsup_var_dtype)
264 this->unsupported_var_dtype =
true;
266 bool temp_unsup_var_dspace =
false;
268 Retrieve_H5_VarDim(var,cdset,full_path_name,temp_unsup_var_dspace);
270 if (!this->unsupported_var_dspace && temp_unsup_var_dspace)
271 this->unsupported_var_dspace =
true;
273 if (
true == include_attr) {
275 int num_attrs = oinfo.num_attrs;
276 bool temp_unsup_attr_dtype =
false;
278 for (
int j = 0; j < num_attrs; j ++) {
282 Retrieve_H5_Attr_Info(attr,cdset,j, temp_unsup_attr_dtype);
283 var->
attrs.push_back(attr);
290 this->vars.push_back(var);
295 case H5O_TYPE_NAMED_DATATYPE:
340 if ((ty_id = H5Dget_type(dset_id)) < 0)
341 throw2(
"unable to obtain hdf5 datatype for the dataset ",varname);
361 unsup_var_dtype =
true;
371 vector<hsize_t> dsize;
372 vector<hsize_t> maxsize;
374 hid_t dspace_id = -1;
378 if ((dspace_id = H5Dget_space(dset_id)) < 0)
379 throw2(
"Cannot get hdf5 dataspace id for the variable ",varname);
381 H5S_class_t space_class = H5S_NO_CLASS;
382 if ((space_class = H5Sget_simple_extent_type(dspace_id)) < 0)
383 throw2(
"Cannot obtain the HDF5 dataspace class for the variable ",varname);
385 if (H5S_NULL == space_class)
386 unsup_var_dspace =
true;
390 if (H5S_SCALAR == space_class) {
393 if ((ty_id = H5Dget_type(dset_id)) < 0)
394 throw2(
"unable to obtain the hdf5 datatype for the dataset ",varname);
396 if (H5T_STRING != H5Tget_class(ty_id))
397 unsup_var_dspace =
true;
402 if (
false == unsup_var_dspace) {
404 int ndims = H5Sget_simple_extent_ndims(dspace_id);
406 throw2(
"Cannot get the hdf5 dataspace number of dimension for the variable ",varname);
413 maxsize.resize(ndims);
420 if (H5Sget_simple_extent_dims(dspace_id, &dsize[0], &maxsize[0])<0)
421 throw2(
"Cannot obtain the dim. info for the variable ", varname);
424 for (
int i = 0; i < ndims; i++) {
426 unsup_var_dspace =
true;
431 if (
false == unsup_var_dspace) {
432 for (
int i=0; i<ndims; i++) {
434 var->dims.push_back(dim);
440 var->unsupported_dspace = unsup_var_dspace;
468 hid_t aspace_id = -1;
475 if ((attrid = H5Aopen_by_idx(obj_id,
".", H5_INDEX_CRT_ORDER, H5_ITER_INC,(hsize_t)j, H5P_DEFAULT, H5P_DEFAULT)) < 0)
476 throw1(
"Unable to open attribute by index " );
480 ssize_t name_size = H5Aget_name(attrid, 0,
NULL);
482 throw1(
"Unable to obtain the size of the hdf5 attribute name " );
486 attr_name.resize(name_size+1);
489 if ((H5Aget_name(attrid, name_size+1, &attr_name[0])) < 0)
490 throw1(
"unable to obtain the hdf5 attribute name ");
493 if ((ty_id = H5Aget_type(attrid)) < 0)
494 throw2(
"unable to obtain hdf5 datatype for the attribute ",attr_name);
513 unsup_attr_dtype =
true;
515 if ((aspace_id = H5Aget_space(attrid)) < 0)
516 throw2(
"Cannot get hdf5 dataspace id for the attribute ",attr_name);
518 int ndims = H5Sget_simple_extent_ndims(aspace_id);
520 throw2(
"Cannot get the hdf5 dataspace number of dimension for attribute ",attr_name);
526 vector<hsize_t> asize;
527 vector<hsize_t> maxsize;
529 maxsize.resize(ndims);
535 if (H5Sget_simple_extent_dims(aspace_id, &asize[0], &maxsize[0])<0)
536 throw2(
"Cannot obtain the dim. info for the attribute ", attr_name);
539 for (
int j = 0; j < ndims; j++)
543 size_t ty_size = H5Tget_size(ty_id);
545 throw2(
"Cannot obtain the dtype size for the attribute ",attr_name);
548 memtype = H5Tget_native_type(ty_id, H5T_DIR_ASCEND);
550 throw2(
"Cannot obtain the memory datatype for the attribute ",attr_name);
554 string temp_aname(attr_name.begin(),attr_name.end());
555 attr->name = temp_aname.substr(0,temp_aname.size()-1);
556 attr->newname = attr->name;
557 attr->count = nelmts;
591 for (vector<Attribute *>::iterator ira = this->
root_attrs.begin();
595 for (vector<Group *>::iterator irg = this->
groups.begin();
596 irg != this->
groups.end(); ++irg) {
597 for (vector<Attribute *>::iterator ira = (*irg)->attrs.begin();
598 ira != (*irg)->attrs.end(); ++ira) {
603 for (vector<Var *>::iterator irv = this->
vars.begin();
604 irv != this->
vars.end(); ++irv) {
605 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
606 ira != (*irv)->attrs.end(); ++ira) {
622 hid_t memtype_id = -1;
623 hid_t aspace_id = -1;
629 obj_id = H5Oopen(this->fileid,obj_name.c_str(),H5P_DEFAULT);
631 throw2(
"Cannot open the object ",obj_name);
633 attr_id = H5Aopen(obj_id,(attr->name).c_str(),H5P_DEFAULT);
635 throw4(
"Cannot open the attribute ",attr->name,
" of object ",obj_name);
637 ty_id = H5Aget_type(attr_id);
639 throw4(
"Cannot obtain the datatype of the attribute ",attr->name,
" of object ",obj_name);
641 memtype_id = H5Tget_native_type(ty_id, H5T_DIR_ASCEND);
644 throw2(
"Cannot obtain the memory datatype for the attribute ",attr->name);
647 size_t ty_size = H5Tget_size(memtype_id);
649 throw4(
"Cannot obtain the dtype size for the attribute ",attr->name,
" of object ",obj_name);
651 size_t total_bytes = attr->count * ty_size;
657 vector<char> temp_buf;
658 temp_buf.resize(total_bytes);
660 if (H5Aread(attr_id, memtype_id, &temp_buf[0]) < 0)
661 throw4(
"Cannot obtain the dtype size for the attribute ",attr->name,
" of object ",obj_name);
663 char *temp_bp =
NULL;
664 temp_bp = &temp_buf[0];
665 char* onestring =
NULL;
666 string total_vstring =
"";
668 attr->strsize.resize(attr->count);
670 for (
unsigned int temp_i = 0; temp_i <attr->count; temp_i++) {
673 onestring =*(
char **)temp_bp;
674 if(onestring!=
NULL) {
675 total_vstring +=string(onestring);
676 attr->strsize[temp_i] = (string(onestring)).size();
678 else attr->strsize[temp_i] = 0;
683 if (&temp_buf[0] !=
NULL) {
685 aspace_id = H5Aget_space(attr_id);
687 throw4(
"Cannot obtain space id for ",attr->name,
" of object ",obj_name);
690 if (H5Dvlen_reclaim(memtype_id,aspace_id,H5P_DEFAULT,&temp_buf[0]) < 0)
691 throw4(
"Cannot reclaim VL memory for ",attr->name,
" of object ",obj_name);
697 throw4(
"Error to obtain the VL string type for attribute ",attr->name,
" of object ",obj_name);
699 attr->value.resize(total_vstring.size());
701 copy(total_vstring.begin(),total_vstring.end(),attr->value.begin());
707 attr->fstrsize = ty_size;
710 attr->value.resize(total_bytes);
713 if (H5Aread(attr_id, memtype_id, (
void *) &attr->value[0]) < 0)
714 throw4(
"Cannot obtain the dtype size for the attribute ",attr->name,
" of object ",obj_name);
718 size_t sect_size = ty_size;
719 int num_sect = (total_bytes%sect_size==0)?(total_bytes/sect_size)
720 :(total_bytes/sect_size+1);
721 vector<size_t>sect_newsize;
722 sect_newsize.resize(num_sect);
724 string total_fstring = string(attr->value.begin(),attr->value.end());
727 num_sect,sect_size,sect_newsize);
729 attr->value.resize(new_total_fstring.size());
730 copy(new_total_fstring.begin(),new_total_fstring.end(),attr->value.begin());
731 attr->strsize.resize(num_sect);
732 for (
int temp_i = 0; temp_i <num_sect; temp_i ++)
733 attr->strsize[temp_i] = sect_newsize[temp_i];
737 for (
int temp_i = 0; temp_i <num_sect; temp_i ++)
738 cerr <<
"string new section size = " << attr->strsize[temp_i] <<endl;
743 H5Tclose(memtype_id);
753 H5Tclose(memtype_id);
779 if (
true == include_attr) {
780 if (
false == this->root_attrs.empty()) {
781 if (
true == this->unsupported_attr_dtype) {
782 for (vector<Attribute *>::iterator ira = this->root_attrs.begin();
783 ira != this->root_attrs.end(); ++ira) {
787 this->root_attrs.erase(ira);
795 if (
false == this->groups.empty()) {
796 for (vector<Group *>::iterator irg = this->groups.begin();
797 irg != this->groups.end(); ++irg) {
798 if (
false == (*irg)->attrs.empty()) {
799 if (
true == (*irg)->unsupported_attr_dtype) {
800 for (vector<Attribute *>::iterator ira = (*irg)->attrs.begin();
801 ira != (*irg)->attrs.end(); ++ira) {
805 (*irg)->attrs.erase(ira);
816 if (
false == this->vars.empty()) {
817 if (
true == include_attr) {
818 for (vector<Var *>::iterator irv = this->vars.begin();
819 irv != this->vars.end(); ++irv) {
820 if (
false == (*irv)->attrs.empty()) {
821 if (
true == (*irv)->unsupported_attr_dtype) {
822 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
823 ira != (*irv)->attrs.end(); ++ira) {
827 (*irv)->attrs.erase(ira);
835 if (
true == this->unsupported_var_dtype) {
837 for (vector<Var *>::iterator irv = this->vars.begin();
838 irv != this->vars.end(); ++irv) {
842 this->vars.erase(irv);
853 if (
false == this->
vars.empty()) {
855 for (vector<Var *>::iterator irv = this->
vars.begin();
856 irv != this->
vars.end(); ++irv) {
857 if (
true == (*irv)->unsupported_dspace) {
859 this->
vars.erase(irv);
868 for (vector<Var *>::iterator irv = this->vars.begin();
869 irv != this->vars.end(); ++irv) {
870 (*irv)->newname = get_CF_string((*irv)->newname);
874 for (vector<Dimension *>::iterator ird = (*irv)->dims.begin();
875 ird != (*irv)->dims.end(); ++ird) {
876 (*ird)->newname = get_CF_string((*ird)->newname);
880 if (
true == include_attr) {
882 for (vector<Attribute *>::iterator ira = this->root_attrs.begin();
883 ira != this->root_attrs.end(); ++ira){
884 (*ira)->newname = get_CF_string((*ira)->newname);
887 for (vector<Group *>::iterator irg = this->groups.begin();
888 irg != this->groups.end(); ++irg) {
889 (*irg)->newname = get_CF_string((*irg)->newname);
890 for (vector<Attribute *>::iterator ira = (*irg)->attrs.begin();
891 ira != (*irg)->attrs.end(); ++ira) {
892 (*ira)->newname = get_CF_string((*ira)->newname);
896 for (vector<Var *>::iterator irv = this->vars.begin();
897 irv != this->vars.end(); ++irv) {
898 for (vector<Attribute *>::iterator ira = (*irv)->attrs.begin();
899 ira != (*irv)->attrs.end(); ++ira) {
900 (*ira)->newname = get_CF_string((*ira)->newname);
908 Handle_General_NameClashing(objnameset,this->vars);
914 pair<set<string>::iterator,
bool> setret;
925 setret = objnameset.insert(FILE_ATTR_TABLE_NAME);
926 if (
false == setret.second) {
929 string fa_clash_name = FILE_ATTR_TABLE_NAME;
931 FILE_ATTR_TABLE_NAME = fa_clash_name;
935 Handle_General_NameClashing(objnameset,this->groups);
949 set<string>objnameset;
955 for (vector<Group *>::iterator irg = this->
groups.begin();
956 irg != this->
groups.end(); ++irg) {
962 for (vector<Var *>::iterator irv = this->
vars.begin();
963 irv != this->
vars.end(); ++irv) {
970 template<
class T>
void
975 pair<set<string>::iterator,
bool> setret;
976 set<string>::iterator iss;
978 vector<string> clashnamelist;
979 vector<string>::iterator ivs;
981 map<int,int> cl_to_ol;
986 typename vector<T*>::iterator irv;
988 for (irv = objvec.begin(); irv != objvec.end(); ++irv) {
989 setret = objnameset.insert((*irv)->newname);
990 if (
false == setret.second) {
991 clashnamelist.insert(clashnamelist.end(), (*irv)->newname);
992 cl_to_ol[cl_index] = ol_index;
1000 for (ivs=clashnamelist.begin(); ivs!=clashnamelist.end(); ivs++) {
1001 int clash_index = 1;
1002 string temp_clashname = *ivs +
'_';
1004 *ivs = temp_clashname;
1008 for (
unsigned int i =0; i <clashnamelist.size(); i++)
1009 objvec[cl_to_ol[i]]->newname = clashnamelist[i];
1018 Handle_Var_NameClashing(objnameset);
1019 if (
true == include_attr) {
1020 Handle_RootGroup_NameClashing(objnameset );
1021 Handle_Obj_AttrNameClashing();
1030 string insertString(1,
'_');
1033 if (
true == isdigit(s[0]))
1034 s.insert(0,insertString);
1036 for(
unsigned int i=0; i < s.length(); i++)
1037 if((
false == isalnum(s[i])) && (s[i]!=
'_'))
1046 pair<map<string,hsize_t>::iterator,
bool>mapret;
1047 mapret = dimname_to_dimsize.insert(pair<string,hsize_t>(name,size));
1048 if (
false == mapret.second)
1049 throw4(
"The dimension name ",name,
" should map to ",size);
1056 pair<map<string,hsize_t>::iterator,
bool>mapret;
1057 mapret = name_to_size.insert(pair<string,hsize_t>(name,size));
1058 if (
false == mapret.second)
1059 throw4(
"The dimension name ",name,
" should map to ",size);
1079 stringstream sfakedimindex;
1080 string fakedimstr =
"FakeDim";
1081 pair<set<string>::iterator,
bool> setret;
1082 map<hsize_t,string>::iterator im;
1083 pair<map<hsize_t,string>::iterator,
bool>mapret;
1085 sfakedimindex << addeddimindex;
1086 string added_dimname = fakedimstr + sfakedimindex.str();
1089 mapret = dimsize_to_fakedimname.insert(pair<hsize_t,string>(dim->size,added_dimname));
1090 if (
false == mapret.second) {
1091 dim->name = dimsize_to_fakedimname[dim->size];
1092 dim->newname = dim->name;
1099 setret = dimnamelist.insert(added_dimname);
1100 if (
false == setret.second) {
1102 string temp_clashname=added_dimname+
'_';
1104 dim->name = temp_clashname;
1105 dim->newname = dim->name;
1106 setret = dimnamelist.insert(dim->name);
1107 if(
false == setret.second)
1108 throw2(
"Fail to insert the unique dimsizede name ", dim->name);
1112 dimsize_to_fakedimname.erase(dim->size);
1113 mapret = dimsize_to_fakedimname.insert(pair<hsize_t,string>(dim->size,dim->name));
1114 if (
false == mapret.second)
1115 throw4(
"The dimension size ",dim->size,
" should map to ",dim->name);
1119 dim->name = added_dimname;
1120 dim->newname = dim->name;
1121 Insert_One_NameSizeMap_Element(dim->name,dim->size);
1137 stringstream sfakedimindex;
1138 pair<set<string>::iterator,
bool> setret;
1141 sfakedimindex << addeddimindex;
1142 string added_dimname =
"FakeDim" + sfakedimindex.str();
1143 setret = dimnamelist.insert(added_dimname);
1144 if (
false == setret.second) {
1146 string temp_clashname=added_dimname+
'_';
1148 dim->name = temp_clashname;
1149 dim->newname = dim->name;
1150 setret = dimnamelist.insert(dim->name);
1151 if(
false == setret.second)
1152 throw2(
"Fail to insert the unique dimsizede name ", dim->name);
1154 dim->name = added_dimname;
1155 dim->newname = dim->name;
1156 Insert_One_NameSizeMap_Element(dim->name,dim->size);
1165 attr->name = attrname;
1166 attr->newname = attr->name;
1169 attr->fstrsize = strvalue.size();
1170 attr->strsize.resize(1);
1171 attr->strsize[0] = attr->fstrsize;
1172 attr->value.resize(strvalue.size());
1173 copy(strvalue.begin(),strvalue.end(),attr->value.begin());
1178 attr->name = attrname;
1179 attr->newname = attr->name;
1182 attr->value.resize(
sizeof(
float));
1183 memcpy(&(attr->value[0]),(
void*)(&float_value),
sizeof(
float));
1192 long int num_sli = 0;
1194 throw2(
"Currently we only convert fixed-size string to other datatypes. ", attr->name);
1195 if(attr->count != 1)
1196 throw4(
"The fixed-size string count must be 1 and the current count is ",attr->count,
" for the attribute ",attr->name);
1198 Retrieve_H5_Attr_Value(attr,var->fullpath);
1200 attr_value.resize(attr->value.size());
1201 copy(attr->value.begin(),attr->value.end(),attr_value.begin());
1203 switch(var->dtype) {
1207 num_sli = strtol(&(attr->value[0]),&pEnd,10);
1208 if(num_sli <0 || num_sli >UCHAR_MAX)
1209 throw5(
"Attribute type is unsigned char, the current attribute ",attr->name,
" has the value ",num_sli,
". It is overflowed. ");
1211 unsigned char num_suc =(
unsigned char)num_sli;
1214 attr->value.resize(
sizeof(
unsigned char));
1215 memcpy(&(attr->value[0]),(
void*)(&num_suc),
sizeof(
unsigned char));
1222 num_sli = strtol(&(attr->value[0]),&pEnd,10);
1223 if(num_sli <SCHAR_MIN || num_sli >SCHAR_MAX)
1224 throw5(
"Attribute type is signed char, the current attribute ",attr->name,
" has the value ",num_sli,
". It is overflowed. ");
1226 char num_sc = (char)num_sli;
1229 attr->value.resize(
sizeof(
char));
1230 memcpy(&(attr->value[0]),(
void*)(&num_sc),
sizeof(
char));
1237 num_sli = strtol(&(attr->value[0]),&pEnd,10);
1238 if(num_sli <SHRT_MIN || num_sli >SHRT_MAX)
1239 throw5(
"Attribute type is 16-bit integer, the current attribute ",attr->name,
" has the value ",num_sli,
". It is overflowed. ");
1241 short num_ss = (short)num_sli;
1244 attr->value.resize(
sizeof(
short));
1245 memcpy(&(attr->value[0]),(
void*)(&num_ss),
sizeof(
short));
1253 num_sli = strtol(&(attr->value[0]),&pEnd,10);
1254 if(num_sli <0 || num_sli >USHRT_MAX)
1255 throw5(
"Attribute type is unsigned 16-bit integer, the current attribute ",attr->name,
" has the value ",num_sli,
". It is overflowed. ");
1257 unsigned short num_uss = (
unsigned short)num_sli;
1260 attr->value.resize(
sizeof(
unsigned short));
1261 memcpy(&(attr->value[0]),(
void*)(&num_uss),
sizeof(
unsigned short));
1267 num_sli = strtol(&(attr->value[0]),&pEnd,10);
1268 if(num_sli <LONG_MIN || num_sli >LONG_MAX)
1269 throw5(
"Attribute type is 32-bit integer, the current attribute ",attr->name,
" has the value ",num_sli,
". It is overflowed. ");
1273 attr->value.resize(
sizeof(
long int));
1274 memcpy(&(attr->value[0]),(
void*)(&num_sli),
sizeof(
long int));
1281 unsigned long int num_suli = strtoul(&(attr->value[0]),&pEnd,10);
1282 if(num_suli >ULONG_MAX)
1283 throw5(
"Attribute type is 32-bit unsigned integer, the current attribute ",attr->name,
" has the value ",num_suli,
". It is overflowed. ");
1287 attr->value.resize(
sizeof(
unsigned long int));
1288 memcpy(&(attr->value[0]),(
void*)(&num_suli),
sizeof(
unsigned long int));
1294 float num_sf = strtof(&(attr->value[0]),
NULL);
1298 attr->value.resize(
sizeof(
float));
1299 memcpy(&(attr->value[0]),(
void*)(&num_sf),
sizeof(
float));
1304 double num_sd = strtod(&(attr->value[0]),
NULL);
1308 attr->value.resize(
sizeof(
double));
1309 memcpy(&(attr->value[0]),(
void*)(&num_sd),
sizeof(
double));
1314 throw4(
"Unsupported HDF5 datatype that the string is converted to for the attribute ",attr->name,
" of the variable ",var->fullpath);
1324 if (
false == add_path)
1328 for (vector<Var *>::iterator irv = this->vars.begin();
1329 irv != this->vars.end(); ++irv) {
1331 const string varname = (*irv)->name;
1332 const string attrname =
"origname";
1333 Add_Str_Attr(attr,attrname,varname);
1334 (*irv)->attrs.push_back(attr);
1337 for (vector<Var *>::iterator irv = this->vars.begin();
1338 irv != this->vars.end(); ++irv) {
1340 const string varname = (*irv)->fullpath;
1341 const string attrname =
"fullnamepath";
1342 Add_Str_Attr(attr,attrname,varname);
1343 (*irv)->attrs.push_back(attr);
1347 for (vector<Group *>::iterator irg = this->groups.begin();
1348 irg != this->groups.end(); ++irg) {
1350 if (
false == (*irg)->attrs.empty()) {
1353 const string varname = (*irg)->path;
1354 const string attrname =
"fullnamepath";
1355 Add_Str_Attr(attr,attrname,varname);
1356 (*irg)->attrs.push_back(attr);
1369 for_each (target->
dims.begin (), target->
dims.end (),
1371 for_each (target->
attrs.begin (), target->
attrs.end (),
1383 for (vector<Attribute*>::iterator ira = target->
attrs.begin();
1384 ira!=target->
attrs.end(); ++ira) {
1386 target->
attrs.erase(ira);
1390 for (vector<Dimension*>::iterator ird = target->
dims.begin();
1391 ird!=target->
dims.end(); ++ird) {
1393 target->
dims.erase(ird);
1399 for (vector<Attribute*>::iterator ira = src->
attrs.begin();
1400 ira!=src->
attrs.end(); ++ira) {
1402 attr->
name = (*ira)->name;
1403 attr->
newname = (*ira)->newname;
1404 attr->
dtype =(*ira)->dtype;
1405 attr->
count =(*ira)->count;
1406 attr->
strsize = (*ira)->strsize;
1408 attr->
value =(*ira)->value;
1409 target->
attrs.push_back(attr);
1413 for (vector<Dimension*>::iterator ird = src->
dims.begin();
1414 ird!=src->
dims.end(); ++ird) {
1416 dim->
name = (*ird)->name;
1417 dim->
newname = (*ird)->newname;
1418 target->
dims.push_back(dim);
1428 for_each (target->
dims.begin (), target->
dims.end (),
1430 for_each (target->
attrs.begin (), target->
attrs.end (),
1434 for (vector<Attribute*>::iterator ira = target->
attrs.begin();
1435 ira!=target->
attrs.end(); ++ira) {
1437 target->
attrs.erase(ira);
1440 for (vector<Attribute*>::iterator ira = src->
attrs.begin();
1441 ira!=src->
attrs.end(); ++ira) {
1443 attr->
name = (*ira)->name;
1444 attr->
newname = (*ira)->newname;
1445 attr->
dtype =(*ira)->dtype;
1446 attr->
count =(*ira)->count;
1447 attr->
strsize = (*ira)->strsize;
1449 attr->
value =(*ira)->value;
1450 target->
attrs.push_back(attr);
void Retrieve_H5_Attr_Value(Attribute *attr, string)
#define throw5(a1, a2, a3, a4, a5)
vector< Dimension * > dims
This class represents one HDF5 dataset(CF variable)
virtual void Replace_Var_Info(Var *src, Var *target)
void Handle_GeneralObj_NameClashing(bool, set< string > &objnameset)
virtual void Retrieve_H5_Info(const char *path, hid_t file_id, bool include_attr)
Retrieve DDS information from the HDF5 file. The reason to separate reading DDS from DAS is: DAP need...
void Handle_RootGroup_NameClashing(set< string > &objnameset)
void Add_One_FakeDim_Name(Dimension *dim)
virtual void Handle_Unsupported_Dtype(bool)
Handle unsupported HDF5 datatypes.
void Retrieve_H5_VarType(Var *, hid_t dset_id, const string &varname, bool &unsup_var_dtype)
virtual void Retrieve_H5_Supported_Attr_Values()
Retrieve attribute values for the supported HDF5 datatypes.
static void gen_unique_name(std::string &str, std::set< std::string > &namelist, int &clash_index)
virtual void Add_Supplement_Attrs(bool)
Add supplemental attributes such as fullpath and original name.
vector< Var * > vars
Var vectors.
virtual string get_CF_string(string)
void Add_Str_Attr(Attribute *attr, const string &attrname, const string &strvalue)
bool unsupported_attr_dtype
void Adjust_Duplicate_FakeDim_Name(Dimension *dim)
virtual void Handle_Unsupported_Dspace()
Handle unsupported HDF5 dataspaces for datasets.
#define throw1(a1)
The followings are convenient functions to throw exceptions with different.
void Change_Attr_One_Str_to_Others(Attribute *attr, Var *var)
void Retrieve_H5_Attr_Info(Attribute *, hid_t obj_id, const int j, bool &unsup_attr_dtype)
void Handle_Obj_AttrNameClashing()
virtual void Replace_Var_Attrs(Var *src, Var *target)
void Retrieve_H5_VarDim(Var *, hid_t dset_id, const string &varname, bool &unsup_var_dspace)
vector< Attribute * > attrs
This class represents one attribute.
void Insert_One_NameSizeMap_Element2(map< string, hsize_t > &, string name, hsize_t size)
void Add_One_Float_Attr(Attribute *attr, const string &attrname, float float_value)
void Retrieve_H5_Obj(hid_t grp_id, const char *gname, bool include_attr)
bool unsupported_attr_dtype
This class repersents one dimension of an HDF5 dataset(variable).
void Handle_Var_NameClashing(set< string > &objnameset)
void Insert_One_NameSizeMap_Element(string name, hsize_t size)
bool unsupported_var_dspace
static bool cf_strict_support_type(H5DataType dtype)
static std::string trim_string(hid_t dtypeid, const std::string s, int num_sect, size_t section_size, std::vector< size_t > §_newsize)
Trim the string with many NULL terms or garbage characters to simply a string with a NULL terminator...
#define throw4(a1, a2, a3, a4)
virtual void Flatten_Obj_Name(bool)
Flatten the object name.
This class represents an HDF5 group. The group will be flattened according to the CF conventions...
static H5DataType H5type_to_H5DAPtype(hid_t h5_type_id)
Map HDF5 Datatype to the intermediate H5DAPtype for the future use.
vector< Attribute * > attrs
vector< Group * > groups
Non-root group vectors.
This class specifies the core engineering of mapping HDF5 to DAP by following CF. ...
void Handle_General_NameClashing(set< string > &objnameset, vector< T * > &objvec)
vector< Attribute * > root_attrs
Root attribute vectors.