summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2000-11-13 21:26:15 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2000-11-13 21:26:15 (GMT)
commit0eb88a48d7d25ec28e97d008eecf6e62e4915ca8 (patch)
tree69aa5d909a1eed2a9a3bb2d61acdb60ec4a17552
parent2da4c9cfaa3cd17c3d189e4650097e8a2e07f010 (diff)
downloadhdf5-0eb88a48d7d25ec28e97d008eecf6e62e4915ca8.zip
hdf5-0eb88a48d7d25ec28e97d008eecf6e62e4915ca8.tar.gz
hdf5-0eb88a48d7d25ec28e97d008eecf6e62e4915ca8.tar.bz2
[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)
-rw-r--r--src/H5T.c145
-rw-r--r--src/H5Tpublic.h9
-rw-r--r--src/H5config.h.in3
3 files changed, 157 insertions, 0 deletions
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<ndims; i++) {
+ if (dim[i]<1) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dimension");
+ }
+ newdim[i]=dim[i];
+ }
+ if (H5I_DATATYPE != H5I_get_type(member_id) ||
+ NULL == (member = H5I_object(member_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+
+ /* Create temporary array datatype for inserting field */
+ if ((array=H5T_array_create(member,ndims,newdim,perm))==NULL)
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create array datatype");
+
+ /* Insert */
+ if (H5T_insert(parent, name, offset, array) < 0)
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "unable to insert member");
+
+ /* Close array datatype */
+ if (H5T_close(array) < 0)
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "unable to close array type");
+
+ FUNC_LEAVE(SUCCEED);
+}
+#endif /* WANT_H5_V1_2_COMPAT */
+
/*-------------------------------------------------------------------------
* Function: H5Tpack
diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h
index 798ebeb..4257f3c 100644
--- a/src/H5Tpublic.h
+++ b/src/H5Tpublic.h
@@ -458,6 +458,11 @@ __DLL__ htri_t H5Tcommitted(hid_t type_id);
/* Operations defined on compound data types */
__DLL__ herr_t H5Tinsert(hid_t parent_id, const char *name, size_t offset,
hid_t member_id);
+#ifdef WANT_H5_V1_2_COMPAT
+__DLL__ herr_t H5Tinsert_array(hid_t parent_id, const char *name,
+ size_t offset, int ndims, const size_t dim[],
+ const int *perm, hid_t member_id);
+#endif /* WANT_H5_V1_2_COMPAT */
__DLL__ herr_t H5Tpack(hid_t type_id);
/* Operations defined on enumeration data types */
@@ -501,6 +506,10 @@ __DLL__ H5T_str_t H5Tget_strpad(hid_t type_id);
__DLL__ int H5Tget_nmembers(hid_t type_id);
__DLL__ char *H5Tget_member_name(hid_t type_id, int membno);
__DLL__ size_t H5Tget_member_offset(hid_t type_id, int membno);
+#ifdef WANT_H5_V1_2_COMPAT
+__DLL__ int H5Tget_member_dims(hid_t type_id, int membno, size_t dims[]/*out*/,
+ int perm[]/*out*/);
+#endif /* WANT_H5_V1_2_COMPAT */
__DLL__ H5T_class_t H5Tget_member_class(hid_t type_id, int membno);
__DLL__ hid_t H5Tget_member_type(hid_t type_id, int membno);
__DLL__ herr_t H5Tget_member_value(hid_t type_id, int membno,
diff --git a/src/H5config.h.in b/src/H5config.h.in
index e1ee542..4f20275 100644
--- a/src/H5config.h.in
+++ b/src/H5config.h.in
@@ -47,6 +47,9 @@
/* Define if it's safe to use `long long' for hsize_t and hssize_t */
#undef HAVE_LARGE_HSIZET
+/* Define if the HDF5 v1.2 compatibility functions are to be compiled in */
+#undef WANT_H5_V1_2_COMPAT
+
/* Width for printf() for type `long long' or `__int64', us. `ll' */
#undef PRINTF_LL_WIDTH