11#include <TObjString.h>
14 OptionConverter::OptionConverter() {}
18 for (
auto strval : fNames) {
20 if (strval.EqualTo(option)) {
25 if (Hal::Std::FindParam(option,
"forced:")) {
26 Cout::PrintInfo(
"replacing HalFastCut by force !", Hal::EInfo::kLowWarning);
27 TRegexp reg(
"[9-0]+");
37 fNames.push_back(option);
38 fValues.push_back(fValues.size());
42 fNames.push_back(option);
43 fValues.push_back(no);
47 if (value > 0 && value < (
int) fNames.size()) {
48 string = fNames[value];
55 OptionConverter::~OptionConverter() {}
59 OptionArray::OptionArray() {}
62 for (
unsigned int i = 0; i < fLabels.size(); i++) {
63 TString tmp = fLabels[i];
65 Cout::PrintInfo(Form(
"Label %s already registered", label.Data()), Hal::EInfo::kLowWarning);
69 if (label.Contains(
":") || label.Contains(
"NULL")) {
74 fLabels.push_back(label);
75 fParameters.push_back(std::vector<TString>());
79 TRegexp regexp(
"[0-9a-zA-Z]+:");
80 TRegexp regexp2(
":.[0-9a-zA-Z]+");
81 TString label = option(regexp);
82 label.Remove(label.Length() - 1);
83 TString value = option(regexp2);
86 for (
unsigned int i = 0; i < fLabels.size(); i++) {
87 if (GetLabel(i).EqualTo(label)) {
93 Cout::PrintInfo(Form(
"Can't add string %s because there is no label ", label.Data()), Hal::EInfo::kWarning);
96 fParameters[label_no].push_back(value);
101 for (
unsigned int i = 0; i < fLabels.size(); i++) {
102 if (GetLabel(i).EqualTo(label)) {
103 Int_t entries = fParameters[i].size();
104 if (entries == 0 || entries <= no) {
105 if (entries == 0)
Cout::PrintInfo(Form(
"No entries for label %s", label.Data()), Hal::EInfo::kLowWarning);
106 if (entries < no)
Cout::PrintInfo(Form(
"Not enough entries for label %s", label.Data()), Hal::EInfo::kLowWarning);
109 return fParameters[i][no];
116 for (
unsigned int i = 0; i < fLabels.size(); i++) {
117 if (GetLabel(i).EqualTo(label)) {
return fParameters[i].size(); }
122 TString OptionArray::GetLabel(Int_t i)
const {
return fLabels[i]; }
125 for (
unsigned int i = 0; i < fLabels.size(); i++) {
126 Cout::Text(Form(
"Label %s", fLabels[i].Data()),
"L", kYellow);
127 for (
unsigned int j = 0; j < fParameters[i].size(); j++) {
128 TString val = fParameters[i][j];
134 OptionArray::~OptionArray() {}
static void Text(TString text, TString option="L", Color_t color=-1)
static void PrintInfo(TString text, Hal::EInfo status)
Int_t GetByLabelNo(TString label) const
void RegisterLabel(TString label)
TString GetByLabel(TString label, Int_t no=0) const
Bool_t Add(TString option)
void Print(Option_t *="") const
void RegisterOption(TString option)
Bool_t GetOptionInt(Int_t &val, TString option) const
Bool_t GetString(TString &val, Int_t value) const