mirror of
https://github.com/Unidata/netcdf-cxx4.git
synced 2024-12-15 08:39:54 +08:00
Suppress clang-tidy warnings about implicit conversions
This commit is contained in:
parent
1f68f28275
commit
2eaaba09f1
@ -155,8 +155,7 @@ int NcCompoundType::getMemberDimCount(int memberIndex) const
|
||||
// Returns the shape of the given member.
|
||||
vector<int> NcCompoundType::getMemberShape(int memberIndex) const
|
||||
{
|
||||
vector<int> dim_size;
|
||||
dim_size.resize(getMemberDimCount(memberIndex));
|
||||
vector<int> dim_size(static_cast<std::size_t>(getMemberDimCount(memberIndex)));
|
||||
if(!dim_size.empty())
|
||||
ncCheck(nc_inq_compound_fielddim_sizes(groupId,myId,memberIndex,&dim_size[0]),__FILE__,__LINE__);
|
||||
return dim_size;
|
||||
|
@ -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<int> unlimdimid(numlimdims);
|
||||
vector<int> unlimdimid(static_cast<std::size_t>(numlimdims));
|
||||
ncCheck(nc_inq_unlimdims(groupId,&numlimdims,&unlimdimid[0]),__FILE__,__LINE__);
|
||||
vector<int>::iterator it;
|
||||
// now look to see if this dimension is unlimited
|
||||
|
@ -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<int>(ncid), static_cast<int>(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<int>(ncid), static_cast<int>(varid), idp, nparamsp, params),__FILE__,__LINE__);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "ncFloat.h"
|
||||
#include "ncDouble.h"
|
||||
#include "ncString.h"
|
||||
#include <cstddef>
|
||||
#include <ncException.h>
|
||||
#include "ncCheck.h"
|
||||
using namespace std;
|
||||
@ -193,13 +194,13 @@ multimap<std::string,NcGroup> 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<std::size_t>(getGroupCount());
|
||||
if (groupCount){
|
||||
vector<int> 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<groupCount;i++){
|
||||
for(std::size_t i=0; i<groupCount;i++){
|
||||
NcGroup tmpGroup(ncids[i]);
|
||||
ncGroups.insert(pair<const string,NcGroup>(tmpGroup.getName(),tmpGroup));
|
||||
}
|
||||
@ -319,13 +320,13 @@ multimap<std::string,NcVar> 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<std::size_t>(getVarCount());
|
||||
if (varCount){
|
||||
// now get the name of each NcVar object and populate the ncVars container.
|
||||
int* nvars=NULL;
|
||||
vector<int> varids(varCount);
|
||||
ncCheck(nc_inq_varids(myId, nvars,&varids[0]),__FILE__,__LINE__);
|
||||
for(int i=0; i<varCount;i++){
|
||||
for(std::size_t i=0; i<varCount;i++){
|
||||
NcVar tmpVar(*this,varids[i]);
|
||||
ncVars.insert(pair<const string,NcVar>(tmpVar.getName(),tmpVar));
|
||||
}
|
||||
@ -338,13 +339,13 @@ multimap<std::string,NcVar> 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<std::size_t>(tmpGroup.getVarCount());
|
||||
if (varCount){
|
||||
// now get the name of each NcVar object and populate the ncVars container.
|
||||
int* nvars=NULL;
|
||||
vector<int> varids(varCount);
|
||||
ncCheck(nc_inq_varids(tmpGroup.getId(), nvars,&varids[0]),__FILE__,__LINE__);
|
||||
for(int i=0; i<varCount;i++){
|
||||
for(std::size_t i=0; i<varCount;i++){
|
||||
NcVar tmpVar(tmpGroup,varids[i]);
|
||||
ncVars.insert(pair<const string,NcVar>(tmpVar.getName(),tmpVar));
|
||||
}
|
||||
@ -943,12 +944,12 @@ multimap<string,NcDim> 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<std::size_t>(getDimCount());
|
||||
if (dimCount){
|
||||
vector<int> 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<dimCount;i++){
|
||||
for(std::size_t i=0; i<dimCount;i++){
|
||||
NcDim tmpDim(*this,dimids[i]);
|
||||
ncDims.insert(pair<const string,NcDim>(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<int> typeids(ntypesp);
|
||||
vector<int> typeids(static_cast<std::size_t>(ntypesp));
|
||||
ncCheck(nc_inq_typeids(getId(), &ntypesp,&typeids[0]),__FILE__,__LINE__);
|
||||
for (int i=0; i<ntypesp;i++){
|
||||
for (std::size_t i=0; i<static_cast<std::size_t>(ntypesp); i++){
|
||||
NcType tmpType(*this,typeids[i]);
|
||||
if(tmpType.getTypeClass() == enumType) ntypes++;
|
||||
}
|
||||
@ -1126,12 +1127,12 @@ multimap<string,NcType> 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<std::size_t>(getTypeCount());
|
||||
if (typeCount){
|
||||
vector<int> 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<typeCount;i++){
|
||||
for(std::size_t i=0; i<typeCount;i++){
|
||||
NcType tmpType(*this,typeids[i]);
|
||||
ncTypes.insert(pair<const string,NcType>(tmpType.getName(),tmpType));
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "ncGroup.h"
|
||||
#include "ncCheck.h"
|
||||
#include "ncException.h"
|
||||
#include <cstddef>
|
||||
#include<netcdf.h>
|
||||
using namespace std;
|
||||
using namespace netCDF::exceptions;
|
||||
@ -151,14 +152,14 @@ int NcVar::getDimCount() const
|
||||
vector<NcDim> NcVar::getDims() const
|
||||
{
|
||||
// get the number of dimensions
|
||||
int dimCount = getDimCount();
|
||||
const auto dimCount = static_cast<std::size_t>(getDimCount());
|
||||
// create a vector of dimensions.
|
||||
vector<NcDim> ncDims;
|
||||
if (dimCount){
|
||||
vector<int> dimids(dimCount);
|
||||
ncCheck(nc_inq_vardimid(groupId,myId, &dimids[0]),__FILE__,__LINE__);
|
||||
ncDims.reserve(dimCount);
|
||||
for (int i=0; i<dimCount; i++){
|
||||
for (std::size_t i = 0; i < dimCount; i++) {
|
||||
NcDim tmpDim(getParentGroup(),dimids[i]);
|
||||
ncDims.push_back(tmpDim);
|
||||
}
|
||||
@ -172,7 +173,7 @@ NcDim NcVar::getDim(int i) const
|
||||
{
|
||||
vector<NcDim> 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<std::size_t>(i)];
|
||||
}
|
||||
|
||||
|
||||
@ -549,7 +550,7 @@ void NcVar::setChunking(ChunkMode chunkMode, vector<size_t>& chunkSizes) const {
|
||||
// Gets the chunking parameters
|
||||
void NcVar::getChunkingParameters(ChunkMode& chunkMode, vector<size_t>& chunkSizes) const {
|
||||
int chunkModeInt;
|
||||
chunkSizes.resize(getDimCount());
|
||||
chunkSizes.resize(static_cast<std::size_t>(getDimCount()));
|
||||
size_t *chunkSizesPtr = chunkSizes.empty() ? 0 : &chunkSizes[0];
|
||||
ncCheck(nc_inq_var_chunking(groupId,myId, &chunkModeInt, chunkSizesPtr),__FILE__,__LINE__);
|
||||
chunkMode = static_cast<ChunkMode> (chunkModeInt);
|
||||
|
Loading…
Reference in New Issue
Block a user