Skip to content

Commit

Permalink
C++17 readability-braces-around-statements
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaciel committed May 10, 2023
1 parent 3a17ea4 commit d18dae7
Show file tree
Hide file tree
Showing 240 changed files with 2,186 additions and 1,127 deletions.
3 changes: 2 additions & 1 deletion regressions/ECKIT-166.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ void run(int argc, char** argv) {
Main::initialise(argc, argv);

// This should initialise MPI automatically
if (mpi::comm().rank() == 0)
if (mpi::comm().rank() == 0) {
std::cout << "mpi::comm().size() = " << mpi::comm().size() << std::endl;
}
}

int main(int argc, char** argv) {
Expand Down
9 changes: 6 additions & 3 deletions src/eckit/cmd/AliasCmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ AliasCmd::~AliasCmd() {}
//----------------------------------------------------------------------------------------------------------------------

void AliasCmd::execute(std::istream&, std::ostream& out, CmdArg& arg) {
if (arg.exists(2))
if (arg.exists(2)) {
CmdParser::alias(arg[1], arg[2]);
else if (arg.exists(1))
}
else if (arg.exists(1)) {
CmdParser::alias(arg[1]);
else
}
else {
CmdParser::alias();
}
}

//----------------------------------------------------------------------------------------------------------------------
Expand Down
24 changes: 16 additions & 8 deletions src/eckit/cmd/Arg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,17 @@ class ArgContentOption : public ArgContent {
bool more = true;
while (more) {
more = false;
for (std::vector<std::string>::iterator j = v.begin(); j != v.end(); ++j)
for (std::vector<std::string>::iterator j = v.begin(); j != v.end(); ++j) {
if ((*j) == name_) {
more = true;
v.push_back("** marker **");
if ((*(j + 1))[0] != '-')
if ((*(j + 1))[0] != '-') {
v.erase(j + 1);
}
v.erase(j);
break;
}
}
}
}

Expand Down Expand Up @@ -127,8 +129,9 @@ template <class T>
void ArgContentList<T>::push(ArgContent* a) {
ArgContentList* e = dynamic_cast<T*>(a);
if (e) {
for (size_t i = 0; i < e->list_.size(); i++)
for (size_t i = 0; i < e->list_.size(); i++) {
list_.push_back(e->list_[i]->clone());
}
}
else {
list_.push_back(a->clone());
Expand All @@ -152,8 +155,9 @@ ArgContentList<T>::~ArgContentList() {
template <class T>
ArgContentList<T>::ArgContentList(const std::vector<ArgContent*>& list) :
list_(list) {
for (size_t i = 0; i < list_.size(); i++)
for (size_t i = 0; i < list_.size(); i++) {
list_[i] = list_[i]->clone();
}
}

template <class T>
Expand All @@ -163,14 +167,16 @@ ArgContent* ArgContentList<T>::clone() const {

template <class T>
void ArgContentList<T>::completion(const std::vector<std::string>& s, std::vector<std::string>& r) {
for (size_t i = 0; i < list_.size(); i++)
for (size_t i = 0; i < list_.size(); i++) {
list_[i]->completion(s, r);
}
}

template <class T>
void ArgContentList<T>::consume(std::vector<std::string>& s) {
for (size_t i = 0; i < list_.size(); i++)
for (size_t i = 0; i < list_.size(); i++) {
list_[i]->consume(s);
}
}

//----------------------------------------------------------------------------------------------------------------------
Expand All @@ -179,15 +185,17 @@ class ArgContentExclusive : public ArgContentList<ArgContentExclusive> {

void print(std::ostream& s, bool bra) const {
std::string p = "";
if (bra)
if (bra) {
s << "(";
}
for (size_t i = 0; i < list_.size(); i++) {
s << p;
list_[i]->print(s, true);
p = " | ";
}
if (bra)
if (bra) {
s << ")";
}
}

public:
Expand Down
12 changes: 8 additions & 4 deletions src/eckit/cmd/CmdApplication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ void CmdApplication::userMode() {
CmdParser::parse(command, std::cout);
}
catch (std::exception& e) {
if (fail)
if (fail) {
throw;
}

Log::error() << "** " << e.what() << " Caught in " << Here() << std::endl;
Log::error() << "** Exception is ignored" << std::endl;
Expand Down Expand Up @@ -101,8 +102,9 @@ void CmdApplication::userMode() {
break;
}
catch (std::exception& e) {
if (fail)
if (fail) {
throw;
}

Log::error() << "** " << e.what() << " Caught in " << Here() << std::endl;
Log::error() << "** Exception is ignored" << std::endl;
Expand Down Expand Up @@ -132,10 +134,12 @@ void CmdApplication::serveMode(long port) {

void CmdApplication::execute() {
long port = Resource<long>("-serve", 0);
if (port)
if (port) {
serveMode(port);
else
}
else {
userMode();
}
}

//----------------------------------------------------------------------------------------------------------------------
Expand Down
21 changes: 14 additions & 7 deletions src/eckit/cmd/CmdArg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ Value& CmdArg::operator[](const long l) {
}

void CmdArg::print(std::ostream& out) const {
for (CmdMap::const_iterator i = args_.begin(); i != args_.end(); ++i)
for (CmdMap::const_iterator i = args_.begin(); i != args_.end(); ++i) {
out << (*i).first << " = " << (*i).second << std::endl;
}
}

std::vector<std::string> CmdArg::args() const {
std::vector<std::string> result;
for (CmdMap::const_iterator i = args_.begin(); i != args_.end(); ++i)
for (CmdMap::const_iterator i = args_.begin(); i != args_.end(); ++i) {
result.push_back((*i).first);
}
return result;
}

Expand All @@ -121,18 +123,21 @@ void CmdArg::erase(long from, long to) {
long i = from;
while ((j = args_.find(Translator<long, std::string>()(i))) != args_.end()) {
CmdMap::iterator k = args_.find(Translator<long, std::string>()(to + 1 - from + i));
if (k != args_.end())
if (k != args_.end()) {
(*j).second = (*k).second;
else
}
else {
args_.erase(j);
}
++i;
}
}

void CmdArg::erase(const std::string& s) {
CmdMap::iterator j = args_.find(s);
if (j != args_.end())
if (j != args_.end()) {
args_.erase(j);
}
}

void CmdArg::operator+=(const CmdArg& other) {
Expand All @@ -144,8 +149,9 @@ void CmdArg::operator+=(const CmdArg& other) {
// Find where we start adding
long i = 0;
CmdMap::iterator j;
while ((j = args_.find(Translator<long, std::string>()(i))) != args_.end())
while ((j = args_.find(Translator<long, std::string>()(i))) != args_.end()) {
++i;
}

// Dont copy arg[0]
tmp.args_.erase(tmp.args_.find("0"));
Expand All @@ -159,8 +165,9 @@ void CmdArg::operator+=(const CmdArg& other) {
}

// Add the rest
for (CmdMap::iterator m = tmp.args_.begin(); m != tmp.args_.end(); ++m)
for (CmdMap::iterator m = tmp.args_.begin(); m != tmp.args_.end(); ++m) {
args_[(*m).first] = (*m).second;
}
}

bool CmdArg::exists(const std::string& key) const {
Expand Down
Loading

0 comments on commit d18dae7

Please sign in to comment.