ATLAS Offline Software
Loading...
Searching...
No Matches
PixelConditionsData Namespace Reference

Functions

template<class T = std::string>
fromString (const std::string &s)
template<>
float fromString (const std::string &s)
template<>
double fromString (const std::string &s)
template<>
int fromString (const std::string &s)
template<>
bool fromString (const std::string &s)
std::vector< std::string > getParameterString (const std::string &varName, const std::vector< std::string > &buffer)
template<class T>
std::vector< T > getParameter (const std::string &varName, const std::vector< std::string > &buffer)

Function Documentation

◆ fromString() [1/5]

template<class T = std::string>
T PixelConditionsData::fromString ( const std::string & s)

Definition at line 14 of file PixelConditionsDataStringUtils.h.

14 {
15 return s;
16 }

◆ fromString() [2/5]

template<>
float PixelConditionsData::fromString ( const std::string & s)
inline

Definition at line 20 of file PixelConditionsDataStringUtils.h.

20 {
21 return std::stof(s);
22 }

◆ fromString() [3/5]

template<>
double PixelConditionsData::fromString ( const std::string & s)
inline

Definition at line 26 of file PixelConditionsDataStringUtils.h.

26 {
27 return std::stod(s);
28 }

◆ fromString() [4/5]

template<>
int PixelConditionsData::fromString ( const std::string & s)
inline

Definition at line 32 of file PixelConditionsDataStringUtils.h.

32 {
33 return std::stoi(s);
34 }

◆ fromString() [5/5]

template<>
bool PixelConditionsData::fromString ( const std::string & s)
inline

Definition at line 38 of file PixelConditionsDataStringUtils.h.

38 {
39 std::string v=s;
40 for (char & c: v) c = std::tolower(c);
41 if (v.find("false")!=std::string::npos) return false;
42 if (v.find("true")!=std::string::npos) return true;
43 throw("bad conversion");
44 }

◆ getParameter()

template<class T>
std::vector< T > PixelConditionsData::getParameter ( const std::string & varName,
const std::vector< std::string > & buffer )

Definition at line 51 of file PixelConditionsDataStringUtils.h.

51 {
52 const std::vector<std::string> & varString = getParameterString(varName, buffer);
53 std::vector<T> result;
54 for (const auto & var : varString) {
55 result.emplace_back(fromString<T>(var));
56 }
57 return result;
58 }
T fromString(const std::string &s)
std::vector< std::string > getParameterString(const std::string &varName, const std::vector< std::string > &buffer)

◆ getParameterString()

std::vector< std::string > PixelConditionsData::getParameterString ( const std::string & varName,
const std::vector< std::string > & buffer )

Definition at line 13 of file PixelConditionsDataStringUtils.cxx.

13 {
14 std::string sParam = "";
15 std::string sMessage = "";
16
17 for (size_t i=0; i<buffer.size(); i++) {
18 if (buffer[i].find(varName.c_str())!=std::string::npos) {
19 std::istringstream iss(buffer[i]);
20 std::string s;
21 bool chkParam = false;
22 bool chkMessage = false;
23 while (iss >> s) {
24 if (s.find("{{")!=std::string::npos) {
25 sParam += s.substr(2,s.length());
26 chkParam = true;
27 }
28 else if (s.find("},")!=std::string::npos) {
29 sParam += s.substr(0,s.length()-2);
30 sParam += ",";
31 }
32 else if (s.find("}}")!=std::string::npos) {
33 sParam += s.substr(0,s.length()-2);
34 chkParam = false;
35 chkMessage = true;
36 }
37 else if (s.find("{")!=std::string::npos && s.find("}")!=std::string::npos) {
38 sParam += s.substr(1,s.length()-1);
39 }
40 else if (s.find("{")!=std::string::npos) {
41 sParam += s.substr(1,s.length());
42 chkParam = true;
43 }
44 else if (s.find("}")!=std::string::npos) {
45 sParam += s.substr(0,s.length()-1);
46 chkParam = false;
47 chkMessage = true;
48 }
49 else if (chkParam==true) {
50 sParam += s;
51 }
52 else if (chkMessage==true) {
53 sMessage += " " + s;
54 }
55 }
56 }
57 }
58 if (sParam.empty()) {
59 throw std::runtime_error ("PixelConfigCondAlg::getParameterString() Input variable " + varName + " was not found. " );
60 }
61
62 std::vector<std::string> vParam;
63 int offset = 0;
64 for (;;) {
65 auto pos = sParam.find(",",offset);
66 if (pos==std::string::npos) {
67 vParam.push_back(sParam.substr(offset,pos));
68 break;
69 }
70 vParam.push_back(sParam.substr(offset,pos-offset));
71 offset = pos + 1;
72 }
73
74 std::vector<std::string> vvParam;
75 for (const auto & param : vParam) {
76 if (param.find("\"")!=std::string::npos) {
77 if (vParam.size()==1) {
78 vvParam.push_back(param.substr(1,param.length()-3));
79 } else {
80 vvParam.push_back(param.substr(1,param.length()-2));
81 }
82 } else {
83 vvParam.push_back(param);
84 }
85 }
86 return vvParam;
87 }
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138