本文整理汇总了C++中H5Tequal函数的典型用法代码示例。如果您正苦于以下问题:C++ H5Tequal函数的具体用法?C++ H5Tequal怎么用?C++ H5Tequal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了H5Tequal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EquivalentDatatypes
//-*****************************************************************************
bool EquivalentDatatypes( hid_t iA, hid_t iB )
{
if ( iA >= 0 && iB >= 0 )
{
if ( H5Tequal( iA, iB ) > 0 )
{
return true;
}
// If they're not equal, but they are both arrayed and
// both have the same super type
// and dimensions, they're equivalent
if ( H5Tget_class( iA ) == H5T_ARRAY &&
H5Tget_class( iB ) == H5T_ARRAY )
{
hid_t superA = H5Tget_super( iA );
hid_t superB = H5Tget_super( iB );
if ( superA >= 0 && superB >= 0 &&
H5Tequal( superA, superB ) > 0 )
{
Dimensions aDims;
getDatatypeArrayDims( iA, aDims );
Dimensions bDims;
getDatatypeArrayDims( iB, bDims );
if ( aDims == bDims )
{
return true;
}
}
}
}
return false;
}
示例2: memset
int H5mdfile::H5_Dread(int argc, char **argv, Tcl_Interp *interp)
{
/* Read h5-dataset and write to dataset array values */
// Allocate memeory
if(dset_data!=NULL) free(dset_data);
if(H5Tequal(dataset_type_id, H5T_NATIVE_FLOAT))
{
dset_data=(float*) Utils::malloc(dset_data_size*sizeof(float));
memset(dset_data,0,dset_data_size*sizeof(float));
}
else if(H5Tequal(dataset_type_id, H5T_NATIVE_DOUBLE))
{
dset_data=(double*) Utils::malloc(dset_data_size*sizeof(double));
memset(dset_data,0,dset_data_size*sizeof(double));
}
else if(H5Tequal(dataset_type_id, H5T_NATIVE_INT))
{
dset_data=(int*) Utils::malloc(dset_data_size*sizeof(int));
memset(dset_data,0,dset_data_size*sizeof(int));
}
else if(H5Tequal(dataset_type_id, H5T_C_S1))
{
dset_data = (h5string*) Utils::malloc(dset_data_size * sizeof(h5string));
}
else
{
Tcl_AppendResult(interp, "\nh5mdfile: No data type in H5_Dread given\n",(char *) NULL);
return TCL_ERROR;
}
// Read h5-dataset
status = H5Dread(dataset_id, dataset_type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT,dset_data);
return TCL_OK;
}
示例3: Tcl_PrintDouble
int H5mdfile::H5_read_value(int argc, char **argv,Tcl_Interp *interp)
{
/* Read value from dataset array and print it to Tcl */
// Get array index
int index=0;
if(dataset_rank>=1) index+=atoi(argv[2+dataset_rank-0]);
if(dataset_rank>=2) index+=atoi(argv[2+dataset_rank-1])*dims[dataset_rank-1];else goto label_index;
if(dataset_rank>=3) index+=atoi(argv[2+dataset_rank-2])*dims[dataset_rank-1]*dims[dataset_rank-2];else goto label_index;
if(dataset_rank>=4) index+=atoi(argv[2+dataset_rank-3])*dims[dataset_rank-1]*dims[dataset_rank-2]*dims[dataset_rank-3];else goto label_index;
if(dataset_rank>=5) index+=atoi(argv[2+dataset_rank-4])*dims[dataset_rank-1]*dims[dataset_rank-2]*dims[dataset_rank-3]*dims[dataset_rank-4];else goto label_index;
if(dataset_rank>=6) index+=atoi(argv[2+dataset_rank-5])*dims[dataset_rank-1]*dims[dataset_rank-2]*dims[dataset_rank-3]*dims[dataset_rank-4]*dims[dataset_rank-5];else goto label_index;
if(dataset_rank>=7) index+=atoi(argv[2+dataset_rank-6])*dims[dataset_rank-1]*dims[dataset_rank-2]*dims[dataset_rank-3]*dims[dataset_rank-4]*dims[dataset_rank-5]*dims[dataset_rank-6];else goto label_index;
if(dataset_rank>=8) index+=atoi(argv[2+dataset_rank-7])*dims[dataset_rank-1]*dims[dataset_rank-2]*dims[dataset_rank-3]*dims[dataset_rank-4]*dims[dataset_rank-5]*dims[dataset_rank-6]*dims[dataset_rank-7];else goto label_index;
label_index:
// Read single value from dataset array and print to Tcl
if(H5Tequal(dataset_type_id, H5T_NATIVE_FLOAT))
{
dset_data_float = static_cast<float*>(dset_data);
dset_data_singlevalue_float = dset_data_float[index];
char buffer[TCL_DOUBLE_SPACE + TCL_INTEGER_SPACE + 2];
Tcl_PrintDouble(interp, (double)dset_data_singlevalue_float, buffer);
Tcl_AppendResult(interp, buffer, (char *)NULL);
return TCL_OK;
}
if(H5Tequal(dataset_type_id, H5T_NATIVE_DOUBLE))
{
dset_data_double = static_cast<double*>(dset_data);
dset_data_singlevalue_double = dset_data_double[index];
char buffer[TCL_DOUBLE_SPACE + TCL_INTEGER_SPACE + 2];
Tcl_PrintDouble(interp, dset_data_singlevalue_double, buffer);
Tcl_AppendResult(interp, buffer, (char *)NULL);
return TCL_OK;
}
if(H5Tequal(dataset_type_id, H5T_NATIVE_INT))
{
dset_data_int = static_cast<int*>(dset_data);
dset_data_singlevalue_int = dset_data_int[index];
char buffer[TCL_DOUBLE_SPACE + TCL_INTEGER_SPACE + 2];
Tcl_PrintDouble(interp, (double)dset_data_singlevalue_int, buffer);
Tcl_AppendResult(interp, buffer, (char *)NULL);
return TCL_OK;
}
if(H5Tequal(dataset_type_id, H5T_C_S1))
{
dset_data_string = static_cast<h5string*>(dset_data);
dset_data_singlevalue_string = dset_data_string[index];
dataspace_simple_id = H5S_ALL;
dataspace_id = H5S_ALL;
Tcl_AppendResult(interp, dset_data_singlevalue_string, (char *)NULL);
return TCL_OK;
}
return TCL_ERROR;
}
示例4: isCharType
bool isCharType(hid_t dataType) {
if (H5Tequal(dataType, H5T_NATIVE_CHAR)) {
return true;
}
hid_t nativeType = H5Tget_native_type(dataType, H5T_DIR_ASCEND);
bool answer = H5Tequal(nativeType, H5T_NATIVE_CHAR);
H5Tclose(nativeType);
return answer;
}
示例5: if
std::string hdf5attribute::read_as_string()
{
std::string result;
if(H5Tequal(_type_id, H5T_NATIVE_INT16))
result = boost::lexical_cast<std::string>(read<short>());
else if(H5Tequal(_type_id, H5T_NATIVE_INT32))
result = boost::lexical_cast<std::string>(read<int>());
else if(H5Tequal(_type_id, H5T_NATIVE_UINT32))
result = boost::lexical_cast<std::string>(read<unsigned int>());
else if(H5Tequal(_type_id, H5T_NATIVE_UINT16))
result = boost::lexical_cast<std::string>(read<unsigned short>());
else if(H5Tequal(_type_id, H5T_NATIVE_UINT8))
result = boost::lexical_cast<std::string>(read<unsigned char>());
else if(H5Tequal(_type_id, H5T_NATIVE_INT8))
result = boost::lexical_cast<std::string>(read<char>());
else if(H5Tequal(_type_id, H5T_NATIVE_FLOAT))
result = boost::lexical_cast<std::string>(read<float>());
else if(H5Tequal(_type_id, H5T_NATIVE_DOUBLE))
result = boost::lexical_cast<std::string>(read<double>());
else if(H5Tget_class(_type_id) == H5T_STRING)
result = read<std::string>();
else
throw std::runtime_error("unknown type");
return result;
}
示例6: nc4_rec_find_hdf_type
/* Recursively hunt for a HDF type id. */
NC_TYPE_INFO_T *
nc4_rec_find_hdf_type(NC_GRP_INFO_T *start_grp, hid_t target_hdf_typeid)
{
NC_GRP_INFO_T *g;
NC_TYPE_INFO_T *type, *res;
htri_t equal;
assert(start_grp);
/* Does this group have the type we are searching for? */
for (type = start_grp->type; type; type = type->l.next)
{
if ((equal = H5Tequal(type->native_hdf_typeid ? type->native_hdf_typeid : type->hdf_typeid, target_hdf_typeid)) < 0)
return NULL;
if (equal)
return type;
}
/* Shake down the kids. */
if (start_grp->children)
for (g = start_grp->children; g; g = g->l.next)
if ((res = nc4_rec_find_hdf_type(g, target_hdf_typeid)))
return res;
/* Can't find it. Fate, why do you mock me? */
return NULL;
}
示例7: EquivalentDatatypes
//-*****************************************************************************
bool EquivalentDatatypes( hid_t iA, hid_t iB )
{
if ( iA >= 0 && iB >= 0 && H5Tequal( iA, iB ) > 0 )
return true;
return false;
}
示例8: main
int main(){
hid_t fprop;
hid_t fid;
hid_t vol_id = H5VL_memvol_init();
char name[1024];
// create some datatypes
hid_t tid = H5Tcreate (H5T_COMPOUND, sizeof(complex_type));
H5Tinsert(tid, "re", HOFFSET(complex_type,re), H5T_NATIVE_DOUBLE);
H5Tinsert(tid, "im", HOFFSET(complex_type,im), H5T_NATIVE_DOUBLE);
hid_t s10 = H5Tcopy(H5T_C_S1);
H5Tset_size(s10, 10);
H5Tinsert(tid, "name", HOFFSET(complex_type,name), s10);
H5Tinsert(tid, "val", HOFFSET(complex_type,val), H5T_NATIVE_INT);
// packed version of the datatype
hid_t disk_tid = H5Tcopy (tid);
H5Tpack(disk_tid);
fprop = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_vol(fprop, vol_id, &fprop);
fid = H5Fcreate("test", H5F_ACC_TRUNC, H5P_DEFAULT, fprop);
H5VLget_plugin_name(fid, name, 1024);
printf ("%s using VOL %s\n", __FILE__ , name);
assert(H5Tcommit(fid, "t_complex", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) >= 0);
assert(H5Tcommit(fid, "t_complex_p", disk_tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) >= 0);
hid_t tid_stored1 = H5Topen(fid, "t_complex", H5P_DEFAULT);
hid_t tid_stored2 = H5Topen(fid, "t_complex_p", H5P_DEFAULT);
// hid_t tid_stored3 = H5Topen(fid, "NotExisting", H5P_DEFAULT);
// assert(tid_stored3 < 0);
assert(H5Tequal(tid_stored1, tid));
assert(H5Tequal(tid_stored2, disk_tid));
H5Fclose(fid);
H5Tclose(tid);
H5Tclose(disk_tid);
H5VL_memvol_finalize();
return 0;
}
示例9: test_fps
/*-------------------------------------------------------------------------
* subroutine for test_text_dtype(): test_fps().
*-------------------------------------------------------------------------
*/
static int test_fps(void)
{
hid_t dtype;
char* dt_str;
size_t str_len;
TESTING3(" text for floating-point types");
if((dtype = H5LTtext_to_dtype("H5T_NATIVE_LDOUBLE\n", H5LT_DDL))<0)
goto out;
if(!H5Tequal(dtype, H5T_NATIVE_LDOUBLE))
goto out;
if(H5Tclose(dtype)<0)
goto out;
if((dtype = H5LTtext_to_dtype("H5T_IEEE_F32BE\n", H5LT_DDL))<0)
goto out;
if(!H5Tequal(dtype, H5T_IEEE_F32BE))
goto out;
if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
goto out;
dt_str = (char*)calloc(str_len, sizeof(char));
if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0)
goto out;
if(strcmp(dt_str, "H5T_IEEE_F32BE"))
goto out;
free(dt_str);
if(H5Tclose(dtype)<0)
goto out;
if((dtype = H5LTtext_to_dtype("H5T_IEEE_F64LE\n", H5LT_DDL))<0)
goto out;
if(!H5Tequal(dtype, H5T_IEEE_F64LE))
goto out;
if(H5Tclose(dtype)<0)
goto out;
PASSED();
return 0;
out:
H5_FAILED();
return -1;
}
示例10: test_integers
/*-------------------------------------------------------------------------
* subroutine for test_text_dtype(): test_integers().
*-------------------------------------------------------------------------
*/
static int test_integers(void)
{
hid_t dtype;
char* dt_str;
size_t str_len;
TESTING3("\n text for integer types");
if((dtype = H5LTtext_to_dtype("H5T_NATIVE_INT\n", H5LT_DDL))<0)
goto out;
if(!H5Tequal(dtype, H5T_NATIVE_INT))
goto out;
if(H5Tclose(dtype)<0)
goto out;
if((dtype = H5LTtext_to_dtype("H5T_STD_I8BE\n", H5LT_DDL))<0)
goto out;
if(!H5Tequal(dtype, H5T_STD_I8BE))
goto out;
if(H5LTdtype_to_text(dtype, NULL, H5LT_DDL, &str_len)<0)
goto out;
dt_str = (char*)calloc(str_len, sizeof(char));
if(H5LTdtype_to_text(dtype, dt_str, H5LT_DDL, &str_len)<0)
goto out;
if(strcmp(dt_str, "H5T_STD_I8BE"))
goto out;
free(dt_str);
if(H5Tclose(dtype)<0)
goto out;
if((dtype = H5LTtext_to_dtype("H5T_STD_U16LE\n", H5LT_DDL))<0)
goto out;
if(!H5Tequal(dtype, H5T_STD_U16LE))
goto out;
if(H5Tclose(dtype)<0)
goto out;
PASSED();
return 0;
out:
H5_FAILED();
return -1;
}
示例11: max_value_of_type
inline size_t max_value_of_type (hid_t type)
{
if (H5Tequal(type, H5T_NATIVE_UCHAR)) {
return std::numeric_limits<uint8_t>::max();
} else
if (H5Tequal(type, H5T_NATIVE_USHORT)) {
return std::numeric_limits<uint16_t>::max();
} else
if (H5Tequal(type, H5T_NATIVE_UINT)) {
return std::numeric_limits<uint32_t>::max();
} else
if (H5Tequal(type, H5T_NATIVE_ULONG)) {
return std::numeric_limits<uint64_t>::max();
} else {
POMAGMA_ERROR("unknown type");
}
}
示例12: compare_and_read_scalar_attribute_internal
void compare_and_read_scalar_attribute_internal(hid_t attribute_id, hid_t type_id, hid_t expected_type, void* buffer)
{
if(H5Tequal(type_id, expected_type))
{
herr_t status = H5Aread(attribute_id, type_id, buffer);
if(status >= 0)
return;
}
throw std::runtime_error("type mismatch");
}
示例13:
int H5mdfile::H5_write_value(int argc, char **argv, Tcl_Interp *interp)
{
/* Read value from Tcl and write it to dataset array */
// Get array index
int index=0;
if(dataset_rank>=1) index+=atoi(argv[4+dataset_rank-0]);
if(dataset_rank>=2) index+=atoi(argv[4+dataset_rank-1])*dims[dataset_rank-1];else goto label_index;
if(dataset_rank>=3) index+=atoi(argv[4+dataset_rank-2])*dims[dataset_rank-1]*dims[dataset_rank-2];else goto label_index;
if(dataset_rank>=4) index+=atoi(argv[4+dataset_rank-3])*dims[dataset_rank-1]*dims[dataset_rank-2]*dims[dataset_rank-3];else goto label_index;
if(dataset_rank>=5) index+=atoi(argv[4+dataset_rank-4])*dims[dataset_rank-1]*dims[dataset_rank-2]*dims[dataset_rank-3]*dims[dataset_rank-4];else goto label_index;
if(dataset_rank>=6) index+=atoi(argv[4+dataset_rank-5])*dims[dataset_rank-1]*dims[dataset_rank-2]*dims[dataset_rank-3]*dims[dataset_rank-4]*dims[dataset_rank-5];else goto label_index;
if(dataset_rank>=7) index+=atoi(argv[4+dataset_rank-6])*dims[dataset_rank-1]*dims[dataset_rank-2]*dims[dataset_rank-3]*dims[dataset_rank-4]*dims[dataset_rank-5]*dims[dataset_rank-6];else goto label_index;
if(dataset_rank>=8) index+=atoi(argv[4+dataset_rank-7])*dims[dataset_rank-1]*dims[dataset_rank-2]*dims[dataset_rank-3]*dims[dataset_rank-4]*dims[dataset_rank-5]*dims[dataset_rank-6]*dims[dataset_rank-7];else goto label_index;
label_index:
// Write single value from Tcl to dataset array
if(H5Tequal(dataset_type_id, H5T_NATIVE_FLOAT))
{
dset_data_float = static_cast<float*>(dset_data);
dset_data_float[index]=(float)atof(argv[3]);
}
if(H5Tequal(dataset_type_id, H5T_NATIVE_DOUBLE))
{
dset_data_double = static_cast<double*>(dset_data);
dset_data_double[index]=atof(argv[3]);
}
if(H5Tequal(dataset_type_id, H5T_NATIVE_INT))
{
dset_data_int = static_cast<int*>(dset_data);
dset_data_int[index]=atoi(argv[3]);
}
if(H5Tis_variable_str(dataset_type_id)!=0)
{
// dset_data_string = static_cast<h5string*>(dset_data);
// dset_data_chars=static_cast<char *>(dset_data);
dset_data_chars=(char**) dset_data;
dset_data_chars[index]=strdup(argv[3]);
}
return TCL_OK;
}
示例14: _MED21attrNumLire
med_err _MED21attrNumLire(med_idt pere,med_type_champ type,char *nom,
unsigned char *val,hid_t hdf_file)
{
med_idt attid;
med_err ret;
int type_hdf;
if ((attid = H5Aopen_name(pere,nom)) < 0)
return -1;
switch(type)
{
case MED_FLOAT64 :
if (H5Tequal(hdf_file,H5T_IEEE_F64BE))
type_hdf = H5T_IEEE_F64LE;
if (H5Tequal(hdf_file,H5T_IEEE_F64LE))
type_hdf = H5T_IEEE_F64BE;
break;
case MED_INT :
#if defined(HAVE_F77INT64)
type_hdf = H5T_NATIVE_LONG;
#else
type_hdf = H5T_NATIVE_INT;
#endif
break;
default :
return -1;
}
if ((ret = H5Aread(attid,type_hdf,val)) < 0)
return -1;
if ((ret = H5Aclose(attid)) < 0)
return -1;
return 0;
}
示例15: gridReaderHDF5_readIntoPatchForVar
extern void
gridReaderHDF5_readIntoPatchForVar(gridReader_t reader,
gridPatch_t patch,
int idxOfVar)
{
assert(reader != NULL);
assert(reader->type = GRIDIO_TYPE_HDF5);
assert(patch != NULL);
assert(idxOfVar >= 0 && idxOfVar < gridPatch_getNumVars(patch));
hid_t dataSet;
hid_t dataSpaceFile, dataTypeFile;
hid_t dataSpacePatch, dataTypePatch;
gridPointUint32_t idxLoPatch, dimsPatch;
dataVar_t var = gridPatch_getVarHandle(patch, idxOfVar);
void *data = gridPatch_getVarDataHandle(patch, idxOfVar);
gridPatch_getIdxLo(patch, idxLoPatch);
gridPatch_getDims(patch, dimsPatch);
dataSet = H5Dopen(((gridReaderHDF5_t)reader)->file,
dataVar_getName(var), H5P_DEFAULT);
dataTypeFile = H5Dget_type(dataSet);
dataSpaceFile = H5Dget_space(dataSet);
dataTypePatch = dataVar_getHDF5Datatype(var);
dataSpacePatch = gridUtilHDF5_getDataSpaceFromDims(dimsPatch);
gridUtilHDF5_selectHyperslab(dataSpaceFile, idxLoPatch, dimsPatch);
if (H5Tequal(dataTypeFile, dataTypePatch)) {
H5Dread(dataSet, dataTypeFile, dataSpacePatch,
dataSpaceFile, H5P_DEFAULT, data);
} else {
fprintf(stderr, "ERROR: Datatype in memory differs from file.\n");
diediedie(EXIT_FAILURE);
}
H5Sclose(dataSpacePatch);
H5Tclose(dataTypePatch);
H5Sclose(dataSpaceFile);
H5Tclose(dataTypeFile);
H5Dclose(dataSet);
} /* gridReaderHDF5_readIntoPatchForVar */