summaryrefslogtreecommitdiffstats
path: root/src/H5T.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2000-11-09 21:45:27 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2000-11-09 21:45:27 (GMT)
commite32c78d023348c70255c3835a4f904862414fb0d (patch)
treebec2363f2d5cd8811522f80114e70efa72d2c196 /src/H5T.c
parent796b4daf83110a1e61f754eeb0ab7be625b0e98a (diff)
downloadhdf5-e32c78d023348c70255c3835a4f904862414fb0d.zip
hdf5-e32c78d023348c70255c3835a4f904862414fb0d.tar.gz
hdf5-e32c78d023348c70255c3835a4f904862414fb0d.tar.bz2
[svn-r2843] Purpose:
New Feature Description: Added array datatype to library. See documentation at: http://hdf.ncsa.uiuc.edu/HDF5/planning/DP/ArrayType.html for complete details on the impact to the library. Solution: Changes to the base library include removing the ability of compound datatype fields to be an array (they can use an array type for the field, to duplicate the functionality) and adding in the new array datatype everywhere appropriate. (I hope :-) Platforms tested: FreeBSD 4.1.1 (hawkwind)
Diffstat (limited to 'src/H5T.c')
-rw-r--r--src/H5T.c1493
1 files changed, 807 insertions, 686 deletions
diff --git a/src/H5T.c b/src/H5T.c
index af81e52..10b0521 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -245,7 +245,8 @@ H5T_init_interface(void)
{
H5T_t *dt = NULL;
hid_t fixedpt=-1, floatpt=-1, string=-1, compound=-1, enum_type=-1;
- hid_t vlen_type=-1, bitfield=-1;
+ hid_t vlen_type=-1, bitfield=-1, array_type=-1;
+ hsize_t dim[1]={1}; /* Dimension info for array datatype */
herr_t status;
herr_t ret_value=FAIL;
@@ -947,6 +948,7 @@ H5T_init_interface(void)
compound = H5Tcreate(H5T_COMPOUND, 1);
enum_type = H5Tcreate(H5T_ENUM, 1);
vlen_type = H5Tvlen_create(H5T_NATIVE_INT);
+ array_type = H5Tarray_create(H5T_NATIVE_INT,1,dim,NULL);
status = 0;
status |= H5Tregister(H5T_PERS_SOFT, "i_i",
@@ -979,6 +981,9 @@ H5T_init_interface(void)
status |= H5Tregister(H5T_PERS_SOFT, "vlen",
vlen_type, vlen_type,
H5T_conv_vlen);
+ status |= H5Tregister(H5T_PERS_SOFT, "array",
+ array_type, array_type,
+ H5T_conv_array);
status |= H5Tregister(H5T_PERS_HARD, "u32le_f64le",
H5T_STD_U32LE_g, H5T_IEEE_F64LE_g,
@@ -1963,9 +1968,9 @@ H5Tset_size(hid_t type_id, size_t size)
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"operation not allowed after members are defined");
}
- if (H5T_COMPOUND==dt->type) {
+ if (H5T_COMPOUND==dt->type || H5T_ARRAY==dt->type) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for compound data types");
+ "operation not defined for this datatype");
}
/* Do the work */
@@ -2012,7 +2017,7 @@ H5Tget_order(hid_t type_id)
"not a data type");
}
if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type) {
+ if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY ==dt->type) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_ORDER_ERROR,
"operation not defined for specified data type");
}
@@ -2065,7 +2070,7 @@ H5Tset_order(hid_t type_id, H5T_order_t order)
"operation not allowed after members are defined");
}
if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type) {
+ if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_ORDER_ERROR,
"operation not defined for specified data type");
}
@@ -2114,7 +2119,7 @@ H5Tget_precision(hid_t type_id)
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data type");
}
if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type) {
+ if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_ORDER_ERROR,
"operation not defined for specified data type");
}
@@ -2240,7 +2245,7 @@ H5Tget_offset(hid_t type_id)
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
}
if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type) {
+ if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"operation not defined for specified data type");
}
@@ -2359,7 +2364,7 @@ H5Tget_pad(hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/)
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type) {
+ if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"operation not defined for specified data type");
}
@@ -2413,7 +2418,7 @@ H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb)
"operation not allowed after members are defined");
}
if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type) {
+ if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"operation not defined for specified data type");
}
@@ -3308,56 +3313,6 @@ H5Tget_member_offset(hid_t type_id, int membno)
/*-------------------------------------------------------------------------
- * 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:
- *
- *-------------------------------------------------------------------------
- */
-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");
- }
-
- /* Value */
- ndims = dt->u.compnd.memb[membno].ndims;
- for (i = 0; i < ndims; i++) {
- if (dims) dims[i] = dt->u.compnd.memb[membno].dim[i];
- if (perm) perm[i] = dt->u.compnd.memb[membno].perm[i];
- }
-
- FUNC_LEAVE(ndims);
-}
-
-
-/*-------------------------------------------------------------------------
* Function: H5Tget_member_type
*
* Purpose: Returns the data type of the specified member. The caller
@@ -3467,79 +3422,8 @@ H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id)
}
/* Insert */
- if (H5T_struct_insert(parent, name, offset, 0, NULL, NULL, member) < 0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
- "unable to insert member");
- }
-
- FUNC_LEAVE(SUCCEED);
-}
-
-
-/*-------------------------------------------------------------------------
- * 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:
- *
- *-------------------------------------------------------------------------
- */
-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 */
- 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");
- }
- }
- 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");
- }
-
- /* Insert */
- if (H5T_struct_insert(parent, name, offset, ndims, dim, perm, member)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
+ if (H5T_insert(parent, name, offset, member) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
"unable to insert member");
}
@@ -4583,58 +4467,62 @@ H5T_create(H5T_class_t type, size_t size)
assert(size > 0);
switch (type) {
- case H5T_INTEGER:
- case H5T_FLOAT:
- case H5T_TIME:
- case H5T_STRING:
- case H5T_BITFIELD:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL,
- "type class is not appropriate - use H5Tcopy()");
+ case H5T_INTEGER:
+ case H5T_FLOAT:
+ case H5T_TIME:
+ case H5T_STRING:
+ case H5T_BITFIELD:
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL,
+ "type class is not appropriate - use H5Tcopy()");
- case H5T_OPAQUE:
- case H5T_COMPOUND:
- if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
- dt->type = type;
- break;
+ case H5T_OPAQUE:
+ case H5T_COMPOUND:
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ dt->type = type;
+ break;
- case H5T_ENUM:
- if (sizeof(char)==size) {
- subtype = H5T_NATIVE_SCHAR_g;
- } else if (sizeof(short)==size) {
- subtype = H5T_NATIVE_SHORT_g;
- } else if (sizeof(int)==size) {
- subtype = H5T_NATIVE_INT_g;
- } else if (sizeof(long)==size) {
- subtype = H5T_NATIVE_LONG_g;
- } else if (sizeof(long_long)==size) {
- subtype = H5T_NATIVE_LLONG_g;
- } else {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
- "no applicable native integer type");
- }
- if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
- dt->type = type;
- if (NULL==(dt->parent=H5T_copy(H5I_object(subtype),
- H5T_COPY_ALL))) {
- H5FL_FREE(H5T_t,dt);
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
- "unable to copy base data type");
- }
- break;
+ case H5T_ENUM:
+ if (sizeof(char)==size) {
+ subtype = H5T_NATIVE_SCHAR_g;
+ } else if (sizeof(short)==size) {
+ subtype = H5T_NATIVE_SHORT_g;
+ } else if (sizeof(int)==size) {
+ subtype = H5T_NATIVE_INT_g;
+ } else if (sizeof(long)==size) {
+ subtype = H5T_NATIVE_LONG_g;
+ } else if (sizeof(long_long)==size) {
+ subtype = H5T_NATIVE_LLONG_g;
+ } else {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
+ "no applicable native integer type");
+ }
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ dt->type = type;
+ if (NULL==(dt->parent=H5T_copy(H5I_object(subtype),
+ H5T_COPY_ALL))) {
+ H5FL_FREE(H5T_t,dt);
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
+ "unable to copy base data type");
+ }
+ break;
- case H5T_VLEN: /* Variable length datatype */
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL,
- "base type required - use H5Tvlen_create()");
+ case H5T_VLEN: /* Variable length datatype */
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL,
+ "base type required - use H5Tvlen_create()");
- default:
- HRETURN_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, NULL,
- "unknown data type class");
+ case H5T_ARRAY: /* Array datatype */
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL,
+ "base type required - use H5Tarray_create()");
+
+ default:
+ HRETURN_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, NULL,
+ "unknown data type class");
}
dt->ent.header = HADDR_UNDEF;
@@ -4808,147 +4696,167 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
/* check args */
assert(old_dt);
- /* copy */
+ /* Allocate space */
if (NULL==(new_dt = H5FL_ALLOC(H5T_t,0))) {
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
"memory allocation failed");
}
+
+ /* Copy actual information */
*new_dt = *old_dt;
- /* copy parent */
- if (new_dt->parent) {
+ /* Copy parent information */
+ if (new_dt->parent)
new_dt->parent = H5T_copy(new_dt->parent, method);
- }
+ /* Check what sort of copy we are making */
switch (method) {
- case H5T_COPY_TRANSIENT:
- /*
- * Return an unlocked transient type.
- */
- new_dt->state = H5T_STATE_TRANSIENT;
- HDmemset (&(new_dt->ent), 0, sizeof(new_dt->ent));
- new_dt->ent.header = HADDR_UNDEF;
- break;
-
- case H5T_COPY_ALL:
- /*
- * Return a transient type (locked or unlocked) or an unopened named
- * type. Immutable transient types are degraded to read-only.
- */
- if (H5T_STATE_OPEN==new_dt->state) {
- new_dt->state = H5T_STATE_NAMED;
- } else if (H5T_STATE_IMMUTABLE==new_dt->state) {
- new_dt->state = H5T_STATE_RDONLY;
- }
- break;
+ case H5T_COPY_TRANSIENT:
+ /*
+ * Return an unlocked transient type.
+ */
+ new_dt->state = H5T_STATE_TRANSIENT;
+ HDmemset (&(new_dt->ent), 0, sizeof(new_dt->ent));
+ new_dt->ent.header = HADDR_UNDEF;
+ break;
+
+ case H5T_COPY_ALL:
+ /*
+ * Return a transient type (locked or unlocked) or an unopened named
+ * type. Immutable transient types are degraded to read-only.
+ */
+ if (H5T_STATE_OPEN==new_dt->state) {
+ new_dt->state = H5T_STATE_NAMED;
+ } else if (H5T_STATE_IMMUTABLE==new_dt->state) {
+ new_dt->state = H5T_STATE_RDONLY;
+ }
+ break;
- case H5T_COPY_REOPEN:
- /*
- * Return a transient type (locked or unlocked) or an opened named
- * type.
- */
- if (H5F_addr_defined(new_dt->ent.header)) {
- if (H5O_open (&(new_dt->ent))<0) {
- H5FL_FREE (H5T_t,new_dt);
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL,
- "unable to reopen named data type");
- }
- new_dt->state = H5T_STATE_OPEN;
- }
- break;
- }
+ case H5T_COPY_REOPEN:
+ /*
+ * Return a transient type (locked or unlocked) or an opened named
+ * type.
+ */
+ if (H5F_addr_defined(new_dt->ent.header)) {
+ if (H5O_open (&(new_dt->ent))<0) {
+ H5FL_FREE (H5T_t,new_dt);
+ HRETURN_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL,
+ "unable to reopen named data type");
+ }
+ new_dt->state = H5T_STATE_OPEN;
+ }
+ break;
+ } /* end switch */
- if (H5T_COMPOUND == new_dt->type) {
- intn accum_change=0; /* Amount of change in the offset of the fields */
+ switch(new_dt->type) {
+ case H5T_COMPOUND:
+ {
+ intn accum_change=0; /* Amount of change in the offset of the fields */
+
+ /*
+ * Copy all member fields to new type, then overwrite the
+ * name and type fields of each new member with copied values.
+ * That is, H5T_copy() is a deep copy.
+ */
+ new_dt->u.compnd.memb = H5MM_malloc(new_dt->u.compnd.nalloc *
+ sizeof(H5T_cmemb_t));
+ if (NULL==new_dt->u.compnd.memb) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
- /*
- * Copy all member fields to new type, then overwrite the
- * name and type fields of each new member with copied values.
- * That is, H5T_copy() is a deep copy.
- */
- new_dt->u.compnd.memb = H5MM_malloc(new_dt->u.compnd.nalloc *
- sizeof(H5T_cmemb_t));
- if (NULL==new_dt->u.compnd.memb) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ HDmemcpy(new_dt->u.compnd.memb, old_dt->u.compnd.memb,
+ new_dt->u.compnd.nmembs * sizeof(H5T_cmemb_t));
+
+ for (i=0; i<new_dt->u.compnd.nmembs; i++) {
+ intn j;
+ intn old_match;
+
+ s = new_dt->u.compnd.memb[i].name;
+ new_dt->u.compnd.memb[i].name = H5MM_xstrdup(s);
+ tmp = H5T_copy (old_dt->u.compnd.memb[i].type, method);
+ new_dt->u.compnd.memb[i].type = tmp;
+
+ /* Apply the accumulated size change to the offset of the field */
+ new_dt->u.compnd.memb[i].offset += accum_change;
+
+ if(old_dt->u.compnd.sorted != H5T_SORT_VALUE) {
+ for (old_match=-1, j=0; j<old_dt->u.compnd.nmembs; j++) {
+ if(!HDstrcmp(new_dt->u.compnd.memb[i].name,old_dt->u.compnd.memb[j].name)) {
+ old_match=j;
+ break;
+ } /* end if */
+ } /* end for */
+
+ /* check if we couldn't find a match */
+ if(old_match<0)
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "fields in datatype corrupted");
+ } /* end if */
+ else {
+ old_match=i;
+ } /* end else */
+
+ /* If the field changed size, add that change to the accumulated size change */
+ if(new_dt->u.compnd.memb[i].type->size != old_dt->u.compnd.memb[old_match].type->size) {
+ /* Adjust the size of the member */
+ new_dt->u.compnd.memb[i].size = (old_dt->u.compnd.memb[old_match].size*tmp->size)/old_dt->u.compnd.memb[old_match].type->size;
+
+ accum_change += (new_dt->u.compnd.memb[i].type->size - old_dt->u.compnd.memb[old_match].type->size);
+ } /* end if */
+ } /* end for */
+
+ /* Apply the accumulated size change to the size of the compound struct */
+ new_dt->size += accum_change;
- HDmemcpy(new_dt->u.compnd.memb, old_dt->u.compnd.memb,
- new_dt->u.compnd.nmembs * sizeof(H5T_cmemb_t));
-
- for (i=0; i<new_dt->u.compnd.nmembs; i++) {
- intn j;
- intn old_match;
-
- s = new_dt->u.compnd.memb[i].name;
- new_dt->u.compnd.memb[i].name = H5MM_xstrdup(s);
- tmp = H5T_copy (old_dt->u.compnd.memb[i].type, method);
- new_dt->u.compnd.memb[i].type = tmp;
-
- /* Apply the accumulated size change to the offset of the field */
- new_dt->u.compnd.memb[i].offset += accum_change;
-
- if(old_dt->u.compnd.sorted != H5T_SORT_VALUE) {
- for (old_match=-1, j=0; j<old_dt->u.compnd.nmembs; j++) {
- if(!HDstrcmp(new_dt->u.compnd.memb[i].name,old_dt->u.compnd.memb[j].name)) {
- old_match=j;
- break;
- } /* end if */
- } /* end for */
-
- /* check if we couldn't find a match */
- if(old_match<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "fields in datatype corrupted");
- } /* end if */
- else {
- old_match=i;
- } /* end else */
-
- /* If the field changed size, add that change to the accumulated size change */
- if(new_dt->u.compnd.memb[i].type->size != old_dt->u.compnd.memb[old_match].type->size) {
- /* Adjust the size of the member */
- new_dt->u.compnd.memb[i].size = (old_dt->u.compnd.memb[old_match].size*tmp->size)/old_dt->u.compnd.memb[old_match].type->size;
-
- accum_change += (new_dt->u.compnd.memb[i].type->size - old_dt->u.compnd.memb[old_match].type->size);
- } /* end if */
- } /* end for */
-
- /* Apply the accumulated size change to the size of the compound struct */
- new_dt->size += accum_change;
-
- } else if (H5T_ENUM == new_dt->type) {
- /*
- * Copy all member fields to new type, then overwrite the name fields
- * of each new member with copied values. That is, H5T_copy() is a
- * deep copy.
- */
- new_dt->u.enumer.name = H5MM_malloc(new_dt->u.enumer.nalloc *
- sizeof(char*));
- new_dt->u.enumer.value = H5MM_malloc(new_dt->u.enumer.nalloc *
- new_dt->size);
- if (NULL==new_dt->u.enumer.value) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
- HDmemcpy(new_dt->u.enumer.value, old_dt->u.enumer.value,
- new_dt->u.enumer.nmembs * new_dt->size);
- for (i=0; i<new_dt->u.enumer.nmembs; i++) {
- s = old_dt->u.enumer.name[i];
- new_dt->u.enumer.name[i] = H5MM_xstrdup(s);
- }
- } else if (H5T_VLEN == new_dt->type) {
- if(method==H5T_COPY_TRANSIENT || method==H5T_COPY_REOPEN) {
- /* H5T_copy converts any VL type into a memory VL type */
- if (H5T_vlen_mark(new_dt, NULL, H5T_VLEN_MEMORY)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid VL location");
}
- }
- } else if (H5T_OPAQUE == new_dt->type) {
- /*
- * Copy the tag name.
- */
- new_dt->u.opaque.tag = HDstrdup(new_dt->u.opaque.tag);
- }
+ break;
+
+ case H5T_ENUM:
+ /*
+ * Copy all member fields to new type, then overwrite the name fields
+ * of each new member with copied values. That is, H5T_copy() is a
+ * deep copy.
+ */
+ new_dt->u.enumer.name = H5MM_malloc(new_dt->u.enumer.nalloc *
+ sizeof(char*));
+ new_dt->u.enumer.value = H5MM_malloc(new_dt->u.enumer.nalloc *
+ new_dt->size);
+ if (NULL==new_dt->u.enumer.value) {
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
+ "memory allocation failed");
+ }
+ HDmemcpy(new_dt->u.enumer.value, old_dt->u.enumer.value,
+ new_dt->u.enumer.nmembs * new_dt->size);
+ for (i=0; i<new_dt->u.enumer.nmembs; i++) {
+ s = old_dt->u.enumer.name[i];
+ new_dt->u.enumer.name[i] = H5MM_xstrdup(s);
+ }
+ break;
+
+ case H5T_VLEN:
+ if(method==H5T_COPY_TRANSIENT || method==H5T_COPY_REOPEN) {
+ /* H5T_copy converts any VL type into a memory VL type */
+ if (H5T_vlen_mark(new_dt, NULL, H5T_VLEN_MEMORY)<0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid VL location");
+ }
+ }
+ break;
+
+ case H5T_OPAQUE:
+ /*
+ * Copy the tag name.
+ */
+ new_dt->u.opaque.tag = HDstrdup(new_dt->u.opaque.tag);
+ break;
+
+ case H5T_ARRAY:
+ /* Re-compute the array's size, in case it's base type changed size */
+ new_dt->size=new_dt->u.array.nelem*new_dt->parent->size;
+ break;
+
+ default:
+ break;
+ } /* end switch */
FUNC_LEAVE(new_dt);
}
@@ -5183,7 +5091,7 @@ H5T_is_atomic(const H5T_t *dt)
FUNC_ENTER(H5T_is_atomic, FAIL);
assert(dt);
- if (H5T_COMPOUND!=dt->type && H5T_ENUM!=dt->type && H5T_VLEN!=dt->type && H5T_OPAQUE!=dt->type) {
+ if (H5T_COMPOUND!=dt->type && H5T_ENUM!=dt->type && H5T_VLEN!=dt->type && H5T_OPAQUE!=dt->type && H5T_ARRAY!=dt->type) {
ret_value = TRUE;
} else {
ret_value = FALSE;
@@ -5260,8 +5168,9 @@ H5T_set_size(H5T_t *dt, size_t size)
switch (dt->type) {
case H5T_COMPOUND:
+ case H5T_ARRAY:
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to set size of a compound data type");
+ "unable to set size of specified data type");
case H5T_INTEGER:
case H5T_TIME:
@@ -5412,7 +5321,7 @@ H5T_set_precision(H5T_t *dt, size_t prec)
}
dt->size = dt->parent->size;
} else {
- if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type) {
+ if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"operation not defined for specified data type");
@@ -5527,7 +5436,7 @@ H5T_set_offset(H5T_t *dt, size_t offset)
}
dt->size = dt->parent->size;
} else {
- if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type) {
+ if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type) {
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
"operation not defined for specified data type");
} else if (H5T_ENUM==dt->type) {
@@ -5545,7 +5454,7 @@ H5T_set_offset(H5T_t *dt, size_t offset)
/*-------------------------------------------------------------------------
- * Function: H5T_struct_insert
+ * Function: H5T_insert
*
* Purpose: Adds a new MEMBER to the compound data type PARENT. The new
* member will have a NAME that is unique within PARENT and an
@@ -5558,18 +5467,17 @@ H5T_set_offset(H5T_t *dt, size_t offset)
* Monday, December 8, 1997
*
* Modifications:
+ * Took out arrayness parameters - QAK, 10/6/00
*
*-------------------------------------------------------------------------
*/
herr_t
-H5T_struct_insert(H5T_t *parent, const char *name, size_t offset, intn ndims,
- const size_t *dim, const intn *perm, const H5T_t *member)
+H5T_insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member)
{
intn idx, i;
size_t total_size;
- hbool_t *perm_check=NULL;
- FUNC_ENTER(H5T_struct_insert, FAIL);
+ FUNC_ENTER(H5T_insert, FAIL);
/* check args */
assert(parent && H5T_COMPOUND == parent->type);
@@ -5586,7 +5494,7 @@ H5T_struct_insert(H5T_t *parent, const char *name, size_t offset, intn ndims,
}
/* Does the new member overlap any existing member ? */
- for (total_size=member->size, i=0; i<ndims; i++) total_size *= dim[i];
+ total_size=member->size;
for (i=0; i<parent->u.compnd.nmembs; i++) {
if ((offset <= parent->u.compnd.memb[i].offset &&
offset + total_size > parent->u.compnd.memb[i].offset) ||
@@ -5598,39 +5506,18 @@ H5T_struct_insert(H5T_t *parent, const char *name, size_t offset, intn ndims,
}
}
- /* Are permutations correct? */
- if (ndims>0 && perm) {
- if (NULL==(perm_check=H5MM_calloc(ndims*sizeof(hbool_t)))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
- for (i=0; i<ndims; i++) {
- if (perm[i]<0 || perm[i]>=ndims) {
- H5MM_xfree(perm_check);
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "invalid permutation vector (out of range)");
- }
- if (perm_check[perm[i]]) {
- H5MM_xfree(perm_check);
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "invalid permutation vector (duplicate value)");
- }
- perm_check[perm[i]] = TRUE;
- }
- perm_check = H5MM_xfree(perm_check);
- }
-
/* Increase member array if necessary */
if (parent->u.compnd.nmembs >= parent->u.compnd.nalloc) {
- size_t na = parent->u.compnd.nalloc + H5T_COMPND_INC;
- H5T_cmemb_t *x = H5MM_realloc (parent->u.compnd.memb,
- na * sizeof(H5T_cmemb_t));
- if (!x) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
- parent->u.compnd.nalloc = (intn)na;
- parent->u.compnd.memb = x;
+ size_t na = parent->u.compnd.nalloc + H5T_COMPND_INC;
+ H5T_cmemb_t *x = H5MM_realloc (parent->u.compnd.memb,
+ na * sizeof(H5T_cmemb_t));
+
+ if (!x) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "memory allocation failed");
+ }
+ parent->u.compnd.nalloc = (intn)na;
+ parent->u.compnd.memb = x;
}
/* Add member to end of member array */
@@ -5638,12 +5525,7 @@ H5T_struct_insert(H5T_t *parent, const char *name, size_t offset, intn ndims,
parent->u.compnd.memb[idx].name = H5MM_xstrdup(name);
parent->u.compnd.memb[idx].offset = offset;
parent->u.compnd.memb[idx].size = total_size;
- parent->u.compnd.memb[idx].ndims = ndims;
parent->u.compnd.memb[idx].type = H5T_copy (member, H5T_COPY_ALL);
- for (i=0; i<ndims; i++) {
- parent->u.compnd.memb[idx].dim[i] = dim[i];
- parent->u.compnd.memb[idx].perm[i] = perm ? perm[i] : i;
- }
parent->u.compnd.sorted = H5T_SORT_NONE;
parent->u.compnd.nmembs++;
@@ -5655,6 +5537,10 @@ H5T_struct_insert(H5T_t *parent, const char *name, size_t offset, intn ndims,
if(member->type==H5T_VLEN || member->force_conv==TRUE)
parent->force_conv=TRUE;
+ /* Set the flag for this compound type, if the field is an array */
+ if(member->type==H5T_ARRAY)
+ parent->u.compnd.has_array=TRUE;
+
FUNC_LEAVE(SUCCEED);
}
@@ -6183,316 +6069,337 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
if (tmp>0) HGOTO_DONE(1);
}
- if (H5T_COMPOUND == dt1->type) {
- /*
- * Compound data types...
- */
- if (dt1->u.compnd.nmembs < dt2->u.compnd.nmembs) HGOTO_DONE(-1);
- if (dt1->u.compnd.nmembs > dt2->u.compnd.nmembs) HGOTO_DONE(1);
-
- /* Build an index for each type so the names are sorted */
- if (NULL==(idx1 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(intn))) ||
- NULL==(idx2 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(intn)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0,
- "memory allocation failed");
- }
- for (i=0; i<dt1->u.compnd.nmembs; i++) idx1[i] = idx2[i] = i;
- for (i=dt1->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
- for (j=0, swapped=FALSE; j<i; j++) {
- if (HDstrcmp(dt1->u.compnd.memb[idx1[j]].name,
- dt1->u.compnd.memb[idx1[j+1]].name) > 0) {
- tmp = idx1[j];
- idx1[j] = idx1[j+1];
- idx1[j+1] = tmp;
- swapped = TRUE;
- }
- }
- }
- for (i=dt2->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
- for (j=0, swapped=FALSE; j<i; j++) {
- if (HDstrcmp(dt2->u.compnd.memb[idx2[j]].name,
- dt2->u.compnd.memb[idx2[j+1]].name) > 0) {
- tmp = idx2[j];
- idx2[j] = idx2[j+1];
- idx2[j+1] = tmp;
- swapped = TRUE;
- }
- }
- }
+ switch(dt1->type) {
+ case H5T_COMPOUND:
+ /*
+ * Compound data types...
+ */
+ if (dt1->u.compnd.nmembs < dt2->u.compnd.nmembs)
+ HGOTO_DONE(-1);
+ if (dt1->u.compnd.nmembs > dt2->u.compnd.nmembs)
+ HGOTO_DONE(1);
+
+ /* Build an index for each type so the names are sorted */
+ if (NULL==(idx1 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(intn))) ||
+ NULL==(idx2 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(intn)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0,
+ "memory allocation failed");
+ }
+ for (i=0; i<dt1->u.compnd.nmembs; i++)
+ idx1[i] = idx2[i] = i;
+ for (i=dt1->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
+ for (j=0, swapped=FALSE; j<i; j++) {
+ if (HDstrcmp(dt1->u.compnd.memb[idx1[j]].name,
+ dt1->u.compnd.memb[idx1[j+1]].name) > 0) {
+ tmp = idx1[j];
+ idx1[j] = idx1[j+1];
+ idx1[j+1] = tmp;
+ swapped = TRUE;
+ }
+ }
+ }
+ for (i=dt2->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
+ for (j=0, swapped=FALSE; j<i; j++) {
+ if (HDstrcmp(dt2->u.compnd.memb[idx2[j]].name,
+ dt2->u.compnd.memb[idx2[j+1]].name) > 0) {
+ tmp = idx2[j];
+ idx2[j] = idx2[j+1];
+ idx2[j+1] = tmp;
+ swapped = TRUE;
+ }
+ }
+ }
#ifdef H5T_DEBUG
- /* I don't quite trust the code above yet :-) --RPM */
- for (i=0; i<dt1->u.compnd.nmembs-1; i++) {
- assert(HDstrcmp(dt1->u.compnd.memb[idx1[i]].name,
- dt1->u.compnd.memb[idx1[i + 1]].name));
- assert(HDstrcmp(dt2->u.compnd.memb[idx2[i]].name,
- dt2->u.compnd.memb[idx2[i + 1]].name));
- }
+ /* I don't quite trust the code above yet :-) --RPM */
+ for (i=0; i<dt1->u.compnd.nmembs-1; i++) {
+ assert(HDstrcmp(dt1->u.compnd.memb[idx1[i]].name,
+ dt1->u.compnd.memb[idx1[i + 1]].name));
+ assert(HDstrcmp(dt2->u.compnd.memb[idx2[i]].name,
+ dt2->u.compnd.memb[idx2[i + 1]].name));
+ }
#endif
- /* Compare the members */
- for (i=0; i<dt1->u.compnd.nmembs; i++) {
- tmp = HDstrcmp(dt1->u.compnd.memb[idx1[i]].name,
- dt2->u.compnd.memb[idx2[i]].name);
- if (tmp < 0) HGOTO_DONE(-1);
- if (tmp > 0) HGOTO_DONE(1);
-
- if (dt1->u.compnd.memb[idx1[i]].offset <
- dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(-1);
- if (dt1->u.compnd.memb[idx1[i]].offset >
- dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(1);
-
- if (dt1->u.compnd.memb[idx1[i]].size <
- dt2->u.compnd.memb[idx2[i]].size) HGOTO_DONE(-1);
- if (dt1->u.compnd.memb[idx1[i]].size >
- dt2->u.compnd.memb[idx2[i]].size) HGOTO_DONE(1);
-
- if (dt1->u.compnd.memb[idx1[i]].ndims <
- dt2->u.compnd.memb[idx2[i]].ndims) HGOTO_DONE(-1);
- if (dt1->u.compnd.memb[idx1[i]].ndims >
- dt2->u.compnd.memb[idx2[i]].ndims) HGOTO_DONE(1);
-
- for (j=0; j<dt1->u.compnd.memb[idx1[i]].ndims; j++) {
- if (dt1->u.compnd.memb[idx1[i]].dim[j] <
- dt2->u.compnd.memb[idx2[i]].dim[j]) HGOTO_DONE(-1);
- if (dt1->u.compnd.memb[idx1[i]].dim[j] >
- dt2->u.compnd.memb[idx2[i]].dim[j]) HGOTO_DONE(1);
- }
-
- for (j=0; j<dt1->u.compnd.memb[idx1[i]].ndims; j++) {
- if (dt1->u.compnd.memb[idx1[i]].perm[j] <
- dt2->u.compnd.memb[idx2[i]].perm[j]) HGOTO_DONE(-1);
- if (dt1->u.compnd.memb[idx1[i]].perm[j] >
- dt2->u.compnd.memb[idx2[i]].perm[j]) HGOTO_DONE(1);
- }
+ /* Compare the members */
+ for (i=0; i<dt1->u.compnd.nmembs; i++) {
+ tmp = HDstrcmp(dt1->u.compnd.memb[idx1[i]].name,
+ dt2->u.compnd.memb[idx2[i]].name);
+ if (tmp < 0)
+ HGOTO_DONE(-1);
+ if (tmp > 0)
+ HGOTO_DONE(1);
+
+ if (dt1->u.compnd.memb[idx1[i]].offset <
+ dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(-1);
+ if (dt1->u.compnd.memb[idx1[i]].offset >
+ dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE(1);
+
+ if (dt1->u.compnd.memb[idx1[i]].size <
+ dt2->u.compnd.memb[idx2[i]].size) HGOTO_DONE(-1);
+ if (dt1->u.compnd.memb[idx1[i]].size >
+ dt2->u.compnd.memb[idx2[i]].size) HGOTO_DONE(1);
+
+ tmp = H5T_cmp(dt1->u.compnd.memb[idx1[i]].type,
+ dt2->u.compnd.memb[idx2[i]].type);
+ if (tmp < 0) HGOTO_DONE(-1);
+ if (tmp > 0) HGOTO_DONE(1);
+ }
+ break;
- tmp = H5T_cmp(dt1->u.compnd.memb[idx1[i]].type,
- dt2->u.compnd.memb[idx2[i]].type);
- if (tmp < 0) HGOTO_DONE(-1);
- if (tmp > 0) HGOTO_DONE(1);
- }
-
- } else if (H5T_ENUM==dt1->type) {
- /*
- * Enumeration data types...
- */
- if (dt1->u.enumer.nmembs < dt2->u.enumer.nmembs) HGOTO_DONE(-1);
- if (dt1->u.enumer.nmembs > dt2->u.enumer.nmembs) HGOTO_DONE(1);
-
- /* Build an index for each type so the names are sorted */
- if (NULL==(idx1 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(intn))) ||
- NULL==(idx2 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(intn)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0,
- "memory allocation failed");
- }
- for (i=0; i<dt1->u.enumer.nmembs; i++) idx1[i] = idx2[i] = i;
- for (i=dt1->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
- for (j=0, swapped=FALSE; j<i; j++) {
- if (HDstrcmp(dt1->u.enumer.name[idx1[j]],
- dt1->u.enumer.name[idx1[j+1]]) > 0) {
- tmp = idx1[j];
- idx1[j] = idx1[j+1];
- idx1[j+1] = tmp;
- swapped = TRUE;
- }
- }
- }
- for (i=dt2->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
- for (j=0, swapped=FALSE; j<i; j++) {
- if (HDstrcmp(dt2->u.enumer.name[idx2[j]],
- dt2->u.enumer.name[idx2[j+1]]) > 0) {
- tmp = idx2[j];
- idx2[j] = idx2[j+1];
- idx2[j+1] = tmp;
- swapped = TRUE;
- }
- }
- }
+ case H5T_ENUM:
+ /*
+ * Enumeration data types...
+ */
+ if (dt1->u.enumer.nmembs < dt2->u.enumer.nmembs)
+ HGOTO_DONE(-1);
+ if (dt1->u.enumer.nmembs > dt2->u.enumer.nmembs)
+ HGOTO_DONE(1);
+
+ /* Build an index for each type so the names are sorted */
+ if (NULL==(idx1 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(intn))) ||
+ NULL==(idx2 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(intn)))) {
+ HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0,
+ "memory allocation failed");
+ }
+ for (i=0; i<dt1->u.enumer.nmembs; i++)
+ idx1[i] = idx2[i] = i;
+ for (i=dt1->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
+ for (j=0, swapped=FALSE; j<i; j++) {
+ if (HDstrcmp(dt1->u.enumer.name[idx1[j]],
+ dt1->u.enumer.name[idx1[j+1]]) > 0) {
+ tmp = idx1[j];
+ idx1[j] = idx1[j+1];
+ idx1[j+1] = tmp;
+ swapped = TRUE;
+ }
+ }
+ }
+ for (i=dt2->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
+ for (j=0, swapped=FALSE; j<i; j++) {
+ if (HDstrcmp(dt2->u.enumer.name[idx2[j]],
+ dt2->u.enumer.name[idx2[j+1]]) > 0) {
+ tmp = idx2[j];
+ idx2[j] = idx2[j+1];
+ idx2[j+1] = tmp;
+ swapped = TRUE;
+ }
+ }
+ }
#ifdef H5T_DEBUG
- /* I don't quite trust the code above yet :-) --RPM */
- for (i=0; i<dt1->u.enumer.nmembs-1; i++) {
- assert(HDstrcmp(dt1->u.enumer.name[idx1[i]],
- dt1->u.enumer.name[idx1[i+1]]));
- assert(HDstrcmp(dt2->u.enumer.name[idx2[i]],
- dt2->u.enumer.name[idx2[i+1]]));
- }
+ /* I don't quite trust the code above yet :-) --RPM */
+ for (i=0; i<dt1->u.enumer.nmembs-1; i++) {
+ assert(HDstrcmp(dt1->u.enumer.name[idx1[i]],
+ dt1->u.enumer.name[idx1[i+1]]));
+ assert(HDstrcmp(dt2->u.enumer.name[idx2[i]],
+ dt2->u.enumer.name[idx2[i+1]]));
+ }
#endif
- /* Compare the members */
- base_size = dt1->parent->size;
- for (i=0; i<dt1->u.enumer.nmembs; i++) {
- tmp = HDstrcmp(dt1->u.enumer.name[idx1[i]],
- dt2->u.enumer.name[idx2[i]]);
- if (tmp<0) HGOTO_DONE(-1);
- if (tmp>0) HGOTO_DONE(1);
-
- tmp = HDmemcmp(dt1->u.enumer.value+idx1[i]*base_size,
- dt2->u.enumer.value+idx2[i]*base_size,
- base_size);
- if (tmp<0) HGOTO_DONE(-1);
- if (tmp>0) HGOTO_DONE(1);
- }
-
- } else if (H5T_VLEN==dt1->type) {
- assert(dt1->u.vlen.type>H5T_VLEN_BADTYPE && dt1->u.vlen.type<H5T_VLEN_MAXTYPE);
- assert(dt2->u.vlen.type>H5T_VLEN_BADTYPE && dt2->u.vlen.type<H5T_VLEN_MAXTYPE);
- assert(dt1->u.vlen.loc>H5T_VLEN_BADLOC && dt1->u.vlen.loc<H5T_VLEN_MAXLOC);
- assert(dt2->u.vlen.loc>H5T_VLEN_BADLOC && dt2->u.vlen.loc<H5T_VLEN_MAXLOC);
-
- /* Arbitrarily sort sequence VL datatypes before string VL datatypes */
- if (dt1->u.vlen.type==H5T_VLEN_SEQUENCE &&
- dt2->u.vlen.type==H5T_VLEN_STRING) {
- HGOTO_DONE(-1);
- } else if (dt1->u.vlen.type==H5T_VLEN_STRING &&
- dt2->u.vlen.type==H5T_VLEN_SEQUENCE) {
- HGOTO_DONE(1);
- }
- /* Arbitrarily sort VL datatypes in memory before disk */
- if (dt1->u.vlen.loc==H5T_VLEN_MEMORY &&
- dt2->u.vlen.loc==H5T_VLEN_DISK) {
- HGOTO_DONE(-1);
- } else if (dt1->u.vlen.loc==H5T_VLEN_DISK &&
- dt2->u.vlen.loc==H5T_VLEN_MEMORY) {
- HGOTO_DONE(1);
- }
-
- } else if (H5T_OPAQUE==dt1->type) {
- HGOTO_DONE(HDstrcmp(dt1->u.opaque.tag,dt2->u.opaque.tag));
-
- } else {
- /*
- * Atomic datatypes...
- */
- if (dt1->u.atomic.order < dt2->u.atomic.order) HGOTO_DONE(-1);
- if (dt1->u.atomic.order > dt2->u.atomic.order) HGOTO_DONE(1);
-
- if (dt1->u.atomic.prec < dt2->u.atomic.prec) HGOTO_DONE(-1);
- if (dt1->u.atomic.prec > dt2->u.atomic.prec) HGOTO_DONE(1);
-
- if (dt1->u.atomic.offset < dt2->u.atomic.offset) HGOTO_DONE(-1);
- if (dt1->u.atomic.offset > dt2->u.atomic.offset) HGOTO_DONE(1);
-
- if (dt1->u.atomic.lsb_pad < dt2->u.atomic.lsb_pad) HGOTO_DONE(-1);
- if (dt1->u.atomic.lsb_pad > dt2->u.atomic.lsb_pad) HGOTO_DONE(1);
-
- if (dt1->u.atomic.msb_pad < dt2->u.atomic.msb_pad) HGOTO_DONE(-1);
- if (dt1->u.atomic.msb_pad > dt2->u.atomic.msb_pad) HGOTO_DONE(1);
-
- switch (dt1->type) {
- case H5T_INTEGER:
- if (dt1->u.atomic.u.i.sign < dt2->u.atomic.u.i.sign) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.i.sign > dt2->u.atomic.u.i.sign) {
- HGOTO_DONE(1);
- }
- break;
-
- case H5T_FLOAT:
- if (dt1->u.atomic.u.f.sign < dt2->u.atomic.u.f.sign) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.f.sign > dt2->u.atomic.u.f.sign) {
- HGOTO_DONE(1);
- }
-
- if (dt1->u.atomic.u.f.epos < dt2->u.atomic.u.f.epos) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.f.epos > dt2->u.atomic.u.f.epos) {
- HGOTO_DONE(1);
- }
-
- if (dt1->u.atomic.u.f.esize <
- dt2->u.atomic.u.f.esize) HGOTO_DONE(-1);
- if (dt1->u.atomic.u.f.esize >
- dt2->u.atomic.u.f.esize) HGOTO_DONE(1);
-
- if (dt1->u.atomic.u.f.ebias <
- dt2->u.atomic.u.f.ebias) HGOTO_DONE(-1);
- if (dt1->u.atomic.u.f.ebias >
- dt2->u.atomic.u.f.ebias) HGOTO_DONE(1);
-
- if (dt1->u.atomic.u.f.mpos < dt2->u.atomic.u.f.mpos) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.f.mpos > dt2->u.atomic.u.f.mpos) {
- HGOTO_DONE(1);
- }
-
- if (dt1->u.atomic.u.f.msize <
- dt2->u.atomic.u.f.msize) HGOTO_DONE(-1);
- if (dt1->u.atomic.u.f.msize >
- dt2->u.atomic.u.f.msize) HGOTO_DONE(1);
-
- if (dt1->u.atomic.u.f.norm < dt2->u.atomic.u.f.norm) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.f.norm > dt2->u.atomic.u.f.norm) {
- HGOTO_DONE(1);
- }
-
- if (dt1->u.atomic.u.f.pad < dt2->u.atomic.u.f.pad) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.f.pad > dt2->u.atomic.u.f.pad) {
- HGOTO_DONE(1);
- }
-
- break;
-
- case H5T_TIME: /* order and precision are checked above */
- /*void */
- break;
-
- case H5T_STRING:
- if (dt1->u.atomic.u.s.cset < dt2->u.atomic.u.s.cset) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.s.cset > dt2->u.atomic.u.s.cset) {
- HGOTO_DONE(1);
- }
-
- if (dt1->u.atomic.u.s.pad < dt2->u.atomic.u.s.pad) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.s.pad > dt2->u.atomic.u.s.pad) {
- HGOTO_DONE(1);
- }
-
- break;
+ /* Compare the members */
+ base_size = dt1->parent->size;
+ for (i=0; i<dt1->u.enumer.nmembs; i++) {
+ tmp = HDstrcmp(dt1->u.enumer.name[idx1[i]],
+ dt2->u.enumer.name[idx2[i]]);
+ if (tmp<0) HGOTO_DONE(-1);
+ if (tmp>0) HGOTO_DONE(1);
+
+ tmp = HDmemcmp(dt1->u.enumer.value+idx1[i]*base_size,
+ dt2->u.enumer.value+idx2[i]*base_size,
+ base_size);
+ if (tmp<0) HGOTO_DONE(-1);
+ if (tmp>0) HGOTO_DONE(1);
+ }
+ break;
- case H5T_BITFIELD:
- /*void */
- break;
+ case H5T_VLEN:
+ assert(dt1->u.vlen.type>H5T_VLEN_BADTYPE && dt1->u.vlen.type<H5T_VLEN_MAXTYPE);
+ assert(dt2->u.vlen.type>H5T_VLEN_BADTYPE && dt2->u.vlen.type<H5T_VLEN_MAXTYPE);
+ assert(dt1->u.vlen.loc>H5T_VLEN_BADLOC && dt1->u.vlen.loc<H5T_VLEN_MAXLOC);
+ assert(dt2->u.vlen.loc>H5T_VLEN_BADLOC && dt2->u.vlen.loc<H5T_VLEN_MAXLOC);
+
+ /* Arbitrarily sort sequence VL datatypes before string VL datatypes */
+ if (dt1->u.vlen.type==H5T_VLEN_SEQUENCE &&
+ dt2->u.vlen.type==H5T_VLEN_STRING) {
+ HGOTO_DONE(-1);
+ } else if (dt1->u.vlen.type==H5T_VLEN_STRING &&
+ dt2->u.vlen.type==H5T_VLEN_SEQUENCE) {
+ HGOTO_DONE(1);
+ }
+ /* Arbitrarily sort VL datatypes in memory before disk */
+ if (dt1->u.vlen.loc==H5T_VLEN_MEMORY &&
+ dt2->u.vlen.loc==H5T_VLEN_DISK) {
+ HGOTO_DONE(-1);
+ } else if (dt1->u.vlen.loc==H5T_VLEN_DISK &&
+ dt2->u.vlen.loc==H5T_VLEN_MEMORY) {
+ HGOTO_DONE(1);
+ }
+ break;
- case H5T_REFERENCE:
- if (dt1->u.atomic.u.r.rtype < dt2->u.atomic.u.r.rtype) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.r.rtype > dt2->u.atomic.u.r.rtype) {
- HGOTO_DONE(1);
- }
+ case H5T_OPAQUE:
+ HGOTO_DONE(HDstrcmp(dt1->u.opaque.tag,dt2->u.opaque.tag));
+
+ case H5T_ARRAY:
+ if (dt1->u.array.ndims < dt2->u.array.ndims)
+ HGOTO_DONE(-1);
+ if (dt1->u.array.ndims > dt2->u.array.ndims)
+ HGOTO_DONE(1);
+
+ for (j=0; j<dt1->u.array.ndims; j++) {
+ if (dt1->u.array.dim[j] < dt2->u.array.dim[j])
+ HGOTO_DONE(-1);
+ if (dt1->u.array.dim[j] > dt2->u.array.dim[j])
+ HGOTO_DONE(1);
+ }
- switch(dt1->u.atomic.u.r.rtype) {
- case H5R_OBJECT:
- case H5R_DATASET_REGION:
- /* Does this need more to distinguish it? -QAK 11/30/98 */
- /*void */
- break;
+ for (j=0; j<dt1->u.array.ndims; j++) {
+ if (dt1->u.array.perm[j] < dt2->u.array.perm[j])
+ HGOTO_DONE(-1);
+ if (dt1->u.array.perm[j] > dt2->u.array.perm[j])
+ HGOTO_DONE(1);
+ }
- default:
- assert("not implemented yet" && 0);
- }
- break;
+ tmp = H5T_cmp(dt1->parent, dt2->parent);
+ if (tmp < 0)
+ HGOTO_DONE(-1);
+ if (tmp > 0)
+ HGOTO_DONE(1);
+ break;
- default:
- assert("not implemented yet" && 0);
- }
- }
+ default:
+ /*
+ * Atomic datatypes...
+ */
+ if (dt1->u.atomic.order < dt2->u.atomic.order) HGOTO_DONE(-1);
+ if (dt1->u.atomic.order > dt2->u.atomic.order) HGOTO_DONE(1);
+
+ if (dt1->u.atomic.prec < dt2->u.atomic.prec) HGOTO_DONE(-1);
+ if (dt1->u.atomic.prec > dt2->u.atomic.prec) HGOTO_DONE(1);
+
+ if (dt1->u.atomic.offset < dt2->u.atomic.offset) HGOTO_DONE(-1);
+ if (dt1->u.atomic.offset > dt2->u.atomic.offset) HGOTO_DONE(1);
+
+ if (dt1->u.atomic.lsb_pad < dt2->u.atomic.lsb_pad) HGOTO_DONE(-1);
+ if (dt1->u.atomic.lsb_pad > dt2->u.atomic.lsb_pad) HGOTO_DONE(1);
+
+ if (dt1->u.atomic.msb_pad < dt2->u.atomic.msb_pad) HGOTO_DONE(-1);
+ if (dt1->u.atomic.msb_pad > dt2->u.atomic.msb_pad) HGOTO_DONE(1);
+
+ switch (dt1->type) {
+ case H5T_INTEGER:
+ if (dt1->u.atomic.u.i.sign < dt2->u.atomic.u.i.sign) {
+ HGOTO_DONE(-1);
+ }
+ if (dt1->u.atomic.u.i.sign > dt2->u.atomic.u.i.sign) {
+ HGOTO_DONE(1);
+ }
+ break;
+
+ case H5T_FLOAT:
+ if (dt1->u.atomic.u.f.sign < dt2->u.atomic.u.f.sign) {
+ HGOTO_DONE(-1);
+ }
+ if (dt1->u.atomic.u.f.sign > dt2->u.atomic.u.f.sign) {
+ HGOTO_DONE(1);
+ }
+
+ if (dt1->u.atomic.u.f.epos < dt2->u.atomic.u.f.epos) {
+ HGOTO_DONE(-1);
+ }
+ if (dt1->u.atomic.u.f.epos > dt2->u.atomic.u.f.epos) {
+ HGOTO_DONE(1);
+ }
+
+ if (dt1->u.atomic.u.f.esize <
+ dt2->u.atomic.u.f.esize) HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.esize >
+ dt2->u.atomic.u.f.esize) HGOTO_DONE(1);
+
+ if (dt1->u.atomic.u.f.ebias <
+ dt2->u.atomic.u.f.ebias) HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.ebias >
+ dt2->u.atomic.u.f.ebias) HGOTO_DONE(1);
+
+ if (dt1->u.atomic.u.f.mpos < dt2->u.atomic.u.f.mpos) {
+ HGOTO_DONE(-1);
+ }
+ if (dt1->u.atomic.u.f.mpos > dt2->u.atomic.u.f.mpos) {
+ HGOTO_DONE(1);
+ }
+
+ if (dt1->u.atomic.u.f.msize <
+ dt2->u.atomic.u.f.msize) HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.msize >
+ dt2->u.atomic.u.f.msize) HGOTO_DONE(1);
+
+ if (dt1->u.atomic.u.f.norm < dt2->u.atomic.u.f.norm) {
+ HGOTO_DONE(-1);
+ }
+ if (dt1->u.atomic.u.f.norm > dt2->u.atomic.u.f.norm) {
+ HGOTO_DONE(1);
+ }
+
+ if (dt1->u.atomic.u.f.pad < dt2->u.atomic.u.f.pad) {
+ HGOTO_DONE(-1);
+ }
+ if (dt1->u.atomic.u.f.pad > dt2->u.atomic.u.f.pad) {
+ HGOTO_DONE(1);
+ }
+
+ break;
+
+ case H5T_TIME: /* order and precision are checked above */
+ /*void */
+ break;
+
+ case H5T_STRING:
+ if (dt1->u.atomic.u.s.cset < dt2->u.atomic.u.s.cset) {
+ HGOTO_DONE(-1);
+ }
+ if (dt1->u.atomic.u.s.cset > dt2->u.atomic.u.s.cset) {
+ HGOTO_DONE(1);
+ }
+
+ if (dt1->u.atomic.u.s.pad < dt2->u.atomic.u.s.pad) {
+ HGOTO_DONE(-1);
+ }
+ if (dt1->u.atomic.u.s.pad > dt2->u.atomic.u.s.pad) {
+ HGOTO_DONE(1);
+ }
+
+ break;
+
+ case H5T_BITFIELD:
+ /*void */
+ break;
+
+ case H5T_REFERENCE:
+ if (dt1->u.atomic.u.r.rtype < dt2->u.atomic.u.r.rtype) {
+ HGOTO_DONE(-1);
+ }
+ if (dt1->u.atomic.u.r.rtype > dt2->u.atomic.u.r.rtype) {
+ HGOTO_DONE(1);
+ }
+
+ switch(dt1->u.atomic.u.r.rtype) {
+ case H5R_OBJECT:
+ case H5R_DATASET_REGION:
+ /* Does this need more to distinguish it? -QAK 11/30/98 */
+ /*void */
+ break;
+
+ default:
+ assert("not implemented yet" && 0);
+ }
+ break;
+
+ default:
+ assert("not implemented yet" && 0);
+ }
+ break;
+ } /* end switch */
- done:
+done:
H5MM_xfree(idx1);
H5MM_xfree(idx2);
@@ -6873,6 +6780,255 @@ H5T_entof (H5T_t *dt)
}
+/*--------------------------------------------------------------------------
+ NAME
+ H5T_get_ref_type
+ PURPOSE
+ Retrieves the type of reference for a datatype
+ USAGE
+ H5R_type_t H5Tget_ref_type(dt)
+ H5T_t *dt; IN: datatype pointer for the reference datatype
+
+ RETURNS
+ Success: A reference type defined in H5Rpublic.h
+ Failure: H5R_BADTYPE
+ DESCRIPTION
+ Given a reference datatype object, this function returns the reference type
+ of the datatype.
+ GLOBAL VARIABLES
+ COMMENTS, BUGS, ASSUMPTIONS
+ EXAMPLES
+ REVISION LOG
+--------------------------------------------------------------------------*/
+H5R_type_t
+H5T_get_ref_type(const H5T_t *dt)
+{
+ H5R_type_t ret_value = H5R_BADTYPE;
+
+ FUNC_ENTER(H5T_get_ref_type, H5R_BADTYPE);
+
+ assert(dt);
+
+ if(dt->type==H5T_REFERENCE)
+ ret_value=dt->u.atomic.u.r.rtype;
+
+#ifdef LATER
+done:
+#endif /* LATER */
+ FUNC_LEAVE(ret_value);
+} /* end H5T_get_ref_type() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tarray_create
+ *
+ * Purpose: Create a new array data type based on the specified BASE_TYPE.
+ * The type is an array with NDIMS dimensionality and the size of the
+ * array is DIMS. The total member size should be relatively small.
+ * PERM is currently unimplemented and unused, but is designed to contain
+ * the dimension permutation from C order.
+ * Array datatypes are currently limited to H5S_MAX_RANK number of
+ * dimensions and must have the number of dimensions set greater than
+ * 0. (i.e. 0 > ndims <= H5S_MAX_RANK) All dimensions sizes must be greater
+ * than 0 also.
+ *
+ * Return: Success: ID of new array data type
+ *
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, Oct 26, 2000
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5Tarray_create(hid_t base_id, int ndims, const hsize_t dim[/* ndims */],
+ const int UNUSED perm[/* ndims */])
+{
+ H5T_t *base = NULL; /* base data type */
+ H5T_t *dt = NULL; /* new array data type */
+ intn i; /* local index variable */
+ hid_t ret_value = FAIL; /* return value */
+
+ FUNC_ENTER(H5Tarray_create, FAIL);
+ H5TRACE1("i","i",base_id);
+
+ /* Check args */
+ if (ndims<1 || ndims>H5S_MAX_RANK)
+ 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]>0))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "zero-sized dimension specified");
+ if (H5I_DATATYPE!=H5I_get_type(base_id) || NULL==(base=H5I_object(base_id)))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype");
+
+ /* Create the actual array datatype */
+ if ((dt=H5T_array_create(base,ndims,dim,perm))==NULL)
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create datatype");
+
+ /* Atomize the type */
+ if ((ret_value=H5I_register(H5I_DATATYPE, dt))<0)
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype");
+
+ FUNC_LEAVE(ret_value);
+} /* end H5Tarray_create */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_array_create
+ *
+ * Purpose: Internal routine to create a new array data type based on the
+ * specified BASE_TYPE. The type is an array with NDIMS dimensionality
+ * and the size of the array is DIMS. PERM is currently unimplemented
+ * and unused, but is designed to contain the dimension permutation from
+ * C order. Array datatypes are currently limited to H5S_MAX_RANK number
+ * of * dimensions.
+ *
+ * Return: Success: ID of new array data type
+ *
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, Oct 26, 2000
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+H5T_t *
+H5T_array_create(H5T_t *base, int ndims, const hsize_t dim[/* ndims */],
+ const int perm[/* ndims */])
+{
+ H5T_t *ret_value = NULL; /*new array data type */
+ intn i; /* local index variable */
+
+ FUNC_ENTER(H5T_array_create, NULL);
+
+ assert(base);
+ assert(ndims>0 && ndims<=H5S_MAX_RANK);
+ assert(dim);
+
+ /* Build new type */
+ if (NULL==(ret_value = H5FL_ALLOC(H5T_t,1)))
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+
+ ret_value->ent.header = HADDR_UNDEF;
+ ret_value->type = H5T_ARRAY;
+
+ /* Copy the base type of the array */
+ ret_value->parent = H5T_copy(base, H5T_COPY_ALL);
+
+ /* Set the array parameters */
+ ret_value->u.array.ndims = ndims;
+
+ /* Copy the array dimensions & compute the # of elements in the array */
+ for(i=0, ret_value->u.array.nelem=1; i<ndims; i++) {
+ ret_value->u.array.dim[i] = dim[i];
+ ret_value->u.array.nelem *= dim[i];
+ } /* end for */
+
+ /* Copy the dimension permutations */
+ for(i=0; i<ndims; i++)
+ ret_value->u.array.perm[i] = perm ? perm[i] : i;
+
+ /* Set the array's size (number of elements * element datatype's size) */
+ ret_value->size = ret_value->parent->size * ret_value->u.array.nelem;
+
+ /*
+ * Set the "force conversion" flag if a VL base datatype is used or
+ * or if any components of the base datatype are VL types.
+ */
+ if(base->type==H5T_VLEN || base->force_conv==TRUE)
+ ret_value->force_conv=TRUE;
+
+ FUNC_LEAVE(ret_value);
+} /* end H5T_array_create */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tget_array_ndims
+ *
+ * Purpose: Query the number of dimensions for an array datatype.
+ *
+ * Return: Success: Number of dimensions of the array datatype
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Monday, November 6, 2000
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+H5Tget_array_ndims(hid_t type_id)
+{
+ H5T_t *dt = NULL; /* pointer to array data type */
+ int ret_value = FAIL; /* return value */
+
+ FUNC_ENTER(H5Tget_array_ndims, FAIL);
+
+ /* Check args */
+ if (H5I_DATATYPE!=H5I_get_type(type_id) || NULL==(dt=H5I_object(type_id)))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object");
+ if(dt->type!=H5T_ARRAY)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype");
+
+ /* Retrieve the number of dimensions */
+ ret_value=dt->u.array.ndims;
+
+ FUNC_LEAVE(ret_value);
+} /* end H5Tget_array_ndims */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Tget_array_dims
+ *
+ * Purpose: Query the sizes of dimensions for an array datatype.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Monday, November 6, 2000
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Tget_array_dims(hid_t type_id, hsize_t dims[], int perm[])
+{
+ H5T_t *dt = NULL; /* pointer to array data type */
+ herr_t ret_value = SUCCEED; /* return value */
+ intn i; /* Local index variable */
+
+ FUNC_ENTER(H5Tget_array_dims, FAIL);
+
+ /* Check args */
+ if (H5I_DATATYPE!=H5I_get_type(type_id) || NULL==(dt=H5I_object(type_id)))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object");
+ if(dt->type!=H5T_ARRAY)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype");
+
+ /* Retrieve the sizes of the dimensions */
+ if(dims)
+ for(i=0; i<dt->u.array.ndims; i++)
+ dims[i]=dt->u.array.dim[i];
+
+ /* Retrieve the dimension permutations */
+ if(perm)
+ for(i=0; i<dt->u.array.ndims; i++)
+ perm[i]=dt->u.array.perm[i];
+
+ FUNC_LEAVE(ret_value);
+} /* end H5Tget_array_dims */
+
+
/*-------------------------------------------------------------------------
* Function: H5T_print_stats
*
@@ -6956,7 +7112,7 @@ herr_t
H5T_debug(H5T_t *dt, FILE *stream)
{
const char *s1="", *s2="";
- int i, j;
+ int i;
size_t k, base_size;
uint64_t tmp;
@@ -7106,6 +7262,7 @@ H5T_debug(H5T_t *dt, FILE *stream)
fprintf(stream, "\n\"%s\" @%lu",
dt->u.compnd.memb[i].name,
(unsigned long) (dt->u.compnd.memb[i].offset));
+#ifdef OLD_WAY
if (dt->u.compnd.memb[i].ndims) {
fprintf(stream, "[");
for (j = 0; j < dt->u.compnd.memb[i].ndims; j++) {
@@ -7114,6 +7271,7 @@ H5T_debug(H5T_t *dt, FILE *stream)
}
fprintf(stream, "]");
}
+#endif /* OLD_WAY */
fprintf(stream, " ");
H5T_debug(dt->u.compnd.memb[i].type, stream);
}
@@ -7144,41 +7302,4 @@ H5T_debug(H5T_t *dt, FILE *stream)
FUNC_LEAVE(SUCCEED);
}
-
-/*--------------------------------------------------------------------------
- NAME
- H5T_get_ref_type
- PURPOSE
- Retrieves the type of reference for a datatype
- USAGE
- H5R_type_t H5Tget_ref_type(dt)
- H5T_t *dt; IN: datatype pointer for the reference datatype
-
- RETURNS
- Success: A reference type defined in H5Rpublic.h
- Failure: H5R_BADTYPE
- DESCRIPTION
- Given a reference datatype object, this function returns the reference type
- of the datatype.
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-H5R_type_t
-H5T_get_ref_type(const H5T_t *dt)
-{
- H5R_type_t ret_value = H5R_BADTYPE;
-
- FUNC_ENTER(H5T_get_ref_type, H5R_BADTYPE);
-
- assert(dt);
-
- if(dt->type==H5T_REFERENCE)
- ret_value=dt->u.atomic.u.r.rtype;
-#ifdef LATER
-done:
-#endif /* LATER */
- FUNC_LEAVE(ret_value);
-} /* end H5T_get_ref_type() */