Loading src/core/config/ConfigManager.cpp +2 −7 Original line number Diff line number Diff line Loading @@ -42,11 +42,7 @@ ConfigManager::ConfigManager(std::filesystem::path file_name, ConfigReader reader(file, file_name); // Convert all global and ignored names to lower case and store them auto lowercase = [](const std::string& in) { std::string out(in); std::transform(out.begin(), out.end(), out.begin(), ::tolower); return out; }; auto lowercase = [](const std::string& in) { return allpix::transform(in, ::tolower); }; std::transform(global.begin(), global.end(), std::inserter(global_names_, global_names_.end()), lowercase); std::transform(ignore.begin(), ignore.end(), std::inserter(ignore_names_, ignore_names_.end()), lowercase); Loading @@ -56,8 +52,7 @@ ConfigManager::ConfigManager(std::filesystem::path file_name, // Store all the configurations read for(auto& config : reader.getConfigurations()) { // Skip all ignored sections std::string config_name = config.getName(); std::transform(config_name.begin(), config_name.end(), config_name.begin(), ::tolower); std::string config_name = allpix::transform(config.getName(), ::tolower); if(ignore_names_.find(config_name) != ignore_names_.end()) { continue; } Loading src/core/config/ConfigReader.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -175,8 +175,7 @@ void ConfigReader::add(std::istream& stream, std::filesystem::path file_name) { void ConfigReader::addConfiguration(Configuration config) { conf_array_.push_back(std::move(config)); std::string section_name = conf_array_.back().getName(); std::transform(section_name.begin(), section_name.end(), section_name.begin(), ::tolower); auto section_name = allpix::transform(conf_array_.back().getName(), ::tolower); conf_map_[section_name].push_back(--conf_array_.end()); } Loading src/core/utils/text.h +9 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,15 @@ namespace allpix { * @return List of all the substrings with all empty substrings ignored (thus removed) */ template <typename T> std::vector<T> split(std::string str, const std::string& delims = " \t,"); /** * @brief Transforms a string and returns the transformed string * @param str String that should be transformed * @param op Unary operator to act on the string * @return Transformed string */ template <typename T> std::string transform(const std::string& str, const T& op); } // namespace allpix // Include template definitions Loading src/core/utils/text.tpp +7 −3 Original line number Diff line number Diff line Loading @@ -102,9 +102,7 @@ namespace allpix { } template <typename T, std::enable_if_t<std::is_enum<T>::value, bool>> std::string to_string_impl(T inp, empty_tag) { auto out = std::string(magic_enum::enum_name(inp)); std::transform(out.begin(), out.end(), out.begin(), ::tolower); return out; return allpix::transform(std::string(magic_enum::enum_name(inp)), ::tolower); } template <typename T> std::vector<T> split(std::string str, const std::string& delims) { Loading Loading @@ -132,4 +130,10 @@ namespace allpix { return elems; } template <typename T> std::string transform(const std::string& str, const T& op) { auto output = str; std::transform(output.begin(), output.end(), output.begin(), op); return output; } } // namespace allpix src/modules/DepositionGeant4/DepositionGeant4Module.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -137,8 +137,7 @@ void DepositionGeant4Module::initialize() { G4EmParameters::Instance(); auto pai_model = config_.get<std::string>("pai_model"); auto lcase_model = pai_model; std::transform(lcase_model.begin(), lcase_model.end(), lcase_model.begin(), ::tolower); auto lcase_model = allpix::transform(pai_model, ::tolower); if(lcase_model == "pai") { pai_model = "PAI"; } else if(lcase_model == "paiphoton") { Loading Loading
src/core/config/ConfigManager.cpp +2 −7 Original line number Diff line number Diff line Loading @@ -42,11 +42,7 @@ ConfigManager::ConfigManager(std::filesystem::path file_name, ConfigReader reader(file, file_name); // Convert all global and ignored names to lower case and store them auto lowercase = [](const std::string& in) { std::string out(in); std::transform(out.begin(), out.end(), out.begin(), ::tolower); return out; }; auto lowercase = [](const std::string& in) { return allpix::transform(in, ::tolower); }; std::transform(global.begin(), global.end(), std::inserter(global_names_, global_names_.end()), lowercase); std::transform(ignore.begin(), ignore.end(), std::inserter(ignore_names_, ignore_names_.end()), lowercase); Loading @@ -56,8 +52,7 @@ ConfigManager::ConfigManager(std::filesystem::path file_name, // Store all the configurations read for(auto& config : reader.getConfigurations()) { // Skip all ignored sections std::string config_name = config.getName(); std::transform(config_name.begin(), config_name.end(), config_name.begin(), ::tolower); std::string config_name = allpix::transform(config.getName(), ::tolower); if(ignore_names_.find(config_name) != ignore_names_.end()) { continue; } Loading
src/core/config/ConfigReader.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -175,8 +175,7 @@ void ConfigReader::add(std::istream& stream, std::filesystem::path file_name) { void ConfigReader::addConfiguration(Configuration config) { conf_array_.push_back(std::move(config)); std::string section_name = conf_array_.back().getName(); std::transform(section_name.begin(), section_name.end(), section_name.begin(), ::tolower); auto section_name = allpix::transform(conf_array_.back().getName(), ::tolower); conf_map_[section_name].push_back(--conf_array_.end()); } Loading
src/core/utils/text.h +9 −0 Original line number Diff line number Diff line Loading @@ -127,6 +127,15 @@ namespace allpix { * @return List of all the substrings with all empty substrings ignored (thus removed) */ template <typename T> std::vector<T> split(std::string str, const std::string& delims = " \t,"); /** * @brief Transforms a string and returns the transformed string * @param str String that should be transformed * @param op Unary operator to act on the string * @return Transformed string */ template <typename T> std::string transform(const std::string& str, const T& op); } // namespace allpix // Include template definitions Loading
src/core/utils/text.tpp +7 −3 Original line number Diff line number Diff line Loading @@ -102,9 +102,7 @@ namespace allpix { } template <typename T, std::enable_if_t<std::is_enum<T>::value, bool>> std::string to_string_impl(T inp, empty_tag) { auto out = std::string(magic_enum::enum_name(inp)); std::transform(out.begin(), out.end(), out.begin(), ::tolower); return out; return allpix::transform(std::string(magic_enum::enum_name(inp)), ::tolower); } template <typename T> std::vector<T> split(std::string str, const std::string& delims) { Loading Loading @@ -132,4 +130,10 @@ namespace allpix { return elems; } template <typename T> std::string transform(const std::string& str, const T& op) { auto output = str; std::transform(output.begin(), output.end(), output.begin(), op); return output; } } // namespace allpix
src/modules/DepositionGeant4/DepositionGeant4Module.cpp +1 −2 Original line number Diff line number Diff line Loading @@ -137,8 +137,7 @@ void DepositionGeant4Module::initialize() { G4EmParameters::Instance(); auto pai_model = config_.get<std::string>("pai_model"); auto lcase_model = pai_model; std::transform(lcase_model.begin(), lcase_model.end(), lcase_model.begin(), ::tolower); auto lcase_model = allpix::transform(pai_model, ::tolower); if(lcase_model == "pai") { pai_model = "PAI"; } else if(lcase_model == "paiphoton") { Loading