//-------------------------------------------------------------------------- // Function: CompType::getMemberIndex ///\brief Returns the index of a member in this compound datatype. ///\param name - IN: Name of the member ///\return Index of member ///\exception H5::DataTypeIException ///\par Description /// Members are stored in no particular order with numbers 0 /// through N-1, where N is the value returned by the member /// function \c CompType::getNmembers. // Programmer Binh-Minh Ribler - 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 ); }
/*------------------------------------------------------------------------- * Function: H5LD_construct_info() * * Purpose: Get the remaining info for a field: * 1) Get the type id of the last member in the field * 2) Get the total offset of all the members in the field * 3) Get the type size of the last member in the field * * Return: Success: 0 * Failure: negative * * Programmer: Vailin Choi; Aug 2010 * *------------------------------------------------------------------------- */ static herr_t H5LD_construct_info(H5LD_memb_t *memb, hid_t par_tid) { hid_t tmp_tid = -1; /* Dataset type id */ unsigned i; /* Local index variable */ herr_t ret_value = FAIL; /* Return value */ /* Make a copy of the incoming datatype */ tmp_tid = H5Tcopy(par_tid); /* Validate all the members in a field */ for(i = 0; memb->names[i] != NULL; i++) { hid_t memb_tid; /* Type id for a member in a field */ int idx; /* Index # of a member in a compound datatype */ /* Get the member index and member type id */ if((idx = H5Tget_member_index(tmp_tid, memb->names[i])) < 0) goto done; if((memb_tid = H5Tget_member_type(tmp_tid, (unsigned)idx)) < 0) goto done; /* Sum up the offset of all the members in the field */ memb->tot_offset += H5Tget_member_offset(tmp_tid, (unsigned)idx); if(H5Tclose(tmp_tid) < 0) goto done; tmp_tid = memb_tid; } /* end for */ /* Get the type size of the last member in the field */ memb->last_tsize = H5Tget_size(tmp_tid); /* Save the type id of the last member in the field */ memb->last_tid = H5Tcopy(tmp_tid); /* Indicate success */ ret_value = SUCCEED; done: H5E_BEGIN_TRY H5Tclose(tmp_tid); H5E_END_TRY return(ret_value); } /* H5LD_construct_info() */