summaryrefslogtreecommitdiffstats
path: root/c++/src/H5CompType.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c++/src/H5CompType.cpp')
-rw-r--r--c++/src/H5CompType.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp
index 6fdba0b..3816751 100644
--- a/c++/src/H5CompType.cpp
+++ b/c++/src/H5CompType.cpp
@@ -68,11 +68,53 @@ string CompType::getMemberName( int member_num ) const
return( member_name ); // return the member name string
}
-// Retrieves the offset of a member of a compound datatype.
+/*-------------------------------------------------------------------------
+ * Function: getMemberIndex
+ *
+ * Purpose: Returns the index of a member in a compound 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 CompType::getMemberIndex(const char* name) const
+{
+ int member_index = H5Tget_member_index(id, name);
+ if( member_index < 0 )
+ {
+ throw DataTypeIException("CompType::getMemberIndex",
+ "H5Tget_member_index returns negative value");
+ }
+ return( member_index );
+}
+int CompType::getMemberIndex(const string& name) const
+{
+ return(getMemberIndex(name.c_str()));
+}
+
+/*-------------------------------------------------------------------------
+ * Function: getMemberOffset
+ *
+ * Purpose: Returns the byte offset of the beginning of a member with
+ * respect to the beginning of the compound data type datum.
+ * 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: Byte offset.
+ * Failure: Quincey: for now, 0 is not a failure
+ *
+ * BMR - 2000
+ *-------------------------------------------------------------------------
+ */
size_t CompType::getMemberOffset( int member_num ) const
{
size_t offset = H5Tget_member_offset( id, member_num );
- // Q. said: for now, 0 is not a failure
//if( offset == 0 )
//{
//throw DataTypeIException("CompType::getMemberOffset",