diff --git a/.clang-format b/.clang-format index 88c79367..1ba7e85c 100644 --- a/.clang-format +++ b/.clang-format @@ -29,6 +29,7 @@ BraceWrapping: # alignment PointerAlignment: Left ReferenceAlignment: Left +QualifierAlignment: Right NamespaceIndentation: All AlignConsecutiveAssignments: true AlignTrailingComments: false diff --git a/examples/iguana-example-00-basic.cc b/examples/iguana-example-00-basic.cc index 9c143a3f..750c20aa 100644 --- a/examples/iguana-example-00-basic.cc +++ b/examples/iguana-example-00-basic.cc @@ -13,8 +13,8 @@ int main(int argc, char** argv) // parse arguments int argi = 1; - const char* inFileName = argc > argi ? argv[argi++] : "data.hipo"; - const int numEvents = argc > argi ? std::stoi(argv[argi++]) : 1; + char const* inFileName = argc > argi ? argv[argi++] : "data.hipo"; + int const numEvents = argc > argi ? std::stoi(argv[argi++]) : 1; // read input file hipo::reader reader(inFileName); diff --git a/examples/iguana-example-01-bank-rows.cc b/examples/iguana-example-01-bank-rows.cc index 9945c519..f2437669 100644 --- a/examples/iguana-example-01-bank-rows.cc +++ b/examples/iguana-example-01-bank-rows.cc @@ -7,8 +7,8 @@ int main(int argc, char** argv) // parse arguments int argi = 1; - const char* inFileName = argc > argi ? argv[argi++] : "data.hipo"; - const int numEvents = argc > argi ? std::stoi(argv[argi++]) : 1; + char const* inFileName = argc > argi ? argv[argi++] : "data.hipo"; + int const numEvents = argc > argi ? std::stoi(argv[argi++]) : 1; // read input file hipo::reader reader(inFileName); diff --git a/src/iguana/algorithms/Algorithm.cc b/src/iguana/algorithms/Algorithm.cc index 9ecbe112..2d6f28f0 100644 --- a/src/iguana/algorithms/Algorithm.cc +++ b/src/iguana/algorithms/Algorithm.cc @@ -26,7 +26,7 @@ namespace iguana { } return val; } - catch(const std::runtime_error& ex) { + catch(std::runtime_error const& ex) { m_log->Error("Failed to `GetOptionScalar` for key '{}'", key); throw std::runtime_error("config file parsing issue"); } @@ -50,7 +50,7 @@ namespace iguana { } return val; } - catch(const std::runtime_error& ex) { + catch(std::runtime_error const& ex) { m_log->Error("Failed to `GetOptionVector` for key '{}'", key); throw std::runtime_error("config file parsing issue"); } @@ -158,19 +158,19 @@ namespace iguana { { if(auto it{m_option_cache.find(key)}; it != m_option_cache.end()) { auto val = it->second; - if(const auto valPtr(std::get_if(&val)); valPtr) + if(auto const valPtr(std::get_if(&val)); valPtr) return fmt::format("{} [{}]", *valPtr, "int"); - else if(const auto valPtr(std::get_if(&val)); valPtr) + else if(auto const valPtr(std::get_if(&val)); valPtr) return fmt::format("{} [{}]", *valPtr, "double"); - else if(const auto valPtr(std::get_if(&val)); valPtr) + else if(auto const valPtr(std::get_if(&val)); valPtr) return fmt::format("{:?} [{}]", *valPtr, "string"); - else if(const auto valPtr(std::get_if>(&val)); valPtr) + else if(auto const valPtr(std::get_if>(&val)); valPtr) return fmt::format("({}) [{}]", fmt::join(*valPtr, ", "), "vector"); - else if(const auto valPtr(std::get_if>(&val)); valPtr) + else if(auto const valPtr(std::get_if>(&val)); valPtr) return fmt::format("({}) [{}]", fmt::join(*valPtr, ", "), "vector"); - else if(const auto valPtr(std::get_if>(&val)); valPtr) { + else if(auto const valPtr(std::get_if>(&val)); valPtr) { std::vector valQuoted; - for(const auto& s : *valPtr) + for(auto const& s : *valPtr) valQuoted.push_back(fmt::format("{:?}", s)); return fmt::format("({}) [{}]", fmt::join(valQuoted, ", "), "vector"); } @@ -199,7 +199,7 @@ namespace iguana { else return result; } - catch(const std::out_of_range& o) { + catch(std::out_of_range const& o) { m_log->Error("required input bank '{}' not found; cannot `Run` algorithm '{}'", expected_bank_name, m_class_name); auto creators = AlgorithmFactory::QueryNewBank(expected_bank_name); if(creators) @@ -211,7 +211,7 @@ namespace iguana { /////////////////////////////////////////////////////////////////////////////// - void Algorithm::MaskRow(hipo::bank& bank, const int row) const + void Algorithm::MaskRow(hipo::bank& bank, int const row) const { // TODO: need https://github.com/gavalian/hipo/issues/35 // until then, just set the PID to -1 @@ -282,7 +282,7 @@ namespace iguana { try { // get the expected type return std::get(it->second); } - catch(const std::bad_variant_access& ex) { + catch(std::bad_variant_access const& ex) { m_log->Warn("user called SetOption for option '{}' and set it to '{}', which is the wrong type; IGNORING", key, PrintOptionValue(key)); } } diff --git a/src/iguana/algorithms/Algorithm.h b/src/iguana/algorithms/Algorithm.h index b70549a4..e75d805e 100644 --- a/src/iguana/algorithms/Algorithm.h +++ b/src/iguana/algorithms/Algorithm.h @@ -82,7 +82,7 @@ namespace iguana { if(key == "log") { if constexpr(std::disjunction< std::is_same, - std::is_same, + std::is_same, std::is_same>::value) m_log->SetLevel(val); else @@ -162,7 +162,7 @@ namespace iguana { /// Mask a row, setting all items to zero /// @param bank the bank to modify /// @param row the row to mask - void MaskRow(hipo::bank& bank, const int row) const; + void MaskRow(hipo::bank& bank, int const row) const; /// Create a new bank and push it to the bank list /// @param [out] banks the `hipo::banklist` onto which the new bank will be pushed @@ -254,17 +254,17 @@ namespace iguana { /// @param creator the creator function /// @param new_banks if this algorithm creates *new* banks, list them here /// @returns true if the algorithm has not yet been registered - static bool Register(const std::string& name, algo_creator_t creator, const std::vector new_banks = {}) noexcept; + static bool Register(std::string const& name, algo_creator_t creator, const std::vector new_banks = {}) noexcept; /// Create an algorithm. Throws an exception if the algorithm cannot be created /// @param name the name of the algorithm, which was used as an argument in the `AlgorithmFactory::Register` call /// @returns the algorithm instance - static algo_t Create(const std::string& name) noexcept(false); + static algo_t Create(std::string const& name) noexcept(false); /// Check if a bank is created by an algorithm /// @param bank_name the name of the bank /// @returns the list of algorithms which create it, if any - static std::optional> QueryNewBank(const std::string& bank_name) noexcept; + static std::optional> QueryNewBank(std::string const& bank_name) noexcept; private: diff --git a/src/iguana/algorithms/AlgorithmFactory.cc b/src/iguana/algorithms/AlgorithmFactory.cc index 1bb2bf7e..1d00bfb4 100644 --- a/src/iguana/algorithms/AlgorithmFactory.cc +++ b/src/iguana/algorithms/AlgorithmFactory.cc @@ -5,11 +5,11 @@ namespace iguana { std::unordered_map AlgorithmFactory::s_creators; std::unordered_map> AlgorithmFactory::s_created_banks; - bool AlgorithmFactory::Register(const std::string& name, algo_creator_t creator, const std::vector new_banks) noexcept + bool AlgorithmFactory::Register(std::string const& name, algo_creator_t creator, const std::vector new_banks) noexcept { if(auto it = s_creators.find(name); it == s_creators.end()) { s_creators.insert({name, creator}); - for(const auto& new_bank : new_banks) { + for(auto const& new_bank : new_banks) { if(auto it = s_created_banks.find(new_bank); it == s_created_banks.end()) s_created_banks.insert({new_bank, {}}); s_created_banks.at(new_bank).push_back(name); @@ -19,14 +19,14 @@ namespace iguana { return false; } - algo_t AlgorithmFactory::Create(const std::string& name) + algo_t AlgorithmFactory::Create(std::string const& name) { if(auto it = s_creators.find(name); it != s_creators.end()) return it->second(); throw std::runtime_error(fmt::format("AlgorithmFactory: algorithm with name {:?} does not exist", name)); } - std::optional> AlgorithmFactory::QueryNewBank(const std::string& bank_name) noexcept + std::optional> AlgorithmFactory::QueryNewBank(std::string const& bank_name) noexcept { if(auto it = s_created_banks.find(bank_name); it != s_created_banks.end()) return it->second; diff --git a/src/iguana/algorithms/AlgorithmSequence.cc b/src/iguana/algorithms/AlgorithmSequence.cc index bee525b7..0022601b 100644 --- a/src/iguana/algorithms/AlgorithmSequence.cc +++ b/src/iguana/algorithms/AlgorithmSequence.cc @@ -6,17 +6,17 @@ namespace iguana { void AlgorithmSequence::Start(hipo::banklist& banks) { - for(const auto& algo : m_sequence) + for(auto const& algo : m_sequence) algo->Start(banks); } void AlgorithmSequence::Run(hipo::banklist& banks) const { - for(const auto& algo : m_sequence) + for(auto const& algo : m_sequence) algo->Run(banks); } void AlgorithmSequence::Stop() { - for(const auto& algo : m_sequence) + for(auto const& algo : m_sequence) algo->Stop(); } @@ -49,7 +49,7 @@ namespace iguana { void AlgorithmSequence::SetName(const std::string name) { // change the `m_name+"|"` prefix of each algorithm - for(const auto& algo : m_sequence) { + for(auto const& algo : m_sequence) { auto algoName = algo->GetName(); if(auto pos{algoName.find("|")}; pos != algoName.npos) algo->SetName(name + algoName.substr(pos)); @@ -63,7 +63,7 @@ namespace iguana { void AlgorithmSequence::PrintSequence(Logger::Level level) const { m_log->Print(level, "algorithms in this sequence:"); - for(const auto& algo : m_sequence) + for(auto const& algo : m_sequence) m_log->Print(level, " - {}", algo->GetName()); } diff --git a/src/iguana/algorithms/clas12/EventBuilderFilter.cc b/src/iguana/algorithms/clas12/EventBuilderFilter.cc index 8f4f2ab8..cf8d9b1e 100644 --- a/src/iguana/algorithms/clas12/EventBuilderFilter.cc +++ b/src/iguana/algorithms/clas12/EventBuilderFilter.cc @@ -39,7 +39,7 @@ namespace iguana::clas12 { } - bool EventBuilderFilter::Filter(const int pid) const + bool EventBuilderFilter::Filter(int const pid) const { return o_pids.find(pid) != o_pids.end(); } diff --git a/src/iguana/algorithms/clas12/EventBuilderFilter.h b/src/iguana/algorithms/clas12/EventBuilderFilter.h index 579cc9d1..78943c09 100644 --- a/src/iguana/algorithms/clas12/EventBuilderFilter.h +++ b/src/iguana/algorithms/clas12/EventBuilderFilter.h @@ -19,7 +19,7 @@ namespace iguana::clas12 { /// **Action function**: checks if the PDG `pid` is a part of the list of user-specified PDGs /// @param pid the particle PDG to check /// @returns `true` if `pid` is one the user wants - bool Filter(const int pid) const; + bool Filter(int const pid) const; private: diff --git a/src/iguana/algorithms/clas12/MomentumCorrection.cc b/src/iguana/algorithms/clas12/MomentumCorrection.cc index 4c7302e4..3122303f 100644 --- a/src/iguana/algorithms/clas12/MomentumCorrection.cc +++ b/src/iguana/algorithms/clas12/MomentumCorrection.cc @@ -63,7 +63,7 @@ namespace iguana::clas12 { } - double MomentumCorrection::CorrectionInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int sec, const int pid) const + double MomentumCorrection::CorrectionInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const sec, int const pid) const { // skip the correction if it's not defined @@ -241,7 +241,7 @@ namespace iguana::clas12 { } - double MomentumCorrection::CorrectionOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int sec, const int pid) const + double MomentumCorrection::CorrectionOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const sec, int const pid) const { // skip the correction if it's not defined @@ -356,7 +356,7 @@ namespace iguana::clas12 { } - double MomentumCorrection::EnergyLossInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int pid) const + double MomentumCorrection::EnergyLossInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const pid) const { // The following code is for the Energy Loss Corrections for the proton @@ -378,7 +378,7 @@ namespace iguana::clas12 { } - double MomentumCorrection::EnergyLossOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int pid) const + double MomentumCorrection::EnergyLossOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const pid) const { // The following code is for the Energy Loss Corrections for the proton diff --git a/src/iguana/algorithms/clas12/MomentumCorrection.h b/src/iguana/algorithms/clas12/MomentumCorrection.h index 82385484..55b7d72c 100644 --- a/src/iguana/algorithms/clas12/MomentumCorrection.h +++ b/src/iguana/algorithms/clas12/MomentumCorrection.h @@ -37,7 +37,7 @@ namespace iguana::clas12 { /// @param sec the sector /// @param pid the particle PDG /// @returns the correction factor - double CorrectionInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int sec, const int pid) const; + double CorrectionInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const sec, int const pid) const; /// Calculate the correction factor for outbending data /// @param Px @f$p_x@f$ @@ -46,7 +46,7 @@ namespace iguana::clas12 { /// @param sec the sector /// @param pid the particle PDG /// @returns the correction factor - double CorrectionOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int sec, const int pid) const; + double CorrectionOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const sec, int const pid) const; /// Energy loss correction for inbending data /// @param Px @f$p_x@f$ @@ -54,7 +54,7 @@ namespace iguana::clas12 { /// @param Pz @f$p_z@f$ /// @param pid the particle PDG /// @returns the correction factor - double EnergyLossInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int pid) const; + double EnergyLossInbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const pid) const; /// Energy loss correction for outbending data /// @param Px @f$p_x@f$ @@ -62,7 +62,7 @@ namespace iguana::clas12 { /// @param Pz @f$p_z@f$ /// @param pid the particle PDG /// @returns the correction factor - double EnergyLossOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, const int pid) const; + double EnergyLossOutbending(const vector_element_t Px, const vector_element_t Py, const vector_element_t Pz, int const pid) const; private: diff --git a/src/iguana/algorithms/clas12/MomentumCorrectionValidator.cc b/src/iguana/algorithms/clas12/MomentumCorrectionValidator.cc index b12845a9..685981b8 100644 --- a/src/iguana/algorithms/clas12/MomentumCorrectionValidator.cc +++ b/src/iguana/algorithms/clas12/MomentumCorrectionValidator.cc @@ -32,7 +32,7 @@ namespace iguana::clas12 { // define plots gStyle->SetOptStat(0); - for(const auto& pdg : u_pdg_list) { + for(auto const& pdg : u_pdg_list) { std::vector deltaPvsP; TString particle_name = particle::name.at(particle::PDG(pdg)); TString particle_title = particle::title.at(particle::PDG(pdg)); @@ -96,14 +96,14 @@ namespace iguana::clas12 { void MomentumCorrectionValidator::Stop() { if(GetOutputDirectory()) { - for(const auto& [pdg, plots] : u_deltaPvsP) { + for(auto const& [pdg, plots] : u_deltaPvsP) { int n_cols = 3; int n_rows = 2; TString canv_name = Form("canv%d", pdg); auto canv = new TCanvas(canv_name, canv_name, n_cols * 800, n_rows * 600); canv->Divide(n_cols, n_rows); int pad_num = 0; - for(const auto& plot : plots) { + for(auto const& plot : plots) { auto pad = canv->GetPad(++pad_num); pad->cd(); pad->SetGrid(1, 1); diff --git a/src/iguana/algorithms/clas12/MomentumCorrectionValidator.h b/src/iguana/algorithms/clas12/MomentumCorrectionValidator.h index 8ccaeb4f..deac947e 100644 --- a/src/iguana/algorithms/clas12/MomentumCorrectionValidator.h +++ b/src/iguana/algorithms/clas12/MomentumCorrectionValidator.h @@ -28,9 +28,9 @@ namespace iguana::clas12 { std::unique_ptr m_sector_finder; - const double m_p_max = 12.0; - const double m_deltaP_max = 1.0; - const double m_deltaP_zoom = 0.2; + double const m_p_max = 12.0; + double const m_deltaP_max = 1.0; + double const m_deltaP_zoom = 0.2; const std::vector u_pdg_list = { particle::PDG::electron, diff --git a/src/iguana/algorithms/clas12/SectorFinder.cc b/src/iguana/algorithms/clas12/SectorFinder.cc index 3092e2d2..af1a5919 100644 --- a/src/iguana/algorithms/clas12/SectorFinder.cc +++ b/src/iguana/algorithms/clas12/SectorFinder.cc @@ -32,7 +32,7 @@ namespace iguana::clas12 { { } - int SectorFinder::GetSector(const hipo::bank& bank, const int pindex) const + int SectorFinder::GetSector(hipo::bank const& bank, int const pindex) const { int sector = 0; for(int row = 0; row < bank.getRows(); row++) { @@ -46,11 +46,11 @@ namespace iguana::clas12 { std::vector SectorFinder::Find(hipo::banklist& banks) const { std::vector sectors; - const auto& particleBank = GetBank(banks, b_particle, "REC::Particle"); + auto const& particleBank = GetBank(banks, b_particle, "REC::Particle"); // filter the input bank for requested PDG code(s) if(userSpecifiedBank) { // if user specified a specific bank - const auto& userBank = GetBank(banks, b_user); + auto const& userBank = GetBank(banks, b_user); for(int row = 0; row < particleBank.getRows(); row++) { if(userBank.getRows() > 0) { sectors.push_back(GetSector(userBank, row)); @@ -62,9 +62,9 @@ namespace iguana::clas12 { } } else { // use the standard method - const auto& calBank = GetBank(banks, b_calorimeter); - const auto& scintBank = GetBank(banks, b_scint); - const auto& trackBank = GetBank(banks, b_track); + auto const& calBank = GetBank(banks, b_calorimeter); + auto const& scintBank = GetBank(banks, b_scint); + auto const& trackBank = GetBank(banks, b_track); for(int row = 0; row < particleBank.getRows(); row++) { int trackSector = 0; if(trackBank.getRows() > 0) { diff --git a/src/iguana/algorithms/clas12/SectorFinder.h b/src/iguana/algorithms/clas12/SectorFinder.h index 3bd1e0cc..55f76578 100644 --- a/src/iguana/algorithms/clas12/SectorFinder.h +++ b/src/iguana/algorithms/clas12/SectorFinder.h @@ -28,7 +28,7 @@ namespace iguana::clas12 { /// @param bank bank to get sector from /// @param pindex index in bank for which to get sector /// @returns sector for pindex in bank - int GetSector(const hipo::bank& bank, const int pindex) const; + int GetSector(hipo::bank const& bank, int const pindex) const; private: diff --git a/src/iguana/algorithms/clas12/ZVertexFilter.cc b/src/iguana/algorithms/clas12/ZVertexFilter.cc index 9e2ec29f..dd0d5d31 100644 --- a/src/iguana/algorithms/clas12/ZVertexFilter.cc +++ b/src/iguana/algorithms/clas12/ZVertexFilter.cc @@ -43,7 +43,7 @@ namespace iguana::clas12 { ShowBank(particleBank, Logger::Header("OUTPUT PARTICLES")); } - bool ZVertexFilter::Filter(const double zvertex) const + bool ZVertexFilter::Filter(double const zvertex) const { return zvertex > GetZcutLower() && zvertex < GetZcutUpper(); } diff --git a/src/iguana/algorithms/clas12/ZVertexFilter.h b/src/iguana/algorithms/clas12/ZVertexFilter.h index 0b0226f8..91f7f7dc 100644 --- a/src/iguana/algorithms/clas12/ZVertexFilter.h +++ b/src/iguana/algorithms/clas12/ZVertexFilter.h @@ -19,7 +19,7 @@ namespace iguana::clas12 { /// **Action function**: checks if the Z Vertex is within specified bounds /// @param zvertex the particle Z Vertex to check /// @returns `true` if `zvertex` is within specified bounds - bool Filter(const double zvertex) const; + bool Filter(double const zvertex) const; /// @returns the current run number int GetRunNum() const; diff --git a/src/iguana/algorithms/example/ExampleAlgorithm.cc b/src/iguana/algorithms/example/ExampleAlgorithm.cc index 83b781f3..8413bab7 100644 --- a/src/iguana/algorithms/example/ExampleAlgorithm.cc +++ b/src/iguana/algorithms/example/ExampleAlgorithm.cc @@ -102,7 +102,7 @@ namespace iguana::example { // ############################################################################ // # define the action function // ############################################################################ - bool ExampleAlgorithm::Filter(const int pid) const + bool ExampleAlgorithm::Filter(int const pid) const { return pid > 0; } diff --git a/src/iguana/algorithms/example/ExampleAlgorithm.h b/src/iguana/algorithms/example/ExampleAlgorithm.h index fd5e8504..af4bda6f 100644 --- a/src/iguana/algorithms/example/ExampleAlgorithm.h +++ b/src/iguana/algorithms/example/ExampleAlgorithm.h @@ -74,7 +74,7 @@ namespace iguana::example { /// this is an example action function, please replace it with your own /// @param pid the particle PDG to check /// @returns `true` if `pid` is positive - bool Filter(const int pid) const; + bool Filter(int const pid) const; private: diff --git a/src/iguana/algorithms/physics/InclusiveKinematics.cc b/src/iguana/algorithms/physics/InclusiveKinematics.cc index a0f8907d..0ec6c9dd 100644 --- a/src/iguana/algorithms/physics/InclusiveKinematics.cc +++ b/src/iguana/algorithms/physics/InclusiveKinematics.cc @@ -43,7 +43,7 @@ namespace iguana::physics { m_beam.pdg = 0; m_beam.mass = -1.0; m_target.mass = -1.0; - for(const auto& [pdg, name] : particle::name) { + for(auto const& [pdg, name] : particle::name) { if(name == o_beam_particle) { m_beam.pdg = pdg; m_beam.mass = particle::mass.at(pdg); @@ -145,7 +145,7 @@ namespace iguana::physics { /////////////////////////////////////////////////////////////////////////////// - int InclusiveKinematics::FindScatteredLepton(const hipo::bank& particle_bank) const + int InclusiveKinematics::FindScatteredLepton(hipo::bank const& particle_bank) const { int lepton_row = -1; double lepton_energy = 0; diff --git a/src/iguana/algorithms/physics/InclusiveKinematics.h b/src/iguana/algorithms/physics/InclusiveKinematics.h index 14de2387..611df0f3 100644 --- a/src/iguana/algorithms/physics/InclusiveKinematics.h +++ b/src/iguana/algorithms/physics/InclusiveKinematics.h @@ -39,7 +39,7 @@ namespace iguana::physics { /// responsible for finding the scattered lepton. /// @param particle_bank the particle bank to search /// @returns the bank row of the scattered lepton, or `-1` if not found - int FindScatteredLepton(const hipo::bank& particle_bank) const; + int FindScatteredLepton(hipo::bank const& particle_bank) const; /// **Action function**: compute kinematics from the scattered lepton. /// @param lepton_px scattered lepton momentum component @f$p_x@f$ (GeV) diff --git a/src/iguana/services/ConfigFileReader.cc b/src/iguana/services/ConfigFileReader.cc index b0b63530..43c4a553 100644 --- a/src/iguana/services/ConfigFileReader.cc +++ b/src/iguana/services/ConfigFileReader.cc @@ -37,7 +37,7 @@ namespace iguana { if(m_log->GetLevel() <= level) { m_log->Print(level, "{:=^60}", " Configuration file search path order: "); m_log->Print(level, " - ./"); - for(const auto& dir : m_directories) + for(auto const& dir : m_directories) m_log->Print(level, " - {}", dir); m_log->Print(level, "{:=^60}", ""); } @@ -54,7 +54,7 @@ namespace iguana { if(found_local) return name; // then search each entry of `m_directories` - for(const auto& dir : m_directories) { + for(auto const& dir : m_directories) { std::string filename = dir + "/" + name; auto found = std::filesystem::exists(filename); m_log->Trace(" - {}{}", dir, found ? " - FOUND" : ""); diff --git a/src/iguana/services/Logger.cc b/src/iguana/services/Logger.cc index 827c19e4..f8419eb0 100644 --- a/src/iguana/services/Logger.cc +++ b/src/iguana/services/Logger.cc @@ -2,7 +2,7 @@ namespace iguana { - Logger::Logger(const std::string name, const Level lev, const bool enable_style) + Logger::Logger(const std::string name, const Level lev, bool const enable_style) : m_name(name) , m_enable_style(enable_style) { @@ -36,7 +36,7 @@ namespace iguana { m_level = lev; Debug("log level set to '{}'", level_name); } - catch(const std::out_of_range& ex) { + catch(std::out_of_range const& ex) { Error("Log level '{}' is not a known log level; the log level will remain at '{}'", static_cast(lev), m_level_names.at(m_level)); } } @@ -56,7 +56,7 @@ namespace iguana { m_enable_style = false; } - std::string Logger::Header(const std::string message, const int width) + std::string Logger::Header(const std::string message, int const width) { return fmt::format("{:=^{}}", " " + message + " ", width); } diff --git a/src/iguana/services/Logger.h b/src/iguana/services/Logger.h index e873183e..c5a3c733 100644 --- a/src/iguana/services/Logger.h +++ b/src/iguana/services/Logger.h @@ -43,7 +43,7 @@ namespace iguana { /// @param name the name of this logger instance, which will be include in all of its printouts /// @param lev the log level /// @param enable_style if true, certain printouts will be styled with color and emphasis - Logger(const std::string name = "log", const Level lev = DEFAULT_LEVEL, const bool enable_style = true); + Logger(const std::string name = "log", const Level lev = DEFAULT_LEVEL, bool const enable_style = true); ~Logger() {} /// Set the log level to this level. Log messages with a lower level will not be printed. @@ -70,7 +70,7 @@ namespace iguana { /// @param message the header message /// @param width the width of the header in number of characters /// @returns the header string - static std::string Header(const std::string message, const int width = 50); + static std::string Header(const std::string message, int const width = 50); /// Printout a log message at the `trace` level @see `Logger::Print` for more details template diff --git a/src/iguana/services/YAMLReader.cc b/src/iguana/services/YAMLReader.cc index 9f58571b..d65225e0 100644 --- a/src/iguana/services/YAMLReader.cc +++ b/src/iguana/services/YAMLReader.cc @@ -5,7 +5,7 @@ namespace iguana { void YAMLReader::LoadFiles() { m_log->Debug("YAMLReader::LoadFiles():"); - for(const auto& file : m_files) { + for(auto const& file : m_files) { try { m_log->Debug(" - load: {}", file); m_configs.push_back({YAML::LoadFile(file), file}); // m_config must be the same ordering as m_files, so `push_back` @@ -13,7 +13,7 @@ namespace iguana { catch(const YAML::Exception& e) { m_log->Error(" - YAML Exception: {}", e.what()); } - catch(const std::exception& e) { + catch(std::exception const& e) { m_log->Error(" - Exception: {}", e.what()); } } @@ -31,7 +31,7 @@ namespace iguana { catch(const YAML::Exception& e) { m_log->Error("YAML Parsing Exception: {}", e.what()); } - catch(const std::exception& e) { + catch(std::exception const& e) { m_log->Error("YAML Misc. Exception: {}", e.what()); } } @@ -46,7 +46,7 @@ namespace iguana { template SCALAR YAMLReader::GetScalar(node_path_t node_path) { - for(const auto& [config, filename] : m_configs) { + for(auto const& [config, filename] : m_configs) { auto node = FindNode(config, node_path); if(node.IsDefined() && !node.IsNull()) return GetScalar(node); @@ -65,14 +65,14 @@ namespace iguana { if(node.IsDefined() && !node.IsNull() && node.IsSequence()) { try { std::vector result; - for(const auto& element : node) + for(auto const& element : node) result.push_back(element.as()); return result; } catch(const YAML::Exception& e) { m_log->Error("YAML Parsing Exception: {}", e.what()); } - catch(const std::exception& e) { + catch(std::exception const& e) { m_log->Error("YAML Misc. Exception: {}", e.what()); } } @@ -87,7 +87,7 @@ namespace iguana { template std::vector YAMLReader::GetVector(node_path_t node_path) { - for(const auto& [config, filename] : m_configs) { + for(auto const& [config, filename] : m_configs) { auto node = FindNode(config, node_path); if(node.IsDefined() && !node.IsNull()) return GetVector(node); diff --git a/src/iguana/tests/include/TestConfig.h b/src/iguana/tests/include/TestConfig.h index 48d26bb0..2c5f0ae5 100644 --- a/src/iguana/tests/include/TestConfig.h +++ b/src/iguana/tests/include/TestConfig.h @@ -15,7 +15,7 @@ inline int TestConfig(int test_num, bool verbose) try { bad_config.AddFile("non_existent_file.yaml"); } - catch(const std::exception& ex) { + catch(std::exception const& ex) { fmt::print("excpected exception thrown when trying to add non-existent file\n"); } bad_config.PrintDirectories(); @@ -49,7 +49,7 @@ inline int TestConfig(int test_num, bool verbose) fmt::print(stderr, "ERROR: accessing 'scalar_empty' did not throw exception\n"); return 1; } - catch(const std::exception& ex) { + catch(std::exception const& ex) { fmt::print("SUCCESS: accessing 'scalar_empty' threw an expected exception\n"); } try { @@ -57,7 +57,7 @@ inline int TestConfig(int test_num, bool verbose) fmt::print(stderr, "ERROR: accessing 'vector_empty' did not throw exception\n"); return 1; } - catch(const std::exception& ex) { + catch(std::exception const& ex) { fmt::print("SUCCESS: accessing 'vector_empty' threw an expected exception\n"); } try { @@ -65,7 +65,7 @@ inline int TestConfig(int test_num, bool verbose) fmt::print(stderr, "ERROR: accessing 'vector_empty' as a `set` did not throw exception\n"); return 1; } - catch(const std::exception& ex) { + catch(std::exception const& ex) { fmt::print("SUCCESS: accessing 'vector_empty' as a `set` threw an expected exception\n"); } // test access to a key that does not exist @@ -74,7 +74,7 @@ inline int TestConfig(int test_num, bool verbose) fmt::print(stderr, "ERROR: accessing 'non_existent_scalar' did not throw exception\n"); return 1; } - catch(const std::exception& ex) { + catch(std::exception const& ex) { fmt::print("SUCCESS: accessing 'non_existent_scalar' threw an expected exception\n"); } try { @@ -82,7 +82,7 @@ inline int TestConfig(int test_num, bool verbose) fmt::print(stderr, "ERROR: accessing 'non_existent_vector' did not throw exception\n"); return 1; } - catch(const std::exception& ex) { + catch(std::exception const& ex) { fmt::print("SUCCESS: accessing 'non_existent_vector' threw an expected exception\n"); } try { @@ -90,7 +90,7 @@ inline int TestConfig(int test_num, bool verbose) fmt::print(stderr, "ERROR: accessing 'non_existent_vector' as a `set` did not throw exception\n"); return 1; } - catch(const std::exception& ex) { + catch(std::exception const& ex) { fmt::print("SUCCESS: accessing 'non_existent_vector' as a `set` threw an expected exception\n"); } break; @@ -134,7 +134,7 @@ inline int TestConfig(int test_num, bool verbose) fmt::print(stderr, "ERROR: accessing a missing default value for `InRange` did not throw exception\n"); return 1; } - catch(const std::exception& ex) { + catch(std::exception const& ex) { fmt::print("SUCCESS: accessing a missing default value for `InRange` threw expected exception\n"); } break; diff --git a/src/iguana/tests/include/TestLogger.h b/src/iguana/tests/include/TestLogger.h index 4d549a39..9c3de5ef 100644 --- a/src/iguana/tests/include/TestLogger.h +++ b/src/iguana/tests/include/TestLogger.h @@ -36,7 +36,7 @@ inline int TestLogger() try { log.Info("too few arguments: {} {}", 1); } - catch(const std::exception& ex) { + catch(std::exception const& ex) { log.Info("too few arguments test threw expected exception"); } }