5#include "ncCompoundType.h"
6#include "ncOpaqueType.h"
21#include <ncException.h>
85 return myId == rhs.myId;
91 return !(*
this == rhs);
101 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getName on a Null group",__FILE__,__LINE__);
106 ncCheck(nc_inq_grpname_len(myId,&lenp),__FILE__,__LINE__);
107 char* charName=
new char[lenp+1];
108 ncCheck(nc_inq_grpname_full(myId,&lenp,charName),__FILE__,__LINE__);
109 groupName = charName;
114 char charName[NC_MAX_NAME+1];
115 ncCheck(nc_inq_grpname(myId,charName),__FILE__,__LINE__);
116 groupName = charName;
123 bool result =
getName() ==
"/";
129 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getParentGroup on a Null group",__FILE__,__LINE__);
132 ncCheck(nc_inq_grp_parent(myId,&parentId),__FILE__,__LINE__);
133 NcGroup ncGroupParent(parentId);
134 return ncGroupParent;
145 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getId on a Null group",__FILE__,__LINE__);
151 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getGroupCount on a Null group",__FILE__,__LINE__);
164 ncCheck(nc_inq_grps(
getId(), &numgrps,ncids),__FILE__,__LINE__);
171 ngroups +=
static_cast<int>(groups.size());
178 ngroups +=
static_cast<int>(groups.size());
187 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getGroups on a Null group",__FILE__,__LINE__);
189 multimap<string,NcGroup> ncGroups;
193 ncGroups.emplace(
getName(), *
this);
199 const auto groupCount =
static_cast<std::size_t
>(
getGroupCount());
201 vector<int> ncids(groupCount);
204 ncCheck(nc_inq_grps(myId, numgrps,&ncids[0]),__FILE__,__LINE__);
205 for (
auto ncid : ncids) {
207 ncGroups.emplace(tmpGroup.
getName(), tmpGroup);
218 if(parentGroup.
isNull())
break;
219 ncGroups.insert(pair<const string,NcGroup>(parentGroup.
getName(),parentGroup));
220 tmpGroup=parentGroup;
227 multimap<string,NcGroup>::iterator it;
229 for (it=groups.begin();it!=groups.end();it++) {
230 multimap<string,NcGroup> childGroups(it->second.getGroups(
AllChildrenGrps));
231 ncGroups.insert(childGroups.begin(),childGroups.end());
240 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getGroup on a Null group",__FILE__,__LINE__);
241 multimap<string,NcGroup> ncGroups(
getGroups(location));
242 pair<multimap<string,NcGroup>::iterator,multimap<string,NcGroup>::iterator> ret;
243 ret = ncGroups.equal_range(name);
244 if(ret.first == ret.second)
247 return ret.first->second;
254 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getGroups on a Null group",__FILE__,__LINE__);
256 multimap<std::string,NcGroup> ncGroups(
getGroups(location));
257 pair<multimap<string,NcGroup>::iterator,multimap<string,NcGroup>::iterator> ret;
258 multimap<string,NcGroup>::iterator it;
259 ret = ncGroups.equal_range(name);
260 set<NcGroup> tmpGroup;
261 for (it=ret.first; it!=ret.second; ++it) {
262 tmpGroup.insert(it->second);
269 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::addGroup on a Null group",__FILE__,__LINE__);
271 ncCheck(nc_def_grp(myId, name.c_str(), &new_ncid),__FILE__,__LINE__);
289 ncCheck(nc_inq_nvars(tmpGroup.
getId(), &nvars),__FILE__,__LINE__);
295 while(!tmpGroup.
isNull()) {
297 ncCheck(nc_inq_nvars(tmpGroup.
getId(), &nvarsp),__FILE__,__LINE__);
306 multimap<string,NcGroup>::iterator it;
307 multimap<string,NcGroup> groups(
getGroups());
308 for (it=groups.begin();it!=groups.end();it++) {
319 multimap<string,NcVar> ncVars;
325 const auto varCount =
static_cast<std::size_t
>(
getVarCount());
329 vector<int> varids(varCount);
330 ncCheck(nc_inq_varids(myId, nvars,&varids[0]),__FILE__,__LINE__);
331 for (
auto varid : varids) {
332 NcVar tmpVar(*
this, varid);
333 ncVars.emplace(tmpVar.
getName(), tmpVar);
342 while(!tmpGroup.
isNull()) {
344 const auto varCount =
static_cast<std::size_t
>(tmpGroup.
getVarCount());
348 vector<int> varids(varCount);
349 ncCheck(nc_inq_varids(tmpGroup.
getId(), nvars,&varids[0]),__FILE__,__LINE__);
350 for (
auto varid : varids) {
351 NcVar tmpVar(tmpGroup, varid);
352 ncVars.emplace(tmpVar.
getName(), tmpVar);
362 multimap<string,NcGroup>::iterator it;
363 multimap<string,NcGroup> groups(
getGroups());
364 for (it=groups.begin();it!=groups.end();it++) {
366 ncVars.insert(vars.begin(),vars.end());
377 multimap<std::string,NcVar> ncVars(
getVars(location));
378 pair<multimap<string,NcVar>::iterator,multimap<string,NcVar>::iterator> ret;
379 multimap<string,NcVar>::iterator it;
380 ret = ncVars.equal_range(name);
382 for (it=ret.first; it!=ret.second; ++it) {
383 tmpVar.insert(it->second);
392 multimap<std::string,NcVar> ncVars(
getVars(location));
393 pair<multimap<string,NcVar>::iterator,multimap<string,NcVar>::iterator> ret;
394 ret = ncVars.equal_range(name);
395 if(ret.first == ret.second)
399 return ret.first->second;
413 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__);
417 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__);
421 int dimId(tmpDim.getId());
422 ncCheck(nc_def_var(myId,name.c_str(),tmpType.getId(),1,&dimId,&varId),__FILE__,__LINE__);
424 return NcVar(*
this,varId);
433 if(ncType.
isNull())
throw NcNullType(
"Attempt to invoke NcGroup::addVar with a Null NcType object",__FILE__,__LINE__);
435 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__);
438 if(ncDim.
isNull())
throw NcNullDim(
"Attempt to invoke NcGroup::addVar with a Null NcDim object",__FILE__,__LINE__);
440 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__);
444 int dimId(tmpDim.getId());
445 ncCheck(nc_def_var(myId,name.c_str(),tmpType.getId(),1,&dimId,&varId),__FILE__,__LINE__);
447 return NcVar(*
this,varId);
452NcVar NcGroup::addVar(
const string& name,
const string& typeName,
const vector<string>& dimNames)
const {
457 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__);
461 dimIds.reserve(dimNames.size());
462 for (
const auto& dimName : dimNames) {
464 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__);
465 dimIds.push_back(tmpDim.getId());
470 int *dimIdsPtr = dimIds.empty() ? 0 : &dimIds[0];
471 ncCheck(nc_def_var(myId,name.c_str(),tmpType.getId(),
static_cast<int>(dimIds.size()), dimIdsPtr,&varId),__FILE__,__LINE__);
473 return NcVar(*
this,varId);
481 if(ncType.
isNull())
throw NcNullType(
"Attempt to invoke NcGroup::addVar with a Null NcType object",__FILE__,__LINE__);
483 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__);
486 vector<NcDim>::const_iterator iter;
488 dimIds.reserve(ncDimVector.size());
489 for (iter=ncDimVector.begin();iter < ncDimVector.end(); iter++) {
490 if(iter->isNull())
throw NcNullDim(
"Attempt to invoke NcGroup::addVar with a Null NcDim object",__FILE__,__LINE__);
492 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__);
493 dimIds.push_back(tmpDim.getId());
498 int *dimIdsPtr = dimIds.empty() ? 0 : &dimIds[0];
499 ncCheck(nc_def_var(myId,name.c_str(),tmpType.getId(),
static_cast<int>(dimIds.size()), dimIdsPtr,&varId),__FILE__,__LINE__);
501 return NcVar(*
this,varId);
517 ncCheck(nc_inq_natts(tmpGroup.
getId(), &ngatts),__FILE__,__LINE__);
523 while(!tmpGroup.
isNull()) {
525 ncCheck(nc_inq_natts(tmpGroup.
getId(), &ngattsp),__FILE__,__LINE__);
534 multimap<string,NcGroup>::iterator it;
535 multimap<string,NcGroup> groups(
getGroups());
536 for (it=groups.begin();it!=groups.end();it++) {
548 multimap<string,NcGroupAtt> ncAtts;
556 for(
int i=0; i<attCount;i++){
557 char charName[NC_MAX_NAME+1];
558 ncCheck(nc_inq_attname(tmpGroup.
getId(),NC_GLOBAL,i,charName),__FILE__,__LINE__);
559 ncAtts.emplace(std::piecewise_construct,
560 std::forward_as_tuple(charName),
561 std::forward_as_tuple(tmpGroup, i));
568 while(!tmpGroup.
isNull()) {
572 for(
int i=0; i<attCount;i++){
573 char charName[NC_MAX_NAME+1];
574 ncCheck(nc_inq_attname(tmpGroup.
getId(),NC_GLOBAL,i,charName),__FILE__,__LINE__);
575 ncAtts.emplace(std::piecewise_construct,
576 std::forward_as_tuple(charName),
577 std::forward_as_tuple(tmpGroup, i));
586 multimap<string,NcGroup>::iterator it;
587 multimap<string,NcGroup> groups(
getGroups());
588 for (it=groups.begin();it!=groups.end();it++) {
590 ncAtts.insert(atts.begin(),atts.end());
599 multimap<std::string,NcGroupAtt> ncAtts(
getAtts(location));
600 pair<multimap<string,NcGroupAtt>::iterator,multimap<string,NcGroupAtt>::iterator> ret;
601 ret = ncAtts.equal_range(name);
602 if(ret.first == ret.second)
606 return ret.first->second;
612 multimap<std::string,NcGroupAtt> ncAtts(
getAtts(location));
613 pair<multimap<string,NcGroupAtt>::iterator,multimap<string,NcGroupAtt>::iterator> ret;
614 multimap<string,NcGroupAtt>::iterator it;
615 ret = ncAtts.equal_range(name);
616 set<NcGroupAtt> tmpAtt;
617 for (it=ret.first; it!=ret.second; ++it) {
618 tmpAtt.insert(it->second);
629 ncCheck(nc_put_att_text(myId,NC_GLOBAL,name.c_str(),dataValues.size(),dataValues.c_str()),__FILE__,__LINE__);
638 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
640 ncCheck(nc_put_att_uchar(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
650 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
652 ncCheck(nc_put_att_schar(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
662 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
664 ncCheck(nc_put_att_short(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
674 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
676 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__);
696 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
698 ncCheck(nc_put_att_float(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
708 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
710 ncCheck(nc_put_att_double(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
720 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
722 ncCheck(nc_put_att_ushort(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
731 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
733 ncCheck(nc_put_att_uint(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
742 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
744 ncCheck(nc_put_att_longlong(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
754 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
756 ncCheck(nc_put_att_ulonglong(myId,NC_GLOBAL,name.c_str(),type.
getId(),1,&datumValue),__FILE__,__LINE__);
766 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
768 ncCheck(nc_put_att_short(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
778 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
780 ncCheck(nc_put_att_int(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
789 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
791 ncCheck(nc_put_att_long(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
800 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
802 ncCheck(nc_put_att_float(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
812 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
814 ncCheck(nc_put_att_double(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
824 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
826 ncCheck(nc_put_att_ushort(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
835 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
837 ncCheck(nc_put_att_uint(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
846 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
848 ncCheck(nc_put_att_longlong(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
858 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
860 ncCheck(nc_put_att_ulonglong(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
869 ncCheck(nc_put_att_string(myId,NC_GLOBAL,name.c_str(),len,dataValues),__FILE__,__LINE__);
877 ncCheck(nc_put_att(myId,NC_GLOBAL,name.c_str(),type.
getId(),len,dataValues),__FILE__,__LINE__);
890 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getDimCount on a Null group",__FILE__,__LINE__);
898 ncCheck(nc_inq_ndims(
getId(), &ndimsp),__FILE__,__LINE__);
904 multimap<string,NcGroup>::iterator it;
906 for (it=groups.begin();it!=groups.end();it++) {
907 ndims += it->second.getDimCount();
913 multimap<string,NcGroup>::iterator it;
915 for (it=groups.begin();it!=groups.end();it++) {
916 ndims += it->second.getDimCount();
925 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getDims on a Null group",__FILE__,__LINE__);
927 multimap<string,NcDim> ncDims;
931 const auto dimCount =
static_cast<std::size_t
>(
getDimCount());
933 vector<int> dimids(dimCount);
934 ncCheck(nc_inq_dimids(
getId(),
nullptr, &dimids[0], 0),__FILE__,__LINE__);
936 for (
auto dimid : dimids) {
937 NcDim tmpDim(*
this,dimid);
938 ncDims.emplace(tmpDim.
getName(), tmpDim);
945 multimap<string,NcGroup>::iterator it;
947 for (it=groups.begin();it!=groups.end();it++) {
948 multimap<string,NcDim> dimTmp(it->second.getDims());
949 ncDims.insert(dimTmp.begin(),dimTmp.end());
955 multimap<string,NcGroup>::iterator it;
957 for (it=groups.begin();it!=groups.end();it++) {
958 multimap<string,NcDim> dimTmp(it->second.getDims());
959 ncDims.insert(dimTmp.begin(),dimTmp.end());
970 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getDim on a Null group",__FILE__,__LINE__);
971 multimap<string,NcDim> ncDims(
getDims(location));
972 pair<multimap<string,NcDim>::iterator,multimap<string,NcDim>::iterator> ret;
973 ret = ncDims.equal_range(name);
974 if(ret.first == ret.second)
977 return ret.first->second;
983 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getDims on a Null group",__FILE__,__LINE__);
985 multimap<string,NcDim> ncDims(
getDims(location));
986 pair<multimap<string,NcDim>::iterator,multimap<string,NcDim>::iterator> ret;
987 multimap<string,NcDim>::iterator it;
988 ret = ncDims.equal_range(name);
990 for (it=ret.first; it!=ret.second; ++it) {
991 tmpDim.insert(it->second);
999 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::addDim on a Null group",__FILE__,__LINE__);
1001 ncCheck(nc_def_dim(myId,name.c_str(),dimSize,&dimId),__FILE__,__LINE__);
1003 return NcDim(*
this,dimId);
1009 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::addDim on a Null group",__FILE__,__LINE__);
1011 ncCheck(nc_def_dim(myId,name.c_str(),NC_UNLIMITED,&dimId),__FILE__,__LINE__);
1013 return NcDim(*
this,dimId);
1027 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getTypeCount on a Null group",__FILE__,__LINE__);
1036 ncCheck(nc_inq_typeids(
getId(), &ntypesp,typeidsp),__FILE__,__LINE__);
1042 multimap<string,NcGroup>::iterator it;
1044 for (it=groups.begin();it!=groups.end();it++) {
1045 ntypes += it->second.getTypeCount();
1051 multimap<string,NcGroup>::iterator it;
1053 for (it=groups.begin();it!=groups.end();it++) {
1054 ntypes += it->second.getTypeCount();
1065 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getTypeCount on a Null group",__FILE__,__LINE__);
1074 ncCheck(nc_inq_typeids(
getId(), &ntypesp,typeidsp),__FILE__,__LINE__);
1076 vector<int> typeids(
static_cast<std::size_t
>(ntypesp));
1077 ncCheck(nc_inq_typeids(
getId(), &ntypesp,&typeids[0]),__FILE__,__LINE__);
1078 for (
auto typeid_ : typeids) {
1079 NcType tmpType(*
this, typeid_);
1087 multimap<string,NcGroup>::iterator it;
1089 for (it=groups.begin();it!=groups.end();it++) {
1090 ntypes += it->second.getTypeCount(enumType);
1096 multimap<string,NcGroup>::iterator it;
1098 for (it=groups.begin();it!=groups.end();it++) {
1099 ntypes += it->second.getTypeCount(enumType);
1108 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getTypes on a Null group",__FILE__,__LINE__);
1110 multimap<string,NcType> ncTypes;
1114 const auto typeCount =
static_cast<std::size_t
>(
getTypeCount());
1116 vector<int> typeids(typeCount);
1117 ncCheck(nc_inq_typeids(
getId(),
nullptr, &typeids[0]),__FILE__,__LINE__);
1119 for (
auto typeid_ : typeids) {
1120 NcType tmpType(*
this, typeid_);
1121 ncTypes.emplace(tmpType.
getName(), tmpType);
1128 multimap<string,NcGroup>::iterator it;
1130 for (it=groups.begin();it!=groups.end();it++) {
1131 multimap<string,NcType> typeTmp(it->second.getTypes());
1132 ncTypes.insert(typeTmp.begin(),typeTmp.end());
1138 multimap<string,NcGroup>::iterator it;
1140 for (it=groups.begin();it!=groups.end();it++) {
1141 multimap<string,NcType> typeTmp(it->second.getTypes());
1142 ncTypes.insert(typeTmp.begin(),typeTmp.end());
1152 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getTypes on a Null group",__FILE__,__LINE__);
1154 multimap<string,NcType>::iterator it;
1156 pair<multimap<string,NcType>::iterator,multimap<string,NcType>::iterator> ret;
1158 multimap<string,NcType> types(
getTypes(location));
1160 set<NcType> tmpType;
1162 ret=types.equal_range(name);
1163 for (it=ret.first;it!=ret.second;it++) {
1164 tmpType.insert(it->second);
1172 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getTypes on a Null group",__FILE__,__LINE__);
1174 multimap<string,NcType>::iterator it;
1176 multimap<string,NcType> types(
getTypes(location));
1178 set<NcType> tmpType;
1180 for (it=types.begin();it!=types.end();it++) {
1181 if(it->second.getTypeClass() == enumType) {
1182 tmpType.insert(it->second);
1191 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getTypes on a Null group",__FILE__,__LINE__);
1193 multimap<string,NcType>::iterator it;
1195 pair<multimap<string,NcType>::iterator,multimap<string,NcType>::iterator> ret;
1197 multimap<string,NcType> types(
getTypes(location));
1199 set<NcType> tmpType;
1201 ret=types.equal_range(name);
1202 for (it=ret.first;it!=ret.second;it++) {
1203 if((*it).second.getTypeClass() == enumType) {
1204 tmpType.insert(it->second);
1213 if(
isNull())
throw NcNullGrp(
"Attempt to invoke NcGroup::getType on a Null group",__FILE__,__LINE__);
1214 if(name ==
"byte" )
return ncByte;
1215 if(name ==
"ubyte" )
return ncUbyte;
1216 if(name ==
"char" )
return ncChar;
1217 if(name ==
"short" )
return ncShort;
1218 if(name ==
"ushort" )
return ncUshort;
1219 if(name ==
"int" )
return ncInt;
1220 if(name ==
"uint" )
return ncUint;
1221 if(name ==
"int64" )
return ncInt64;
1222 if(name ==
"uint64" )
return ncUint64;
1223 if(name ==
"float" )
return ncFloat;
1224 if(name ==
"double" )
return ncDouble;
1225 if(name ==
"string" )
return ncString;
1229 multimap<string,NcType>::iterator it;
1231 pair<multimap<string,NcType>::iterator,multimap<string,NcType>::iterator> ret;
1233 multimap<string,NcType> types(
getTypes(location));
1235 set<NcType> tmpType;
1237 ret=types.equal_range(name);
1238 if(ret.first == ret.second)
1241 return ret.first->second;
1249 ncCheck(nc_def_enum(myId, baseType, name.c_str(), &typeId),__FILE__,__LINE__);
1259 ncCheck(nc_def_vlen(myId, name.c_str(), baseType.
getId(),&typeId),__FILE__,__LINE__);
1269 ncCheck(nc_def_opaque(myId, size, name.c_str(), &typeId),__FILE__,__LINE__);
1278 ncCheck(nc_def_compound(myId, size, name.c_str(), &typeId),__FILE__,__LINE__);
1286 map<string,NcGroup> coordVars;
1290 multimap<string,NcDim>::iterator itD;
1291 multimap<string,NcVar>::iterator itV;
1292 bool check_current_group = !(location ==
Parents || location ==
Children);
1298 if (check_current_group) {
1299 multimap<string,NcDim> dimTmp(tmpGroup.
getDims());
1300 multimap<string,NcVar> varTmp(tmpGroup.
getVars());
1301 for (itD=dimTmp.begin();itD!=dimTmp.end();itD++) {
1302 string coordName(itD->first);
1303 itV = varTmp.find(coordName);
1304 if(itV != varTmp.end()) {
1305 coordVars.insert(pair<const string,NcGroup>(
string(coordName),tmpGroup));
1310 if (!check_parent_groups || tmpGroup.
isRootGroup()) {
1313 check_current_group =
true;
1320 if (check_child_groups) {
1321 multimap<string,NcGroup>::iterator it;
1322 multimap<string,NcGroup> groups(
getGroups());
1323 for (it=groups.begin();it!=groups.end();it++) {
1325 coordVars.insert(coordVarsTmp.begin(),coordVarsTmp.end());
1339 multimap<string,NcDim>::iterator itD;
1341 multimap<string,NcVar>::iterator itV;
1342 bool check_current_group = !(location ==
Parents || location ==
Children);
1348 if (check_current_group) {
1349 multimap<string,NcDim> dimTmp(tmpGroup.
getDims());
1350 multimap<string,NcVar> varTmp(tmpGroup.
getVars());
1351 itD=dimTmp.find(coordVarName);
1352 itV=varTmp.find(coordVarName);
1353 if(itD != dimTmp.end() && itV != varTmp.end()) {
1359 if(!check_parent_groups || tmpGroup.
isRootGroup()) {
1362 check_current_group =
true;
1368 if (check_child_groups) {
1369 multimap<string,NcGroup>::iterator it;
1370 multimap<string,NcGroup> groups(
getGroups());
1371 for (it=groups.begin();it!=groups.end();it++) {
1373 if(!ncDim.
isNull())
break;
Class represents a netCDF compound type.
Class represents a netCDF dimension.
std::string getName() const
The name of this dimension.
bool isNull() const
Returns true if this object is null (i.e.
NcDim()
Constructor generates a null object.
Class represents a netCDF enum type.
ncEnumType
List of NetCDF-4 Enumeration types.
Class represents a netCDF group attribute.
NcGroupAtt()
Constructor generates a null object.
int getGroupCount(NcGroup::GroupLocation location=ChildrenGrps) const
Gets the number of NcGroup objects.
virtual ~NcGroup()
destructor
friend bool operator>(const NcGroup &lhs, const NcGroup &rhs)
comparator operator
NcGroup & operator=(const NcGroup &rhs)
assignment operator
NcCompoundType addCompoundType(const std::string &name, size_t size) const
Adds a new netCDF UserDefined type.
bool operator!=(const NcGroup &rhs) const
!= operator
NcVlenType addVlenType(const std::string &name, NcType &basetype) const
Adds a new netCDF Vlen type.
NcGroup getGroup(const std::string &name, NcGroup::GroupLocation location=ChildrenGrps) const
Gets the named child NcGroup object.
int getTypeCount(NcGroup::Location location=Current) const
Gets the number of type objects.
int getId() const
Gets the group id.
NcType getType(const std::string &name, NcGroup::Location location=Current) const
Gets the NcType object with a given name.
int getVarCount(NcGroup::Location location=Current) const
Gets the number of NcVar objects in this group.
std::multimap< std::string, NcGroupAtt > getAtts(NcGroup::Location location=Current) const
Gets the collection of NcGroupAtt objects.
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...
NcGroup()
Constructor generates a null object.
NcDim addDim(const std::string &name, size_t dimSize) const
Adds a new netCDF dimension.
NcGroupAtt getAtt(const std::string &name, NcGroup::Location location=Current) const
Gets the named NcGroupAtt object.
bool isRootGroup() const
Returns true if this is the root group, otherwise returns false.
void getCoordVar(const std::string &coordVarName, NcDim &ncDim, NcVar &ncVar, NcGroup::Location location=Current) const
Gets the NcDim and NcVar object pair for a named coordinate variable.
NcGroup addGroup(const std::string &name) const
Adds a new child netCDF group object.
Location
The enumeration list contains the options for selecting groups.
@ ParentsAndCurrent
Select from contents of current and parents groups.
@ Current
Select from contents of current group.
@ Children
Select from contents of children groups.
@ ChildrenAndCurrent
Select from contents of current and child groups.
@ All
Select from contents of current, parents and child groups.
@ Parents
Select from contents of parents groups.
bool operator==(const NcGroup &rhs) const
equivalence operator
std::multimap< std::string, NcVar > getVars(NcGroup::Location location=Current) const
Get the collection of NcVar objects.
std::map< std::string, NcGroup > getCoordVars(NcGroup::Location location=Current) const
Gets a collection of coordinate variables.
GroupLocation
The enumeration list contains the options for selecting groups (used for returned set of NcGroup obje...
@ ParentsAndCurrentGrps
Select from set of parent groups(includes the current group).
@ ChildrenOfChildrenGrps
Select from set of all children of children in the current group.
@ ParentsGrps
Select from set of parent groups (excludes the current group).
@ AllGrps
Select from set of parent groups, current groups and all the children beneath.
@ ChildrenGrps
Select from the set of children in the current group.
@ AllChildrenGrps
Select from set of all children of the current group and beneath.
NcOpaqueType addOpaqueType(const std::string &name, size_t size) const
Adds a new netCDF Opaque type.
std::string getName(bool fullName=false) const
Gets the group name.
int getAttCount(NcGroup::Location location=Current) const
Gets the number of group attributes.
NcEnumType addEnumType(const std::string &name, NcEnumType::ncEnumType basetype) const
Adds a new netCDF enum type.
NcGroup getParentGroup() const
Gets the parent group.
NcVar getVar(const std::string &name, NcGroup::Location location=Current) const
Gets the named NcVar object.
bool nullObject
assignment operator
NcDim getDim(const std::string &name, NcGroup::Location location=Current) const
Gets the named NcDim object.
NcVar addVar(const std::string &name, const NcType &ncType) const
Adds a new netCDF scalar variable.
bool isNull() const
Returns true if this object is null (i.e.
std::multimap< std::string, NcGroup > getGroups(NcGroup::GroupLocation location=ChildrenGrps) const
Gets the collection of NcGroup objects.
friend bool operator<(const NcGroup &lhs, const NcGroup &rhs)
comparator operator
std::multimap< std::string, NcType > getTypes(NcGroup::Location location=Current) const
Gets the collection of NcType objects.
int getDimCount(NcGroup::Location location=Current) const
Gets the number of NcDim objects.
std::multimap< std::string, NcDim > getDims(NcGroup::Location location=Current) const
Gets the collection of NcDim objects.
Class represents a netCDF opaque type.
Base class inherited by NcOpaque, NcVlen, NcCompound and NcEnum classes.
ncType getTypeClass() const
The type class returned as enumeration type.
NcType()
Constructor generates a null object.
bool isNonPrimitive() const
Return true if this is not a primitive type.
ncType
List of netCDF types that can be represented.
std::string getName() const
The name of this type.
bool isNull() const
Returns true if this object is null (i.e.
nc_type getId() const
The netCDF Id of this type.
Class represents a netCDF variable.
std::string getName() const
Name of this NcVar object.
NcVar()
Constructor generates a null object.
Class represents a netCDF VLEN type.
Thrown if cannot return a netCDF group.
Thrown if the requested operation is on a NULL dimension.
Thrown if the requested operation is on a NULL group.
Thrown if the requested operation is on a NULL type.
NcShort ncShort
A global instance of the NcShort class within the netCDF namespace.
NcFloat ncFloat
A global instance of the NcFloat class within the netCDF namespace.
NcInt64 ncInt64
A global instance of the NcInt64 class within the netCDF namespace.
void ncCheckDefineMode(int ncid)
Function checks if the file (group) is in define mode.
NcUint64 ncUint64
A global instance of the NcUint64 class within the netCDF namespace.
NcUint ncUint
A global instance of the NcUint class within the netCDF namespace.
NcString ncString
A global instance of the NcString class within the netCDF namespace.
NcInt ncInt
A global instance of the NcInt class within the netCDF namespace.
NcDouble ncDouble
A global instance of the NcDouble class within the netCDF namespace.
void ncCheck(int retCode, const char *file, int line)
Function checks error code and if necessary throws an exception.
NcUbyte ncUbyte
A global instance of the NcUbyte class within the netCDF namespace.
NcChar ncChar
A global instance of the NcChar class within the netCDF namespace.
NcByte ncByte
A global instance of the NcByte class within the netCDF namespace.