summaryrefslogtreecommitdiffstats
path: root/src/H5T.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5T.c')
-rw-r--r--src/H5T.c145
1 files changed, 145 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