Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernise loops #143

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
#Minimum required CMake Version
cmake_minimum_required(VERSION 2.8.12)

# Only set the cxx_standard if it is not set by someone else
if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

# strongly encouraged to enable this globally to avoid conflicts between
# -Wpedantic being enabled and -std=c++20 and -std=gnu++20 for example
# when compiling with PCH enabled
set(CMAKE_CXX_EXTENSIONS OFF)


#Project Name
PROJECT(NCXX C CXX)
set(PACKAGE "netcdf-cxx4" CACHE STRING "")
Expand Down
25 changes: 11 additions & 14 deletions cxx4/ncAtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,19 @@ NcType NcAtt::getType() const{
// get the identifier for the netCDF type of this attribute.
nc_type xtypep;
ncCheck(nc_inq_atttype(groupId,varId,myName.c_str(),&xtypep),__FILE__,__LINE__);
if(xtypep <= 12)
if (xtypep <= 12) {
// This is an atomic type
return NcType(xtypep);
else
// this is a user-defined type
{
// now get the set of NcType objects in this file.
multimap<string,NcType> typeMap(getParentGroup().getTypes(NcGroup::ParentsAndCurrent));
multimap<string,NcType>::iterator iter;
// identify the Nctype object with the same id as this attribute.
for (iter=typeMap.begin(); iter!= typeMap.end();iter++) {
if(iter->second.getId() == xtypep) return iter->second;
}
// return a null object, as no type was identified.
return NcType();
}
}
// this is a user-defined type
// now get the set of NcType objects in this file.
multimap<string,NcType> typeMap(getParentGroup().getTypes(NcGroup::ParentsAndCurrent));
// identify the Nctype object with the same id as this attribute.
for (const auto& type: typeMap) {
if(type.second.getId() == xtypep) return type.second;
}
// return a null object, as no type was identified.
return NcType();
}

// Gets attribute length.
Expand Down
3 changes: 1 addition & 2 deletions cxx4/ncDim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ bool NcDim::isUnlimited() const
// get all the unlimited dimension ids in this group
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
it = find(unlimdimid.begin(),unlimdimid.end(),myId);
const auto it = find(unlimdimid.begin(),unlimdimid.end(),myId);
return it != unlimdimid.end();
}
return false;
Expand Down
Loading