Project
Loading...
Searching...
No Matches
AnalysisTask.cxx
Go to the documentation of this file.
1// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#include <string>
12
13namespace o2::framework
14{
16std::string type_to_task_name(std::string_view const& camelCase)
17{
18 std::string result;
19 result.reserve(camelCase.size() * 2 + 2);
20
21 // The first character is always -.
22 result += "-";
23 result += static_cast<char>(std::tolower(camelCase[0]));
24
25 for (auto it = camelCase.begin() + 1; it != camelCase.end(); ++it) {
26 if (std::isupper(*it) && *(it - 1) != '-') {
27 result += '-';
28 }
29 result += static_cast<char>(std::tolower(*it));
30 }
31 // Post-process to consolidate common ALICE abbreviations
32 // Process backwards to handle patterns correctly
33 static const struct {
34 std::string_view pattern;
35 std::string_view replacement;
36 } abbreviations[] = {
37 {"-h-m-p-i-d", "-hmpid"},
38 {"-e-m-c-a-l", "-emcal"},
39 {"-e-m-c", "-emc"},
40 {"-i-t-s", "-its"},
41 {"-t-p-c", "-tpc"},
42 {"-q-c-d", "-qcd"},
43 {"-t-o-f", "-tof"},
44 {"-t-r-d", "-trd"},
45 {"-f-v0", "-fv0"},
46 {"-q-a", "-qa"},
47 {"-b-c", "-bc"},
48 {"-q-c", "-qc"}};
49
50 std::string consolidated;
51 consolidated.reserve(result.size());
52
53 for (int i = result.size() - 1; i >= 0;) {
54 bool matched = false;
55
56 for (const auto& abbr : abbreviations) {
57 int startPos = i - abbr.pattern.size() + 1;
58 if (startPos >= 0 && result.compare(startPos, abbr.pattern.size(), abbr.pattern.data()) == 0) {
59 consolidated.insert(0, abbr.replacement);
60 i = startPos - 1;
61 matched = true;
62 break;
63 }
64 }
65
66 if (!matched) {
67 consolidated.insert(0, 1, result[i]);
68 --i;
69 }
70 }
71 if (consolidated[0] == '-') {
72 return std::string(consolidated.data() + 1);
73 }
74
75 return consolidated;
76}
77} // namespace o2::framework
int32_t i
GLuint64EXT * result
Definition glcorearb.h:5662
Defining PrimaryVertex explicitly as messageable.
std::string type_to_task_name(std::string_view const &camelCase)
Convert a CamelCase task struct name to snake-case task name.
std::array< uint16_t, 5 > pattern