summaryrefslogtreecommitdiffstats
path: root/c++/src/H5EnumType.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2002-05-16 22:41:00 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2002-05-16 22:41:00 (GMT)
commit567c04276158059089d64e0e9fd5b9c7e1b8d7ba (patch)
tree2476a14df8ac8ab258d18a4b71caaf4e5d024407 /c++/src/H5EnumType.cpp
parent97a2a55cf4a27e6fc15a43f3ffaba9f90dc42be4 (diff)
downloadhdf5-567c04276158059089d64e0e9fd5b9c7e1b8d7ba.zip
hdf5-567c04276158059089d64e0e9fd5b9c7e1b8d7ba.tar.gz
hdf5-567c04276158059089d64e0e9fd5b9c7e1b8d7ba.tar.bz2
[svn-r5428]
Purpose: New Feature - per library change Description: Added the new member function getMemberIndex to classes EnumType and CompType to match the new C API H5Tget_member_index. Given the name of a member of an enumeration or compound datatype, this new function queries the index of the member. Platforms: SunOS 5.7 (arabica) Linux 6.2 (eirene)
Diffstat (limited to 'c++/src/H5EnumType.cpp')
-rw-r--r--c++/src/H5EnumType.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/c++/src/H5EnumType.cpp b/c++/src/H5EnumType.cpp
index 5bf9ece..f10ff18 100644
--- a/c++/src/H5EnumType.cpp
+++ b/c++/src/H5EnumType.cpp
@@ -108,6 +108,35 @@ void EnumType::valueOf( const char* name, void *value ) const
}
}
+/*-------------------------------------------------------------------------
+ * Function: getMemberIndex
+ *
+ * Purpose: Returns the index of a member in an enumeration data type.
+ * Members are stored in no particular order with numbers 0
+ * through N-1, where N is the value returned by the member
+ * function getNmembers.
+ *
+ * Return: Success: index of the member if exists.
+ * Failure: DataTypeIException
+ *
+ * BMR - May 16, 2002
+ *-------------------------------------------------------------------------
+ */
+int EnumType::getMemberIndex(const char *name) const
+{
+ int member_index = H5Tget_member_index(id, name);
+ if( member_index < 0 )
+ {
+ throw DataTypeIException("EnumType::getMemberIndex",
+ "H5Tget_member_index returns negative value");
+ }
+ return( member_index );
+}
+int EnumType::getMemberIndex(const string& name) const
+{
+ return(EnumType::getMemberIndex(name.c_str()));
+}
+
// Retrieves the value of a member in this enumeration datatype, given the
// member's index.
void EnumType::getMemberValue( int memb_no, void *value ) const