From ac4348294416af36e3d70777898e7894f8ce1f5e Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Fri, 18 Oct 2019 08:32:49 +0200 Subject: [PATCH 1/2] Remove trailing whitespace --- python/cxx/deck_keyword.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/cxx/deck_keyword.cpp b/python/cxx/deck_keyword.cpp index 1498bdc61..57324d2af 100644 --- a/python/cxx/deck_keyword.cpp +++ b/python/cxx/deck_keyword.cpp @@ -62,7 +62,7 @@ struct DeckRecordIterator bool is_int(const std::string& s) { - return !s.empty() && std::find_if(s.begin(), + return !s.empty() && std::find_if(s.begin(), s.end(), [](char c) { return !std::isdigit(c); }) == s.end(); } @@ -72,7 +72,7 @@ void push_string_as_deck_value(std::vector& record, const std::string std::size_t star_pos = str.find('*'); if (star_pos != std::string::npos) { int multiplier = 1; - + std::string mult_str = str.substr(0, star_pos); if (mult_str.length() > 0) { @@ -94,7 +94,7 @@ void push_string_as_deck_value(std::vector& record, const std::string for (int i = 0; i < multiplier; i++) record.push_back( value ); - + } else record.push_back( DeckValue(str) ); @@ -115,7 +115,7 @@ void python::common::export_DeckKeyword(py::module& module) { py::list record = record_obj.cast(); std::vector value_record; - for (py::handle value_obj : record) { + for (py::handle value_obj : record) { try { int val_int = value_obj.cast(); @@ -132,14 +132,14 @@ void python::common::export_DeckKeyword(py::module& module) { catch (std::exception e_double) {} try { - std::string val_string = value_obj.cast(); + std::string val_string = value_obj.cast(); push_string_as_deck_value(value_record, val_string); continue; } catch (std::exception e_string) {} throw py::type_error("DeckKeyword: tried to add unkown type to record."); - + } value_record_list.push_back( value_record ); } From 1067b666967fda84156ecd1afa8c1dbd36c35376 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Fri, 18 Oct 2019 08:34:12 +0200 Subject: [PATCH 2/2] Use const& to avoiw warnings --- python/cxx/deck_keyword.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/cxx/deck_keyword.cpp b/python/cxx/deck_keyword.cpp index 57324d2af..658613054 100644 --- a/python/cxx/deck_keyword.cpp +++ b/python/cxx/deck_keyword.cpp @@ -115,28 +115,28 @@ void python::common::export_DeckKeyword(py::module& module) { py::list record = record_obj.cast(); std::vector value_record; - for (py::handle value_obj : record) { + for (const py::handle& value_obj : record) { try { int val_int = value_obj.cast(); value_record.push_back( DeckValue(val_int) ); continue; } - catch (std::exception e_int) {} + catch (const std::exception& e_int) {} try { double val_double = value_obj.cast(); value_record.push_back( DeckValue(val_double) ); continue; } - catch (std::exception e_double) {} + catch (const std::exception& e_double) {} try { std::string val_string = value_obj.cast(); push_string_as_deck_value(value_record, val_string); continue; } - catch (std::exception e_string) {} + catch (const std::exception& e_string) {} throw py::type_error("DeckKeyword: tried to add unkown type to record.");