@@ -25,20 +25,20 @@ int Converter::StringToInt(const std::string& var)
25
25
}
26
26
27
27
28
- std::string Converter::ZToSymbol (const int Z )
28
+ std::string Converter::ZToSymbol (const int proton_number )
29
29
{
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 ;
32
32
});
33
33
34
34
return [&]() {
35
- if (it == symbolZmap.end ())
35
+ if (match == symbolZmap.end ())
36
36
{
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 );
38
38
return std::string{ " Xy" };
39
39
}
40
40
41
- return it ->first ;
41
+ return match ->first ;
42
42
}();
43
43
}
44
44
@@ -47,19 +47,17 @@ int Converter::SymbolToZ(std::string _symbol)
47
47
{
48
48
const std::string symbol = caseCorrection (std::move (_symbol));
49
49
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; });
54
52
55
53
return [&]() {
56
- if (it == symbolZmap.end ())
54
+ if (match == symbolZmap.end ())
57
55
{
58
56
fmt::print (" \n **WARNING**: {} is not a valid symbol\n " , symbol);
59
57
return 200 ;
60
58
}
61
59
62
- return it ->second ;
60
+ return match ->second ;
63
61
}();
64
62
}
65
63
@@ -86,29 +84,30 @@ std::string Converter::caseCorrection(std::string symbol)
86
84
}
87
85
88
86
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 )
90
88
{
91
89
// 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 );
93
91
94
92
const std::regex pieces_regex (R"( (-?\d*\.?\d+)e([+-]?)(\d+))" );
95
93
std::smatch matches;
96
94
97
95
// Always get 1dp from the first number
98
96
// 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 ;
100
98
101
99
return (std::regex_match (number, matches, pieces_regex))
102
100
// coefficient(1dp) exponent sign exponent
103
101
? 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{} );
106
104
}
107
105
108
106
109
- std::string Converter::IsomerEnergyToHuman (const double in , const int numDP)
107
+ std::string Converter::IsomerEnergyToHuman (const double number , const int numDP)
110
108
{
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);
112
111
}
113
112
114
113
0 commit comments