14#ifndef TrigInDetAnalysisExample_ChainString_H
15#define TrigInDetAnalysisExample_ChainString_H
35 const std::string&
roi()
const {
return m_roi; }
36 const std::string&
vtx()
const {
return m_vtx; }
42 const std::string&
raw()
const {
return m_raw; }
47 std::string
value(
const std::string& key )
const {
57 std::string
value(
size_t i)
const {
65 std::string
postvalue(
const std::string& key )
const {
71 const std::vector<std::string>&
keys()
const {
return m_keys; }
73 std::string
pre()
const {
return m_raw.substr( 0,
m_raw.find(
":post") ); }
78 std::string
subs( std::string s )
const;
83 static std::string
chop(std::string& s1,
const std::string& s2) {
84 std::string::size_type pos = s1.find_first_of(s2);
86 if ( pos == std::string::npos ) {
88 s1.erase(0, s1.size());
91 s3 = s1.substr(0, pos);
100 static std::string
chomp(std::string& s1,
const std::string& s2) {
102 std::string::size_type pos = s1.find_first_of(s2);
104 if ( pos == std::string::npos )
return "";
106 s3 = s1.substr(pos+1, s1.size());
107 s1.erase(pos, s1.size());
113 static char toupper(
char c ) {
return ( c>=
'a' && c<=
'z' ? c+
'A'-
'a' : c ); }
116 static std::string
toupper(
const std::string& s ) {
117 const char* c = s.c_str();
120 while (( *tp++ =
toupper(*c++) ));
125 static char tolower(
char c ) {
return ( c>=
'A' && c<=
'Z' ? c-
'A'+
'a' : c ); }
128 static std::string
tolower(
const std::string& s ) {
129 const char* c = s.c_str();
132 while (( *tp++ =
tolower(*c++) ));
140 void parse( std::string s );
143 for (
int i=
m_keys.size() ; i-- ; )
if ( key==
m_keys[i] )
return i;
bool operator==(const ChainString &cs, const ChainString &s)
const std::string & extra() const
static std::string toupper(const std::string &s)
convert to upper case
const std::vector< std::string > & keys() const
const std::string & roi() const
std::string subs(std::string s) const
ChainString(const std::string &s)
const std::string & post() const
const std::vector< std::string > & values() const
void parse(std::string s)
parse the full specification string
const std::string & raw() const
std::vector< std::string > m_keys
const std::string & head() const
std::string value(const std::string &key) const
can't make this return a reference in case there is no such key - could throw an exception then it wo...
static char tolower(char c)
convert to lower case
ChainString & operator=(const ChainString &)=default
const std::string & tail() const
std::string postvalue(const std::string &key) const
same here regarding returning a reference
int findkey(const std::string &key) const
std::string value(size_t i) const
as above - should really return a const std::string& but we don't want to have to throw an exception ...
static std::string chop(std::string &s1, const std::string &s2)
static std::string tolower(const std::string &s)
convert to lower case
static std::string chomp(std::string &s1, const std::string &s2)
std::vector< std::string > m_values
static char toupper(char c)
convert to upper case
const std::string & vtx() const
const std::string & element() const