Commit e0dab6c3 authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

Merge branch 'feature/string-empty-for-better-readability' into 'master'

[cleanup] use std::string::empty for better readability

See merge request !1844
parents 4de7e8c7 d5eb0bc2
......@@ -84,7 +84,7 @@ public:
bool hasKeyInGroup(const std::string& key,
const std::string& groupPrefix) const
{
if (groupPrefix == "")
if (groupPrefix.empty())
return hasKey(key);
if (hasKey(key))
......@@ -206,7 +206,7 @@ public:
const std::string& key,
const std::string& defaultValue) const
{
if (groupPrefix == "")
if (groupPrefix.empty())
return get(key, defaultValue);
// first, look for the compound key
......@@ -315,7 +315,7 @@ public:
const std::string& key,
const T& defaultValue) const
{
if (groupPrefix == "")
if (groupPrefix.empty())
return get<T>(key, defaultValue);
// first, look for the compound key
......@@ -386,7 +386,7 @@ public:
T getFromGroup(const std::string& groupPrefix,
const std::string& key) const
{
if (groupPrefix == "")
if (groupPrefix.empty())
return get<T>(key);
// first, look for the compound key
......
......@@ -122,7 +122,7 @@ public:
parameterFileName = commandLineArgs.get<std::string>("ParameterFile", parameterFileName);
// otherwise use the default name (executable name + .input)
if (parameterFileName == "")
if (parameterFileName.empty())
{
parameterFileName = [&](){
std::string defaultName = std::string(argv[0]) + ".input";
......@@ -139,7 +139,7 @@ public:
}();
// if no parameter file was given and also no default names where found, continue without
if (parameterFileName == "")
if (parameterFileName.empty())
{
if (mpiHelper.size() > 1)
std::cout << "Rank " << mpiHelper.rank() << ": ";
......@@ -392,7 +392,7 @@ private:
//! recursively merge all elements
static void mergeTreeImpl_(Dune::ParameterTree& target, const Dune::ParameterTree& source, bool overwrite, const std::string& group)
{
const auto prefix = group == "" ? "" : group + ".";
const auto prefix = group.empty() ? "" : group + ".";
for (const auto& key : source.getValueKeys())
if (overwrite || !target.hasKey(key))
target[prefix + key] = source[key];
......@@ -412,7 +412,7 @@ void setParam(Dune::ParameterTree& params,
const std::string& key,
const std::string& value)
{
if(group == "")
if(group.empty())
params[key] = value;
else
params[group + "." + key] = value;
......
......@@ -119,7 +119,7 @@ public:
// Didn't find a way to construct the grid
else
{
const auto prefix = modelParamGroup == "" ? modelParamGroup : modelParamGroup + ".";
const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup + ".";
DUNE_THROW(ParameterException, "Please supply one of the parameters "
<< prefix + "Grid.UpperRight"
<< ", or a grid file in " << prefix + "Grid.File");
......
......@@ -85,7 +85,7 @@ public:
// Didn't find a way to construct the grid
else
{
const auto prefix = modelParamGroup == "" ? modelParamGroup : modelParamGroup + ".";
const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup + ".";
DUNE_THROW(ParameterException, "Please supply one of the parameters "
<< prefix + "Grid.UpperRight"
<< ", or a grid file in " << prefix + "Grid.File");
......
......@@ -109,7 +109,7 @@ public:
// Didn't find a way to construct the grid
else
{
const auto prefix = modelParamGroup == "" ? modelParamGroup : modelParamGroup + ".";
const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup + ".";
DUNE_THROW(ParameterException, "Please supply one of the parameters "
<< prefix + "Grid.UpperRight"
<< ", or a grid file in " << prefix + "Grid.File");
......
......@@ -93,7 +93,7 @@ public:
// Didn't find a way to construct the grid
else
{
const auto prefix = modelParamGroup == "" ? modelParamGroup : modelParamGroup + ".";
const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup + ".";
DUNE_THROW(ParameterException, "Please supply one of the parameters "
<< prefix + "Grid.RightBoundary"
<< ", or " << prefix + "Grid.Coordinates"
......
......@@ -94,7 +94,7 @@ public:
}
else
{
const auto prefix = paramGroup == "" ? paramGroup : paramGroup + ".";
const auto prefix = paramGroup.empty() ? paramGroup : paramGroup + ".";
DUNE_THROW(ParameterException, "Please supply a grid file in " << prefix << "Grid.File or " << prefix << "Grid.UpperRight/Cells.");
}
}
......
......@@ -127,7 +127,7 @@ public:
<< "Use Dune::VTKWriter to write out your grid manually." << std::endl;
const auto postfix = getParamFromGroup<std::string>(paramGroup, "Problem.Name", "");
const std::string name = postfix == "" ? "subgrid" : "subgrid_" + postfix;
const std::string name = postfix.empty() ? "subgrid" : "subgrid_" + postfix;
Dune::DGFWriter<typename Grid::LeafGridView> writer(subgridPtr->leafGridView());
writer.write(name + ".dgf");
}
......@@ -140,7 +140,7 @@ public:
<< "Use Dune::VTKWriter to write out your grid manually." << std::endl;
const auto postfix = getParamFromGroup<std::string>(paramGroup, "Problem.Name", "");
const std::string name = postfix == "" ? "subgrid" : "subgrid_" + postfix;
const std::string name = postfix.empty() ? "subgrid" : "subgrid_" + postfix;
Dune::VTKWriter<typename Grid::LeafGridView> vtkWriter(subgridPtr->leafGridView());
vtkWriter.write(name);
}
......
......@@ -96,7 +96,7 @@ public:
// Didn't find a way to construct the grid
else
{
const auto prefix = modelParamGroup == "" ? modelParamGroup : modelParamGroup + ".";
const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup + ".";
DUNE_THROW(ParameterException, "Please supply one of the parameters "
<< prefix + "Grid.UpperRight"
<< ", or a grid file in " << prefix + "Grid.File");
......
......@@ -100,7 +100,7 @@ public:
// Didn't find a way to construct the grid
else
{
const auto prefix = modelParamGroup == "" ? modelParamGroup : modelParamGroup + ".";
const auto prefix = modelParamGroup.empty() ? modelParamGroup : modelParamGroup + ".";
DUNE_THROW(ParameterException, "Please supply one of the parameters "
<< prefix + "Grid.UpperRight"
<< ", or a grid file in " << prefix + "Grid.File");
......
......@@ -208,7 +208,7 @@ public:
constexpr auto prefix = isCellCenter ? "CellCenter" : "Face";
try {
if(paramGroup == "")
if(paramGroup.empty())
return NumericEpsilon<typename Traits::Scalar, numEq>(prefix);
else
return NumericEpsilon<typename Traits::Scalar, numEq>(paramGroup + "." + prefix);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment