summaryrefslogtreecommitdiffstats
path: root/src/H5T.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2002-04-05 21:29:42 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2002-04-05 21:29:42 (GMT)
commit4a800d456bbebb5c0e6b685ac2fe361596008f2a (patch)
tree9c5513dc097ed0d876d425ca02cc11089944b8c0 /src/H5T.c
parent11ee77963caca330ab9e9aa7aea9a4f62abbdf23 (diff)
downloadhdf5-4a800d456bbebb5c0e6b685ac2fe361596008f2a.zip
hdf5-4a800d456bbebb5c0e6b685ac2fe361596008f2a.tar.gz
hdf5-4a800d456bbebb5c0e6b685ac2fe361596008f2a.tar.bz2
[svn-r5144]
Purpose: New Function Description: H5Tget_member_index was added to compound and enumeration data type to query member's index by its name. Platforms tested: SunOS 5.8
Diffstat (limited to 'src/H5T.c')
-rw-r--r--src/H5T.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/H5T.c b/src/H5T.c
index bcfe1fc..e75dfd4 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -3408,6 +3408,64 @@ H5Tget_member_name(hid_t type_id, int membno)
/*-------------------------------------------------------------------------
+ * Function: H5Tget_member_index
+ *
+ * Purpose: Returns the index of a member in a compound or enumeration
+ * data type by given name.Members are stored in no particular
+ * order with numbers 0 through N-1 where N is the value
+ * returned by H5Tget_nmembers().
+ *
+ * Return: Success: index of the member if exists.
+ * Failure: -1.
+ *
+ * Programmer: Raymond Lu
+ * Thursday, April 4, 2002
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+int
+H5Tget_member_index(hid_t type_id, const char *name)
+{
+ H5T_t *dt = NULL;
+ int ret_value = FAIL;
+ int nmembs, i;
+
+ FUNC_ENTER(H5Tget_member_index, NULL);
+
+ /* Check arguments */
+ assert(name);
+ if(H5I_DATATYPE!=H5I_get_type(type_id) || NULL==(dt=H5I_object(type_id)))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+
+ /* Locate member by name */
+ switch (dt->type) {
+ case H5T_COMPOUND:
+ nmembs = dt->u.compnd.nmembs;
+ for(i=0; i<nmembs; i++) {
+ if(!HDstrcmp(dt->u.compnd.memb[i].name, name))
+ HGOTO_DONE(i);
+ }
+ break;
+ case H5T_ENUM:
+ nmembs = dt->u.enumer.nmembs;
+ for(i=0; i<nmembs; i++) {
+ if(!HDstrcmp(dt->u.enumer.name[i], name))
+ HGOTO_DONE(i);
+ }
+ break;
+ default:
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "operation not supported for this type");
+ }
+
+done:
+ FUNC_LEAVE(ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
* Function: H5Tget_member_offset
*
* Purpose: Returns the byte offset of the beginning of a member with