4 #include "ncVlenType.h" 5 #include "ncCompoundType.h" 6 #include "ncOpaqueType.h" 7 #include "ncGroupAtt.h" 20 #include <ncException.h> 82 return myId == rhs.myId;
88 return !(*
this == rhs);
98 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getName on a Null group",__FILE__,__LINE__);
103 ncCheck(nc_inq_grpname_len(myId,&lenp),__FILE__,__LINE__);
104 char* charName=
new char[lenp+1];
105 ncCheck(nc_inq_grpname_full(myId,&lenp,charName),__FILE__,__LINE__);
106 groupName = charName;
111 char charName[NC_MAX_NAME+1];
112 ncCheck(nc_inq_grpname(myId,charName),__FILE__,__LINE__);
113 groupName = charName;
120 bool result =
getName() ==
"/";
126 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getParentGroup on a Null group",__FILE__,__LINE__);
129 ncCheck(nc_inq_grp_parent(myId,&parentId),__FILE__,__LINE__);
130 NcGroup ncGroupParent(parentId);
131 return ncGroupParent;
142 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getId on a Null group",__FILE__,__LINE__);
148 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getGroupCount on a Null group",__FILE__,__LINE__);
161 ncCheck(nc_inq_grps(
getId(), &numgrps,ncids),__FILE__,__LINE__);
168 ngroups += groups.size();
175 ngroups += groups.size();
184 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getGroups on a Null group",__FILE__,__LINE__);
186 multimap<string,NcGroup> ncGroups;
190 ncGroups.insert(pair<const string,NcGroup>(
getName(),*
this));
198 vector<int> ncids(groupCount);
201 ncCheck(nc_inq_grps(myId, numgrps,&ncids[0]),__FILE__,__LINE__);
202 for(
int i=0; i<groupCount;i++){
204 ncGroups.insert(pair<const string,NcGroup>(tmpGroup.
getName(),tmpGroup));
215 if(parentGroup.isNull())
break;
216 ncGroups.insert(pair<const string,NcGroup>(parentGroup.getName(),parentGroup));
217 tmpGroup=parentGroup;
224 multimap<string,NcGroup>::iterator it;
226 for (it=groups.begin();it!=groups.end();it++) {
227 multimap<string,NcGroup> childGroups(it->second.getGroups(
AllChildrenGrps));
228 ncGroups.insert(childGroups.begin(),childGroups.end());
237 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getGroup on a Null group",__FILE__,__LINE__);
238 multimap<string,NcGroup> ncGroups(
getGroups(location));
239 pair<multimap<string,NcGroup>::iterator,multimap<string,NcGroup>::iterator> ret;
240 ret = ncGroups.equal_range(name);
241 if(ret.first == ret.second)
244 return ret.first->second;
251 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getGroups on a Null group",__FILE__,__LINE__);
253 multimap<std::string,NcGroup> ncGroups(
getGroups(location));
254 pair<multimap<string,NcGroup>::iterator,multimap<string,NcGroup>::iterator> ret;
255 multimap<string,NcGroup>::iterator it;
256 ret = ncGroups.equal_range(name);
257 set<NcGroup> tmpGroup;
258 for (it=ret.first; it!=ret.second; ++it) {
259 tmpGroup.insert(it->second);
266 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::addGroup on a Null group",__FILE__,__LINE__);
268 ncCheck(nc_def_grp(myId,const_cast<char*> (name.c_str()),&new_ncid),__FILE__,__LINE__);
286 ncCheck(nc_inq_nvars(tmpGroup.
getId(), &nvars),__FILE__,__LINE__);
292 while(!tmpGroup.
isNull()) {
294 ncCheck(nc_inq_nvars(tmpGroup.
getId(), &nvarsp),__FILE__,__LINE__);
303 multimap<string,NcGroup>::iterator it;
304 multimap<string,NcGroup> groups(
getGroups());
305 for (it=groups.begin();it!=groups.end();it++) {
316 multimap<string,NcVar> ncVars;
326 vector<int> varids(varCount);
327 ncCheck(nc_inq_varids(myId, nvars,&varids[0]),__FILE__,__LINE__);
328 for(
int i=0; i<varCount;i++){
329 NcVar tmpVar(*
this,varids[i]);
330 ncVars.insert(pair<const string,NcVar>(tmpVar.
getName(),tmpVar));
339 while(!tmpGroup.
isNull()) {
345 vector<int> varids(varCount);
346 ncCheck(nc_inq_varids(tmpGroup.
getId(), nvars,&varids[0]),__FILE__,__LINE__);
347 for(
int i=0; i<varCount;i++){
348 NcVar tmpVar(tmpGroup,varids[i]);
349 ncVars.insert(pair<const string,NcVar>(tmpVar.
getName(),tmpVar));
359 multimap<string,NcGroup>::iterator it;
360 multimap<string,NcGroup> groups(
getGroups());
361 for (it=groups.begin();it!=groups.end();it++) {
363 ncVars.insert(vars.begin(),vars.end());
374 multimap<std::string,NcVar> ncVars(
getVars(location));
375 pair<multimap<string,NcVar>::iterator,multimap<string,NcVar>::iterator> ret;
376 multimap<string,NcVar>::iterator it;
377 ret = ncVars.equal_range(name);
379 for (it=ret.first; it!=ret.second; ++it) {
380 tmpVar.insert(it->second);
389 multimap<std::string,NcVar> ncVars(
getVars(location));
390 pair<multimap<string,NcVar>::iterator,multimap<string,NcVar>::iterator> ret;
391 ret = ncVars.equal_range(name);
392 if(ret.first == ret.second)
396 return ret.first->second;
405 NcVar NcGroup::addVar(
const string& name,
const string& typeName,
const string& dimName)
const {
410 if(tmpType.
isNull())
throw NcNullType(
"Attempt to invoke NcGroup::addVar failed: typeName must be defined in either the current group or a parent group",__FILE__,__LINE__);
414 if(tmpDim.
isNull())
throw NcNullDim(
"Attempt to invoke NcGroup::addVar failed: dimName must be defined in either the current group or a parent group",__FILE__,__LINE__);
418 int dimId(tmpDim.
getId());
419 ncCheck(nc_def_var(myId,name.c_str(),tmpType.
getId(),1,&dimId,&varId),__FILE__,__LINE__);
421 return NcVar(*
this,varId);
430 if(ncType.
isNull())
throw NcNullType(
"Attempt to invoke NcGroup::addVar with a Null NcType object",__FILE__,__LINE__);
432 if(tmpType.
isNull())
throw NcNullType(
"Attempt to invoke NcGroup::addVar failed: NcType must be defined in either the current group or a parent group",__FILE__,__LINE__);
435 if(ncDim.
isNull())
throw NcNullDim(
"Attempt to invoke NcGroup::addVar with a Null NcDim object",__FILE__,__LINE__);
437 if(tmpDim.
isNull())
throw NcNullDim(
"Attempt to invoke NcGroup::addVar failed: NcDim must be defined in either the current group or a parent group",__FILE__,__LINE__);
441 int dimId(tmpDim.
getId());
442 ncCheck(nc_def_var(myId,name.c_str(),tmpType.
getId(),1,&dimId,&varId),__FILE__,__LINE__);
444 return NcVar(*
this,varId);
449 NcVar NcGroup::addVar(
const string& name,
const string& typeName,
const vector<string>& dimNames)
const {
454 if(tmpType.
isNull())
throw NcNullType(
"Attempt to invoke NcGroup::addVar failed: typeName must be defined in either the current group or a parent group",__FILE__,__LINE__);
458 dimIds.reserve(dimNames.size());
459 for (
size_t i=0; i<dimNames.size();i++){
461 if(tmpDim.
isNull())
throw NcNullDim(
"Attempt to invoke NcGroup::addVar failed: dimNames must be defined in either the current group or a parent group",__FILE__,__LINE__);
462 dimIds.push_back(tmpDim.
getId());
467 int *dimIdsPtr = dimIds.empty() ? 0 : &dimIds[0];
468 ncCheck(nc_def_var(myId,name.c_str(),tmpType.
getId(),dimIds.size(), dimIdsPtr,&varId),__FILE__,__LINE__);
470 return NcVar(*
this,varId);
478 if(ncType.
isNull())
throw NcNullType(
"Attempt to invoke NcGroup::addVar with a Null NcType object",__FILE__,__LINE__);
480 if(tmpType.
isNull())
throw NcNullType(
"Attempt to invoke NcGroup::addVar failed: NcType must be defined in either the current group or a parent group",__FILE__,__LINE__);
483 vector<NcDim>::const_iterator iter;
485 dimIds.reserve(ncDimVector.size());
486 for (iter=ncDimVector.begin();iter < ncDimVector.end(); iter++) {
487 if(iter->isNull())
throw NcNullDim(
"Attempt to invoke NcGroup::addVar with a Null NcDim object",__FILE__,__LINE__);
489 if(tmpDim.
isNull())
throw NcNullDim(
"Attempt to invoke NcGroup::addVar failed: NcDim must be defined in either the current group or a parent group",__FILE__,__LINE__);
490 dimIds.push_back(tmpDim.
getId());
495 int *dimIdsPtr = dimIds.empty() ? 0 : &dimIds[0];
496 ncCheck(nc_def_var(myId,name.c_str(),tmpType.
getId(),dimIds.size(), dimIdsPtr,&varId),__FILE__,__LINE__);
498 return NcVar(*
this,varId);
514 ncCheck(nc_inq_natts(tmpGroup.
getId(), &ngatts),__FILE__,__LINE__);
520 while(!tmpGroup.
isNull()) {
522 ncCheck(nc_inq_natts(tmpGroup.
getId(), &ngattsp),__FILE__,__LINE__);
531 multimap<string,NcGroup>::iterator it;
532 multimap<string,NcGroup> groups(
getGroups());
533 for (it=groups.begin();it!=groups.end();it++) {
545 multimap<string,NcGroupAtt> ncAtts;
553 for(
int i=0; i<attCount;i++){
554 char charName[NC_MAX_NAME+1];
555 ncCheck(nc_inq_attname(tmpGroup.
getId(),NC_GLOBAL,i,charName),__FILE__,__LINE__);
557 ncAtts.insert(pair<const string,NcGroupAtt>(
string(charName),tmpAtt));
564 while(!tmpGroup.
isNull()) {
568 for(
int i=0; i<attCount;i++){
569 char charName[NC_MAX_NAME+1];
570 ncCheck(nc_inq_attname(tmpGroup.
getId(),NC_GLOBAL,i,charName),__FILE__,__LINE__);
572 ncAtts.insert(pair<const string,NcGroupAtt>(
string(charName),tmpAtt));
581 multimap<string,NcGroup>::iterator it;
582 multimap<string,NcGroup> groups(
getGroups());
583 for (it=groups.begin();it!=groups.end();it++) {
585 ncAtts.insert(atts.begin(),atts.end());
594 multimap<std::string,NcGroupAtt> ncAtts(
getAtts(location));
595 pair<multimap<string,NcGroupAtt>::iterator,multimap<string,NcGroupAtt>::iterator> ret;
596 ret = ncAtts.equal_range(name);
597 if(ret.first == ret.second)
601 return ret.first->second;
607 multimap<std::string,NcGroupAtt> ncAtts(
getAtts(location));
608 pair<multimap<string,NcGroupAtt>::iterator,multimap<string,NcGroupAtt>::iterator> ret;
609 multimap<string,NcGroupAtt>::iterator it;
610 ret = ncAtts.equal_range(name);
611 set<NcGroupAtt> tmpAtt;
612 for (it=ret.first; it!=ret.second; ++it) {
613 tmpAtt.insert(it->second);
624 ncCheck(nc_put_att_text(myId,NC_GLOBAL,name.c_str(),dataValues.size(),dataValues.c_str()),__FILE__,__LINE__);
634 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
636 ncCheck(nc_put_att_uchar(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
647 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
649 ncCheck(nc_put_att_schar(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
660 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
662 ncCheck(nc_put_att_short(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
673 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
675 ncCheck(nc_put_att_int(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
685 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
687 ncCheck(nc_put_att_long(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
697 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
699 ncCheck(nc_put_att_float(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
710 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
712 ncCheck(nc_put_att_double(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
723 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
725 ncCheck(nc_put_att_ushort(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
735 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
737 ncCheck(nc_put_att_uint(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
747 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
749 ncCheck(nc_put_att_longlong(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
760 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
762 ncCheck(nc_put_att_ulonglong(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
773 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
775 ncCheck(nc_put_att_short(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
786 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
788 ncCheck(nc_put_att_int(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
798 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
800 ncCheck(nc_put_att_long(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
810 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
812 ncCheck(nc_put_att_float(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
823 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
825 ncCheck(nc_put_att_double(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
836 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
838 ncCheck(nc_put_att_ushort(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
848 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
850 ncCheck(nc_put_att_uint(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
860 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
862 ncCheck(nc_put_att_longlong(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
873 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
875 ncCheck(nc_put_att_ulonglong(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
884 ncCheck(nc_put_att_string(myId,NC_GLOBAL,name.c_str(),len,dataValues),__FILE__,__LINE__);
892 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
905 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getDimCount on a Null group",__FILE__,__LINE__);
913 ncCheck(nc_inq_ndims(
getId(), &ndimsp),__FILE__,__LINE__);
919 multimap<string,NcGroup>::iterator it;
921 for (it=groups.begin();it!=groups.end();it++) {
922 ndims += it->second.getDimCount();
928 multimap<string,NcGroup>::iterator it;
930 for (it=groups.begin();it!=groups.end();it++) {
931 ndims += it->second.getDimCount();
940 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getDims on a Null group",__FILE__,__LINE__);
942 multimap<string,NcDim> ncDims;
948 vector<int> dimids(dimCount);
949 ncCheck(nc_inq_dimids(
getId(), &dimCount, &dimids[0], 0),__FILE__,__LINE__);
951 for(
int i=0; i<dimCount;i++){
952 NcDim tmpDim(*
this,dimids[i]);
953 ncDims.insert(pair<const string,NcDim>(tmpDim.
getName(),tmpDim));
960 multimap<string,NcGroup>::iterator it;
962 for (it=groups.begin();it!=groups.end();it++) {
963 multimap<string,NcDim> dimTmp(it->second.getDims());
964 ncDims.insert(dimTmp.begin(),dimTmp.end());
970 multimap<string,NcGroup>::iterator it;
972 for (it=groups.begin();it!=groups.end();it++) {
973 multimap<string,NcDim> dimTmp(it->second.getDims());
974 ncDims.insert(dimTmp.begin(),dimTmp.end());
985 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getDim on a Null group",__FILE__,__LINE__);
986 multimap<string,NcDim> ncDims(
getDims(location));
987 pair<multimap<string,NcDim>::iterator,multimap<string,NcDim>::iterator> ret;
988 ret = ncDims.equal_range(name);
989 if(ret.first == ret.second)
992 return ret.first->second;
998 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getDims on a Null group",__FILE__,__LINE__);
1000 multimap<string,NcDim> ncDims(
getDims(location));
1001 pair<multimap<string,NcDim>::iterator,multimap<string,NcDim>::iterator> ret;
1002 multimap<string,NcDim>::iterator it;
1003 ret = ncDims.equal_range(name);
1005 for (it=ret.first; it!=ret.second; ++it) {
1006 tmpDim.insert(it->second);
1014 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::addDim on a Null group",__FILE__,__LINE__);
1016 ncCheck(nc_def_dim(myId,name.c_str(),dimSize,&dimId),__FILE__,__LINE__);
1018 return NcDim(*
this,dimId);
1024 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::addDim on a Null group",__FILE__,__LINE__);
1026 ncCheck(nc_def_dim(myId,name.c_str(),NC_UNLIMITED,&dimId),__FILE__,__LINE__);
1028 return NcDim(*
this,dimId);
1042 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getTypeCount on a Null group",__FILE__,__LINE__);
1051 ncCheck(nc_inq_typeids(
getId(), &ntypesp,typeidsp),__FILE__,__LINE__);
1057 multimap<string,NcGroup>::iterator it;
1059 for (it=groups.begin();it!=groups.end();it++) {
1060 ntypes += it->second.getTypeCount();
1066 multimap<string,NcGroup>::iterator it;
1068 for (it=groups.begin();it!=groups.end();it++) {
1069 ntypes += it->second.getTypeCount();
1080 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getTypeCount on a Null group",__FILE__,__LINE__);
1089 ncCheck(nc_inq_typeids(
getId(), &ntypesp,typeidsp),__FILE__,__LINE__);
1091 vector<int> typeids(ntypesp);
1092 ncCheck(nc_inq_typeids(
getId(), &ntypesp,&typeids[0]),__FILE__,__LINE__);
1093 for (
int i=0; i<ntypesp;i++){
1094 NcType tmpType(*
this,typeids[i]);
1102 multimap<string,NcGroup>::iterator it;
1104 for (it=groups.begin();it!=groups.end();it++) {
1105 ntypes += it->second.getTypeCount(enumType);
1111 multimap<string,NcGroup>::iterator it;
1113 for (it=groups.begin();it!=groups.end();it++) {
1114 ntypes += it->second.getTypeCount(enumType);
1123 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getTypes on a Null group",__FILE__,__LINE__);
1125 multimap<string,NcType> ncTypes;
1131 vector<int> typeids(typeCount);
1132 ncCheck(nc_inq_typeids(
getId(), &typeCount,&typeids[0]),__FILE__,__LINE__);
1134 for(
int i=0; i<typeCount;i++){
1135 NcType tmpType(*
this,typeids[i]);
1136 ncTypes.insert(pair<const string,NcType>(tmpType.
getName(),tmpType));
1143 multimap<string,NcGroup>::iterator it;
1145 for (it=groups.begin();it!=groups.end();it++) {
1146 multimap<string,NcType> typeTmp(it->second.getTypes());
1147 ncTypes.insert(typeTmp.begin(),typeTmp.end());
1153 multimap<string,NcGroup>::iterator it;
1155 for (it=groups.begin();it!=groups.end();it++) {
1156 multimap<string,NcType> typeTmp(it->second.getTypes());
1157 ncTypes.insert(typeTmp.begin(),typeTmp.end());
1167 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getTypes on a Null group",__FILE__,__LINE__);
1169 multimap<string,NcType>::iterator it;
1171 pair<multimap<string,NcType>::iterator,multimap<string,NcType>::iterator> ret;
1173 multimap<string,NcType> types(
getTypes(location));
1175 set<NcType> tmpType;
1177 ret=types.equal_range(name);
1178 for (it=ret.first;it!=ret.second;it++) {
1179 tmpType.insert(it->second);
1187 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getTypes on a Null group",__FILE__,__LINE__);
1189 multimap<string,NcType>::iterator it;
1191 multimap<string,NcType> types(
getTypes(location));
1193 set<NcType> tmpType;
1195 for (it=types.begin();it!=types.end();it++) {
1196 if(it->second.getTypeClass() == enumType) {
1197 tmpType.insert(it->second);
1206 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getTypes on a Null group",__FILE__,__LINE__);
1208 multimap<string,NcType>::iterator it;
1210 pair<multimap<string,NcType>::iterator,multimap<string,NcType>::iterator> ret;
1212 multimap<string,NcType> types(
getTypes(location));
1214 set<NcType> tmpType;
1216 ret=types.equal_range(name);
1217 for (it=ret.first;it!=ret.second;it++) {
1218 if((*it).second.getTypeClass() == enumType) {
1219 tmpType.insert(it->second);
1228 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getType on a Null group",__FILE__,__LINE__);
1229 if(name ==
"byte" )
return ncByte;
1230 if(name ==
"ubyte" )
return ncUbyte;
1231 if(name ==
"char" )
return ncChar;
1232 if(name ==
"short" )
return ncShort;
1233 if(name ==
"ushort" )
return ncUshort;
1234 if(name ==
"int" )
return ncInt;
1235 if(name ==
"uint" )
return ncUint;
1236 if(name ==
"int64" )
return ncInt64;
1237 if(name ==
"uint64" )
return ncUint64;
1238 if(name ==
"float" )
return ncFloat;
1239 if(name ==
"double" )
return ncDouble;
1240 if(name ==
"string" )
return ncString;
1244 multimap<string,NcType>::iterator it;
1246 pair<multimap<string,NcType>::iterator,multimap<string,NcType>::iterator> ret;
1248 multimap<string,NcType> types(
getTypes(location));
1250 set<NcType> tmpType;
1252 ret=types.equal_range(name);
1253 if(ret.first == ret.second)
1256 return ret.first->second;
1264 ncCheck(nc_def_enum(myId, baseType, name.c_str(), &typeId),__FILE__,__LINE__);
1274 ncCheck(nc_def_vlen(myId, const_cast<char*>(name.c_str()),baseType.
getId(),&typeId),__FILE__,__LINE__);
1284 ncCheck(nc_def_opaque(myId, size,const_cast<char*>(name.c_str()), &typeId),__FILE__,__LINE__);
1293 ncCheck(nc_def_compound(myId, size,const_cast<char*>(name.c_str()),&typeId),__FILE__,__LINE__);
1301 map<string,NcGroup> coordVars;
1305 multimap<string,NcDim>::iterator itD;
1306 multimap<string,NcVar>::iterator itV;
1309 multimap<string,NcDim> dimTmp(tmpGroup.
getDims());
1310 multimap<string,NcVar> varTmp(tmpGroup.
getVars());
1311 for (itD=dimTmp.begin();itD!=dimTmp.end();itD++) {
1312 string coordName(itD->first);
1313 itV = varTmp.find(coordName);
1314 if(itV != varTmp.end()) {
1315 coordVars.insert(pair<const string,NcGroup>(
string(coordName),tmpGroup));
1327 multimap<string,NcGroup>::iterator it;
1328 multimap<string,NcGroup> groups(
getGroups());
1329 for (it=groups.begin();it!=groups.end();it++) {
1331 coordVars.insert(coordVarsTmp.begin(),coordVarsTmp.end());
1342 multimap<string,NcDim>::iterator itD;
1344 multimap<string,NcVar>::iterator itV;
1347 multimap<string,NcDim> dimTmp(tmpGroup.
getDims());
1348 multimap<string,NcVar> varTmp(tmpGroup.
getVars());
1349 itD=dimTmp.find(coordVarName);
1350 itV=varTmp.find(coordVarName);
1351 if(itD != dimTmp.end() && itV != varTmp.end()) {
1365 multimap<string,NcGroup>::iterator it;
1366 multimap<string,NcGroup> groups(
getGroups());
1367 for (it=groups.begin();it!=groups.end();it++) {
1369 if(!ncDim.
isNull())
break;
NcGroupAtt getAtt(const std::string &name, NcGroup::Location location=Current) const
Gets the named NcGroupAtt object.
Thrown if the requested operation is on a NULL type.
const int getId() const
The netCDF Id of this dimension.
GroupLocation
The enumeration list contains the options for selecting groups (used for returned set of NcGroup obje...
Base class inherited by NcOpaque, NcVlen, NcCompound and NcEnum classes.
NcUint64 ncUint64
A global instance of the NcUint64 class within the netCDF namespace.
bool isNull() const
Returns true if this object is null (i.e.
Thrown if cannot return a netCDF group.
bool operator==(const NcGroup &rhs) const
equivalence operator
Select from set of all children of the current group and beneath.
int getDimCount(NcGroup::Location location=Current) const
Gets the number of NcDim objects.
NcGroup getParentGroup() const
Gets the parent group.
bool nullObject
assignment operator
std::multimap< std::string, NcGroup > getGroups(NcGroup::GroupLocation location=ChildrenGrps) const
Gets the collection of NcGroup objects.
Select from contents of current group.
Location
The enumeration list contains the options for selecting groups.
NcGroupAtt putAtt(const std::string &name, size_t len, const char **dataValues) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Select from contents of parents groups.
Select from the set of children in the current group.
Thrown if the requested operation is on a NULL group.
bool isNull() const
Returns true if this object is null (i.e.
NcByte ncByte
A global instance of the NcByte class within the netCDF namespace.
NcType getType(const std::string &name, NcGroup::Location location=Current) const
Gets the NcType object with a given name.
int getAttCount(NcGroup::Location location=Current) const
Gets the number of group attributes.
Class represents a netCDF compound type.
int getId() const
Gets the group id.
Class represents a netCDF enum type.
Select from set of parent groups(includes the current group).
NcVlenType addVlenType(const std::string &name, NcType &basetype) const
Adds a new netCDF Vlen type.
std::string getName(bool fullName=false) const
Gets the group name.
Class represents a netCDF VLEN type.
NcEnumType addEnumType(const std::string &name, NcEnumType::ncEnumType basetype) const
Adds a new netCDF enum type.
NcFloat ncFloat
A global instance of the NcFloat class within the netCDF namespace.
Class represents a netCDF group.
void getCoordVar(std::string &coordVarName, NcDim &ncDim, NcVar &ncVar, NcGroup::Location location=Current) const
Gets the NcDim and NcVar object pair for a named coordinate variable.
int getGroupCount(NcGroup::GroupLocation location=ChildrenGrps) const
Gets the number of NcGroup objects.
Class represents a netCDF group attribute.
ncType
List of netCDF types that can be represented.
NcUint ncUint
A global instance of the NcUint class within the netCDF namespace.
Select from set of parent groups, current groups and all the children beneath.
NcChar ncChar
A global instance of the NcChar class within the netCDF namespace.
NcGroup getGroup(const std::string &name, NcGroup::GroupLocation location=ChildrenGrps) const
Gets the named child NcGroup object.
bool isNull() const
Returns true if this object is null (i.e.
Thrown if the requested operation is on a NULL dimension.
NcGroup & operator=(const NcGroup &rhs)
assignment operator
std::string getName() const
The name of this type.
NcVar addVar(const std::string &name, const NcType &ncType) const
Adds a new netCDF scalar variable.
std::multimap< std::string, NcDim > getDims(NcGroup::Location location=Current) const
Gets the collection of NcDim objects.
Select from contents of current, parents and child groups.
nc_type getId() const
The netCDF Id of this type.
NcDouble ncDouble
A global instance of the NcDouble class within the netCDF namespace.
Class represents a netCDF dimension.
NcGroup addGroup(const std::string &name) const
Adds a new child netCDF group object.
Select from contents of current and parents groups.
NcDim getDim(const std::string &name, NcGroup::Location location=Current) const
Gets the named NcDim object.
std::multimap< std::string, NcType > getTypes(NcGroup::Location location=Current) const
Gets the collection of NcType objects.
Select from contents of children groups.
std::multimap< std::string, NcGroupAtt > getAtts(NcGroup::Location location=Current) const
Gets the collection of NcGroupAtt objects.
void ncCheck(int retCode, const char *file, int line)
Function checks error code and if necessary throws an exception.
NcShort ncShort
A global instance of the NcShort class within the netCDF namespace.
bool isRootGroup() const
Returns true if this is the root group, otherwise returns false.
std::string getName() const
Name of this NcVar object.
void ncCheckDefineMode(int ncid)
Function checks if the file (group) is in define mode.
NcDim addDim(const std::string &name, size_t dimSize) const
Adds a new netCDF dimension.
int getVarCount(NcGroup::Location location=Current) const
Gets the number of NcVar objects in this group.
Select from contents of current and child groups.
std::multimap< std::string, NcVar > getVars(NcGroup::Location location=Current) const
Get the collection of NcVar objects.
ncEnumType
List of NetCDF-4 Enumeration types.
NcVar getVar(const std::string &name, NcGroup::Location location=Current) const
Gets the named NcVar object.
NcString ncString
A global instance of the NcString class within the netCDF namespace.
Select from set of parent groups (excludes the current group).
NcCompoundType addCompoundType(const std::string &name, size_t size) const
Adds a new netCDF UserDefined type.
Class represents a netCDF opaque type.
int getTypeCount(NcGroup::Location location=Current) const
Gets the number of type objects.
Class represents a netCDF variable.
std::map< std::string, NcGroup > getCoordVars(NcGroup::Location location=Current) const
Gets a collection of coordinate variables.
NcGroup()
Constructor generates a null object.
NcOpaqueType addOpaqueType(const std::string &name, size_t size) const
Adds a new netCDF Opaque type.
const std::string getName() const
The name of this dimension.
NcInt ncInt
A global instance of the NcInt class within the netCDF namespace.
ncType getTypeClass() const
The type class returned as enumeration type.
bool operator!=(const NcGroup &rhs) const
!= operator
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.
Select from set of all children of children in the current group.