Added NcCompoundType methods getMemberName and getMemberIndex

This commit is contained in:
Jarle Ladstein 2015-04-24 17:46:36 +02:00
parent 4f7d126ef6
commit e1f300c5ae
2 changed files with 23 additions and 3 deletions

View File

@ -128,7 +128,21 @@ NcType NcCompoundType::getMember(int memberIndex) const
}
}
// Returns name of member field.
std::string NcCompoundType::getMemberName(int memberIndex) const
{
char fieldName[NC_MAX_NAME];
ncCheck(nc_inq_compound_fieldname(groupId,myId,memberIndex, fieldName),__FILE__,__LINE__);
return std::string(fieldName);
}
// Returns index of named member field.
int NcCompoundType::getMemberIndex(const std::string& memberName) const{
int memberIndex;
ncCheck(nc_inq_compound_fieldindex(groupId,myId, memberName.c_str(),&memberIndex),__FILE__,__LINE__);
return memberIndex;
}
// Returns the number of dimensions of a member with the given index.
int NcCompoundType::getMemberDimCount(int memberIndex) const
{

View File

@ -80,8 +80,14 @@ the offset of a member "mem4" in structure struct1 is: offsetof(struct1,mem4).
size_t getMemberCount() const;
/*! Returns a NcType object for a single member. */
NcType getMember(int memberIndex) const;
NcType getMember(int memberIndex) const;
/*! Returns name of member field. */
std::string getMemberName(int memberIndex) const;
/*! Returns index of named member field. */
int getMemberIndex(const std::string& memberName) const;
/*! Returns the offset of the member with given index. */
size_t getMemberOffset(const int index) const;