3 #include "ncCompoundType.h" 16 #include "ncException.h" 27 NcType::operator=(rhs);
36 if(getTypeClass() != nc_COMPOUND)
throw NcException(
"The NcType object must be the base of a Compound type.",__FILE__,__LINE__);
38 NcType::operator=(rhs);
54 return nullObject == rhs.nullObject;
82 ncCheck(nc_insert_compound(
groupId,
myId,const_cast<char*>(memberName.c_str()),offset,newMemberType.
getId()),__FILE__,__LINE__);
91 ncCheck(nc_insert_array_compound(
groupId,
myId,const_cast<char*>(memberName.c_str()), offset, newMemberType.
getId(), shape.size(),
const_cast<int*
>(&shape[0])),__FILE__,__LINE__);
93 addMember(memberName, newMemberType, offset);
110 nc_type fieldtypeidp;
111 ncCheck(nc_inq_compound_fieldtype(
groupId,
myId,memberIndex,&fieldtypeidp),__FILE__,__LINE__);
112 switch (fieldtypeidp) {
113 case NC_BYTE :
return ncByte;
114 case NC_UBYTE :
return ncUbyte;
115 case NC_CHAR :
return ncChar;
116 case NC_SHORT :
return ncShort;
117 case NC_USHORT :
return ncUshort;
118 case NC_INT :
return ncInt;
119 case NC_UINT :
return ncUint;
120 case NC_INT64 :
return ncInt64;
122 case NC_FLOAT :
return ncFloat;
134 char fieldName[NC_MAX_NAME+1];
135 ncCheck(nc_inq_compound_fieldname(
groupId,
myId,memberIndex, fieldName),__FILE__,__LINE__);
136 return std::string(fieldName);
142 ncCheck(nc_inq_compound_fieldindex(
groupId,
myId, memberName.c_str(),&memberIndex),__FILE__,__LINE__);
150 ncCheck(nc_inq_compound_fieldndims(
groupId,
myId,memberIndex, &ndimsp),__FILE__,__LINE__);
158 vector<int> dim_size;
160 if(!dim_size.empty())
161 ncCheck(nc_inq_compound_fielddim_sizes(
groupId,
myId,memberIndex,&dim_size[0]),__FILE__,__LINE__);
Base class inherited by NcOpaque, NcVlen, NcCompound and NcEnum classes.
NcUint64 ncUint64
A global instance of the NcUint64 class within the netCDF namespace.
size_t getMemberCount() const
Returns number of members in this NcCompoundType object.
std::string getMemberName(int memberIndex) const
Returns name of member field.
NcByte ncByte
A global instance of the NcByte class within the netCDF namespace.
Class represents a netCDF compound type.
NcFloat ncFloat
A global instance of the NcFloat class within the netCDF namespace.
Class represents a netCDF group.
NcUint ncUint
A global instance of the NcUint class within the netCDF namespace.
NcType getMember(int memberIndex) const
Returns a NcType object for a single member.
NcChar ncChar
A global instance of the NcChar class within the netCDF namespace.
std::vector< int > getMemberShape(int memberIndex) const
Returns the shape of a given member.
nc_type getId() const
The netCDF Id of this type.
NcDouble ncDouble
A global instance of the NcDouble class within the netCDF namespace.
Base object is thrown if a netCDF exception is encountered.
NcType()
Constructor generates a null object.
void ncCheck(int retCode, const char *file, int line)
Function checks error code and if necessary throws an exception.
bool operator==(const NcCompoundType &rhs)
equivalence operator
size_t getMemberOffset(const int index) const
Returns the offset of the member with given index.
int getMemberDimCount(int memberIndex) const
Returns the number of dimensions of a member with the given index.
NcShort ncShort
A global instance of the NcShort class within the netCDF namespace.
NcCompoundType()
Constructor generates a null object.
NcString ncString
A global instance of the NcString class within the netCDF namespace.
netCDF::NcGroup getParentGroup() const
Gets parent group.
NcInt ncInt
A global instance of the NcInt class within the netCDF namespace.
int getMemberIndex(const std::string &memberName) const
Returns index of named member field.
void addMember(const std::string &memName, const NcType &newMemberType, size_t offset)
Adds a named field.
NcUbyte ncUbyte
A global instance of the NcUbyte class within the netCDF namespace.
NcInt64 ncInt64
A global instance of the NcInt64 class within the netCDF namespace.
NcType & operator=(const NcType &rhs)
assignment operator