diff --git a/cxx4/ncCompoundType.cpp b/cxx4/ncCompoundType.cpp index c50c3c4..7698946 100644 --- a/cxx4/ncCompoundType.cpp +++ b/cxx4/ncCompoundType.cpp @@ -79,7 +79,7 @@ NcCompoundType::NcCompoundType(const NcType& rhs): // Inserts a named field. void NcCompoundType::addMember(const string& memberName, const NcType& newMemberType,size_t offset) { - ncCheck(nc_insert_compound(groupId,myId,const_cast(memberName.c_str()),offset,newMemberType.getId()),__FILE__,__LINE__); + ncCheck(nc_insert_compound(groupId,myId, memberName.c_str(),offset,newMemberType.getId()),__FILE__,__LINE__); } @@ -88,7 +88,7 @@ void NcCompoundType::addMember(const string& memberName, const NcType& newMember void NcCompoundType::addMember(const string& memberName, const NcType& newMemberType, size_t offset, const vector& shape) { if (!shape.empty()) - ncCheck(nc_insert_array_compound(groupId, myId,const_cast(memberName.c_str()), offset, newMemberType.getId(), shape.size(), const_cast(&shape[0])),__FILE__,__LINE__); + ncCheck(nc_insert_array_compound(groupId, myId, memberName.c_str(), offset, newMemberType.getId(), static_cast(shape.size()), &shape[0]),__FILE__,__LINE__); else addMember(memberName, newMemberType, offset); } @@ -155,8 +155,7 @@ int NcCompoundType::getMemberDimCount(int memberIndex) const // Returns the shape of the given member. vector NcCompoundType::getMemberShape(int memberIndex) const { - vector dim_size; - dim_size.resize(getMemberDimCount(memberIndex)); + vector dim_size(static_cast(getMemberDimCount(memberIndex))); if(!dim_size.empty()) ncCheck(nc_inq_compound_fielddim_sizes(groupId,myId,memberIndex,&dim_size[0]),__FILE__,__LINE__); return dim_size; diff --git a/cxx4/ncDim.cpp b/cxx4/ncDim.cpp index a0f3aa8..c207b37 100644 --- a/cxx4/ncDim.cpp +++ b/cxx4/ncDim.cpp @@ -91,7 +91,7 @@ bool NcDim::isUnlimited() const ncCheck(nc_inq_unlimdims(groupId,&numlimdims,unlimdimidsp),__FILE__,__LINE__); if (numlimdims){ // get all the unlimited dimension ids in this group - vector unlimdimid(numlimdims); + vector unlimdimid(static_cast(numlimdims)); ncCheck(nc_inq_unlimdims(groupId,&numlimdims,&unlimdimid[0]),__FILE__,__LINE__); vector::iterator it; // now look to see if this dimension is unlimited diff --git a/cxx4/ncFilter.cpp b/cxx4/ncFilter.cpp index 4516027..b3ff766 100644 --- a/cxx4/ncFilter.cpp +++ b/cxx4/ncFilter.cpp @@ -18,12 +18,12 @@ NcFilter::~NcFilter() { method allows for setting of the filter which is to be used wen writing a variable. */ void NcFilter::setFilter(unsigned int ncid, unsigned int varid, unsigned int filterId, size_t nparams, const unsigned int* parms) { - ncCheck(nc_def_var_filter(ncid,varid,filterId,nparams,parms),__FILE__,__LINE__); + ncCheck(nc_def_var_filter(static_cast(ncid), static_cast(varid),filterId,nparams,parms),__FILE__,__LINE__); } /* This second API method makes it possible to query a varible to obtain information about any associated filter using this signature */ void NcFilter::getFilter(unsigned int ncid, unsigned int varid, unsigned int* idp, size_t* nparamsp, unsigned int* params) { - ncCheck(nc_inq_var_filter(ncid, varid, idp, nparamsp, params),__FILE__,__LINE__); + ncCheck(nc_inq_var_filter(static_cast(ncid), static_cast(varid), idp, nparamsp, params),__FILE__,__LINE__); } diff --git a/cxx4/ncGroup.cpp b/cxx4/ncGroup.cpp index 5be5bde..aa543f1 100644 --- a/cxx4/ncGroup.cpp +++ b/cxx4/ncGroup.cpp @@ -17,6 +17,7 @@ #include "ncFloat.h" #include "ncDouble.h" #include "ncString.h" +#include #include #include "ncCheck.h" using namespace std; @@ -165,14 +166,14 @@ int NcGroup::getGroupCount(NcGroup::GroupLocation location) const { // search in parent groups if(location == ParentsGrps || location == ParentsAndCurrentGrps || location == AllGrps ) { multimap groups(getGroups(ParentsGrps)); - ngroups += groups.size(); + ngroups += static_cast(groups.size()); } // get the number of all children that are childreof children if(location == ChildrenOfChildrenGrps || location == AllChildrenGrps || location == AllGrps ) { multimap groups(getGroups(ChildrenOfChildrenGrps)); - ngroups += groups.size(); + ngroups += static_cast(groups.size()); } return ngroups; @@ -193,13 +194,13 @@ multimap NcGroup::getGroups(NcGroup::GroupLocation location // the child groups of the current group if(location == ChildrenGrps || location == AllChildrenGrps || location == AllGrps ) { // get the number of groups - int groupCount = getGroupCount(); + const auto groupCount = static_cast(getGroupCount()); if (groupCount){ vector ncids(groupCount); int* numgrps=NULL; // now get the id of each NcGroup and populate the ncGroups container. ncCheck(nc_inq_grps(myId, numgrps,&ncids[0]),__FILE__,__LINE__); - for(int i=0; i(tmpGroup.getName(),tmpGroup)); } @@ -265,7 +266,7 @@ set NcGroup::getGroups(const std::string& name,NcGroup::GroupLocation l NcGroup NcGroup::addGroup(const string& name) const { if(isNull()) throw NcNullGrp("Attempt to invoke NcGroup::addGroup on a Null group",__FILE__,__LINE__); int new_ncid; - ncCheck(nc_def_grp(myId,const_cast (name.c_str()),&new_ncid),__FILE__,__LINE__); + ncCheck(nc_def_grp(myId, name.c_str(), &new_ncid),__FILE__,__LINE__); return NcGroup(new_ncid); } @@ -319,13 +320,13 @@ multimap NcGroup::getVars(NcGroup::Location location) const { NcGroup tmpGroup(*this); if((location == ParentsAndCurrent || location == ChildrenAndCurrent || location == Current || location ==All) && !tmpGroup.isNull()) { // get the number of variables. - int varCount = getVarCount(); + const auto varCount = static_cast(getVarCount()); if (varCount){ // now get the name of each NcVar object and populate the ncVars container. int* nvars=NULL; vector varids(varCount); ncCheck(nc_inq_varids(myId, nvars,&varids[0]),__FILE__,__LINE__); - for(int i=0; i(tmpVar.getName(),tmpVar)); } @@ -338,13 +339,13 @@ multimap NcGroup::getVars(NcGroup::Location location) const { tmpGroup=getParentGroup(); while(!tmpGroup.isNull()) { // get the number of variables - int varCount = tmpGroup.getVarCount(); + const auto varCount = static_cast(tmpGroup.getVarCount()); if (varCount){ // now get the name of each NcVar object and populate the ncVars container. int* nvars=NULL; vector varids(varCount); ncCheck(nc_inq_varids(tmpGroup.getId(), nvars,&varids[0]),__FILE__,__LINE__); - for(int i=0; i(tmpVar.getName(),tmpVar)); } @@ -465,7 +466,7 @@ NcVar NcGroup::addVar(const string& name, const string& typeName, const vector(dimIds.size()), dimIdsPtr,&varId),__FILE__,__LINE__); // return an NcVar object for this new variable return NcVar(*this,varId); } @@ -493,7 +494,7 @@ NcVar NcGroup::addVar(const string& name, const NcType& ncType, const vector(dimIds.size()), dimIdsPtr,&varId),__FILE__,__LINE__); // return an NcVar object for this new variable return NcVar(*this,varId); } @@ -943,12 +944,12 @@ multimap NcGroup::getDims(NcGroup::Location location) const { // search in current group if(location == Current || location == ParentsAndCurrent || location == ChildrenAndCurrent || location == All ) { - int dimCount = getDimCount(); + const auto dimCount = static_cast(getDimCount()); if (dimCount){ vector dimids(dimCount); - ncCheck(nc_inq_dimids(getId(), &dimCount, &dimids[0], 0),__FILE__,__LINE__); + ncCheck(nc_inq_dimids(getId(), nullptr, &dimids[0], 0),__FILE__,__LINE__); // now get the name of each NcDim and populate the nDims container. - for(int i=0; i(tmpDim.getName(),tmpDim)); } @@ -1088,9 +1089,9 @@ int NcGroup::getTypeCount(NcType::ncType enumType, NcGroup::Location location) c int* typeidsp=NULL; ncCheck(nc_inq_typeids(getId(), &ntypesp,typeidsp),__FILE__,__LINE__); if (ntypesp){ - vector typeids(ntypesp); + vector typeids(static_cast(ntypesp)); ncCheck(nc_inq_typeids(getId(), &ntypesp,&typeids[0]),__FILE__,__LINE__); - for (int i=0; i(ntypesp); i++){ NcType tmpType(*this,typeids[i]); if(tmpType.getTypeClass() == enumType) ntypes++; } @@ -1126,12 +1127,12 @@ multimap NcGroup::getTypes(NcGroup::Location location) const { // search in current group if(location == Current || location == ParentsAndCurrent || location == ChildrenAndCurrent || location == All ) { - int typeCount = getTypeCount(); + const auto typeCount = static_cast(getTypeCount()); if (typeCount){ vector typeids(typeCount); - ncCheck(nc_inq_typeids(getId(), &typeCount,&typeids[0]),__FILE__,__LINE__); + ncCheck(nc_inq_typeids(getId(), nullptr, &typeids[0]),__FILE__,__LINE__); // now get the name of each NcType and populate the nTypes container. - for(int i=0; i(tmpType.getName(),tmpType)); } @@ -1271,7 +1272,7 @@ NcEnumType NcGroup::addEnumType(const string& name,NcEnumType::ncEnumType baseTy NcVlenType NcGroup::addVlenType(const string& name,NcType& baseType) const { ncCheckDefineMode(myId); nc_type typeId; - ncCheck(nc_def_vlen(myId, const_cast(name.c_str()),baseType.getId(),&typeId),__FILE__,__LINE__); + ncCheck(nc_def_vlen(myId, name.c_str(), baseType.getId(),&typeId),__FILE__,__LINE__); NcVlenType ncTypeTmp(*this,name); return ncTypeTmp; } @@ -1281,7 +1282,7 @@ NcVlenType NcGroup::addVlenType(const string& name,NcType& baseType) const { NcOpaqueType NcGroup::addOpaqueType(const string& name, size_t size) const { ncCheckDefineMode(myId); nc_type typeId; - ncCheck(nc_def_opaque(myId, size,const_cast(name.c_str()), &typeId),__FILE__,__LINE__); + ncCheck(nc_def_opaque(myId, size, name.c_str(), &typeId),__FILE__,__LINE__); NcOpaqueType ncTypeTmp(*this,name); return ncTypeTmp; } @@ -1290,7 +1291,7 @@ NcOpaqueType NcGroup::addOpaqueType(const string& name, size_t size) const { NcCompoundType NcGroup::addCompoundType(const string& name, size_t size) const { ncCheckDefineMode(myId); nc_type typeId; - ncCheck(nc_def_compound(myId, size,const_cast(name.c_str()),&typeId),__FILE__,__LINE__); + ncCheck(nc_def_compound(myId, size, name.c_str(), &typeId),__FILE__,__LINE__); NcCompoundType ncTypeTmp(*this,name); return ncTypeTmp; } diff --git a/cxx4/ncVar.cpp b/cxx4/ncVar.cpp index 16a99c2..76d4feb 100644 --- a/cxx4/ncVar.cpp +++ b/cxx4/ncVar.cpp @@ -4,6 +4,7 @@ #include "ncGroup.h" #include "ncCheck.h" #include "ncException.h" +#include #include using namespace std; using namespace netCDF::exceptions; @@ -151,14 +152,14 @@ int NcVar::getDimCount() const vector NcVar::getDims() const { // get the number of dimensions - int dimCount = getDimCount(); + const auto dimCount = static_cast(getDimCount()); // create a vector of dimensions. vector ncDims; if (dimCount){ vector dimids(dimCount); ncCheck(nc_inq_vardimid(groupId,myId, &dimids[0]),__FILE__,__LINE__); ncDims.reserve(dimCount); - for (int i=0; i ncDims = getDims(); if((size_t)i >= ncDims.size() || i < 0) throw NcException("Index out of range",__FILE__,__LINE__); - return ncDims[i]; + return ncDims[static_cast(i)]; } @@ -549,7 +550,7 @@ void NcVar::setChunking(ChunkMode chunkMode, vector& chunkSizes) const { // Gets the chunking parameters void NcVar::getChunkingParameters(ChunkMode& chunkMode, vector& chunkSizes) const { int chunkModeInt; - chunkSizes.resize(getDimCount()); + chunkSizes.resize(static_cast(getDimCount())); size_t *chunkSizesPtr = chunkSizes.empty() ? 0 : &chunkSizes[0]; ncCheck(nc_inq_var_chunking(groupId,myId, &chunkModeInt, chunkSizesPtr),__FILE__,__LINE__); chunkMode = static_cast (chunkModeInt);