@@ -25,20 +25,20 @@ int Converter::StringToInt(const std::string& var)
2525}
2626
2727
28- std::string Converter::ZToSymbol (const int Z )
28+ std::string Converter::ZToSymbol (const int proton_number )
2929{
30- const auto it = std::find_if (symbolZmap.cbegin (), symbolZmap.cend (), [Z ](const std::pair<std::string, int >& element) {
31- return element.second == Z ;
30+ const auto match = std::find_if (symbolZmap.cbegin (), symbolZmap.cend (), [proton_number ](const auto element) {
31+ return element.second == proton_number ;
3232 });
3333
3434 return [&]() {
35- if (it == symbolZmap.end ())
35+ if (match == symbolZmap.end ())
3636 {
37- fmt::print (" \n **WARNING**: {} is not a valid proton number\n " , Z );
37+ fmt::print (" \n **WARNING**: {} is not a valid proton number\n " , proton_number );
3838 return std::string{ " Xy" };
3939 }
4040
41- return it ->first ;
41+ return match ->first ;
4242 }();
4343}
4444
@@ -47,19 +47,17 @@ int Converter::SymbolToZ(std::string _symbol)
4747{
4848 const std::string symbol = caseCorrection (std::move (_symbol));
4949
50- const auto it =
51- std::find_if (symbolZmap.cbegin (), symbolZmap.cend (), [&symbol](const std::pair<std::string, int >& element) {
52- return element.first == symbol;
53- });
50+ const auto match = std::find_if (
51+ symbolZmap.cbegin (), symbolZmap.cend (), [&symbol](const auto element) { return element.first == symbol; });
5452
5553 return [&]() {
56- if (it == symbolZmap.end ())
54+ if (match == symbolZmap.end ())
5755 {
5856 fmt::print (" \n **WARNING**: {} is not a valid symbol\n " , symbol);
5957 return 200 ;
6058 }
6159
62- return it ->second ;
60+ return match ->second ;
6361 }();
6462}
6563
@@ -86,29 +84,30 @@ std::string Converter::caseCorrection(std::string symbol)
8684}
8785
8886
89- std::tuple<std::string, std::string, std::string> Converter::FloatToExponent (const double in )
87+ std::tuple<std::string, std::string, std::string> Converter::FloatToExponent (const double value )
9088{
9189 // Force the number to be scientific, i.e. follow the regex: -?\d*\.?\d+e[+-]?\d+
92- const std::string number = fmt::format (" {0:e}" , in );
90+ const auto number = fmt::format (" {0:e}" , value );
9391
9492 const std::regex pieces_regex (R"( (-?\d*\.?\d+)e([+-]?)(\d+))" );
9593 std::smatch matches;
9694
9795 // Always get 1dp from the first number
9896 // If it's negative take an extra char for the sign
99- const int digits = (in < 0.0 ) ? 4 : 3 ;
97+ const int digits = (value < 0.0 ) ? 4 : 3 ;
10098
10199 return (std::regex_match (number, matches, pieces_regex))
102100 // coefficient(1dp) exponent sign exponent
103101 ? std::make_tuple (
104- std::string ( matches[1 ]) .substr (0 , digits), std::string ( matches[2 ]) , std::string ( matches[3 ]) )
105- : std::make_tuple (std::string () , std::string () , std::string () );
102+ std::string{ matches[1 ] } .substr (0 , digits), std::string{ matches[2 ] } , std::string{ matches[3 ] } )
103+ : std::make_tuple (std::string{} , std::string{} , std::string{} );
106104}
107105
108106
109- std::string Converter::IsomerEnergyToHuman (const double in , const int numDP)
107+ std::string Converter::IsomerEnergyToHuman (const double number , const int numDP)
110108{
111- return (in < 1000.0 ) ? fmt::format (" {0:0.{1}f} keV" , in, numDP) : fmt::format (" {0:0.{1}f} MeV" , in / 1000.0 , numDP);
109+ return (number < 1000.0 ) ? fmt::format (" {0:0.{1}f} keV" , number, numDP)
110+ : fmt::format (" {0:0.{1}f} MeV" , number / 1000.0 , numDP);
112111}
113112
114113
0 commit comments