From 0eb88a48d7d25ec28e97d008eecf6e62e4915ca8 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 13 Nov 2000 16:26:15 -0500 Subject: [svn-r2886] Purpose: Backward compatibility additions Description: Created HDF5 v1.2 compatibility API functions (H5Tget_member_dims & H5Tinsert_array) which use the newer array datatypes underneath, but should ease user's transition to the 1.4 version of the library. Platforms tested: FreeBSD 4.1.1 (hawkwind) --- src/H5T.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/H5Tpublic.h | 9 ++++ src/H5config.h.in | 3 ++ 3 files changed, 157 insertions(+) diff --git a/src/H5T.c b/src/H5T.c index e9feb57..596efe6 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -3311,6 +3311,67 @@ H5Tget_member_offset(hid_t type_id, int membno) FUNC_LEAVE(offset); } +#ifdef WANT_H5_V1_2_COMPAT + +/*------------------------------------------------------------------------- + * Function: H5Tget_member_dims + * + * Purpose: Returns the dimensionality of the member. The dimensions and + * permuation vector are returned through arguments DIMS and + * PERM, both arrays of at least four elements. Either (or even + * both) may be null pointers. + * + * Return: Success: A value between zero and four, inclusive. + * + * Failure: Negative + * + * Programmer: Robb Matzke + * Wednesday, January 7, 1998 + * + * Modifications: + * Moved into compatibility section for v1.2 functions and patched to + * use new array datatypes - QAK, 11/13/00 + * + *------------------------------------------------------------------------- + */ +int +H5Tget_member_dims(hid_t type_id, int membno, + size_t dims[]/*out*/, int perm[]/*out*/) +{ + H5T_t *dt = NULL; + intn ndims, i; + + FUNC_ENTER(H5Tget_member_dims, FAIL); + H5TRACE4("Is","iIsxx",type_id,membno,dims,perm); + + /* Check args */ + if (H5I_DATATYPE != H5I_get_type(type_id) || + NULL == (dt = H5I_object(type_id)) || + H5T_COMPOUND != dt->type) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type"); + } + if (membno < 0 || membno >= dt->u.compnd.nmembs) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number"); + } + + /* Check if this field is an array datatype */ + if(dt->u.compnd.memb[membno].type->type==H5T_ARRAY) { + /* Value */ + ndims = dt->u.compnd.memb[membno].type->u.array.ndims; + for (i = 0; i < ndims; i++) { + if (dims) + dims[i] = dt->u.compnd.memb[membno].type->u.array.dim[i]; + if (perm) + perm[i] = dt->u.compnd.memb[membno].type->u.array.perm[i]; + } + } /* end if */ + else + ndims=0; + + FUNC_LEAVE(ndims); +} +#endif /* WANT_H5_V1_2_COMPAT */ + /*------------------------------------------------------------------------- * Function: H5Tget_member_class @@ -3469,6 +3530,90 @@ H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id) FUNC_LEAVE(SUCCEED); } +#ifdef WANT_H5_V1_2_COMPAT + +/*------------------------------------------------------------------------- + * Function: H5Tinsert_array + * + * Purpose: Adds another member to the compound data type PARENT_ID. The + * new member has a NAME which must be unique within the + * compound data type. The OFFSET argument defines the start of + * the member in an instance of the compound data type and + * MEMBER_ID is the type of the new member. The member is an + * array with NDIMS dimensionality and the size of the array is + * DIMS. The total member size should be relatively small. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Tuesday, July 7, 1998 + * + * Modifications: + * Moved into compatibility section for v1.2 functions and patched to + * use new array datatypes - QAK, 11/13/00 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Tinsert_array(hid_t parent_id, const char *name, size_t offset, + int ndims, const size_t dim[/*ndims*/], const int *perm, + hid_t member_id) +{ + H5T_t *parent = NULL; /*the compound parent data type */ + H5T_t *member = NULL; /*the atomic member type */ + H5T_t *array = NULL; /*the array type */ + hsize_t newdim[H5S_MAX_RANK]; /* Array to hold the dimensions */ + intn i; + + FUNC_ENTER(H5Tinsert_array, FAIL); + H5TRACE7("e","iszIs*[a3]z*Isi",parent_id,name,offset,ndims,dim,perm, + member_id); + + /* Check args */ + if (H5I_DATATYPE != H5I_get_type(parent_id) || + NULL == (parent = H5I_object(parent_id)) || + H5T_COMPOUND != parent->type) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type"); + } + if (H5T_STATE_TRANSIENT!=parent->state) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parent type read-only"); + } + if (!name || !*name) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no member name"); + } + if (ndims<0 || ndims>4) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dimensionality"); + } + if (ndims>0 && !dim) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified"); + } + for (i=0; i