#include <ChainString.h>
|
| | ChainString (const std::string &s) |
| | ChainString (const ChainString &s) |
| ChainString & | operator= (const ChainString &)=default |
| const std::string & | head () const |
| const std::string & | tail () const |
| const std::string & | roi () const |
| const std::string & | vtx () const |
| const std::string & | element () const |
| const std::string & | extra () const |
| bool | passed () const |
| const std::string & | raw () 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 would work, but that is far too excessive
|
| std::string | postvalue (const std::string &key) const |
| | same here regarding returning a reference
|
| const std::vector< std::string > & | values () const |
| const std::vector< std::string > & | keys () const |
| std::string | pre () const |
| const std::string & | post () const |
| size_t | postcount () const |
| std::string | subs (std::string s) const |
|
| static std::string | chop (std::string &s1, const std::string &s2) |
|
| void | parse (std::string s) |
| | parse the full specification string
|
| int | findkey (const std::string &key) const |
|
| static std::string | chomp (std::string &s1, const std::string &s2) |
| static char | toupper (char c) |
| | convert to upper case
|
| static std::string | toupper (const std::string &s) |
| | convert to upper case
|
| static char | tolower (char c) |
| | convert to lower case
|
| static std::string | tolower (const std::string &s) |
| | convert to lower case
|
Definition at line 23 of file ChainString.h.
◆ ChainString() [1/2]
| ChainString::ChainString |
( |
const std::string & | s | ) |
|
Definition at line 16 of file ChainString.cxx.
16 :
17 std::string(s),
20 if (
s.find(
":post")!=std::string::npos )
m_post =
s.substr(
s.find(
":post")+6,
s.size() );
22}
void parse(std::string s)
parse the full specification string
◆ ChainString() [2/2]
Definition at line 25 of file ChainString.cxx.
25 :
26 std::string(s),
33}
std::vector< std::string > m_keys
std::vector< std::string > m_values
◆ chomp()
| std::string ChainString::chomp |
( |
std::string & | s1, |
|
|
const std::string & | s2 ) |
|
inlinestaticprotected |
Definition at line 89 of file ChainString.h.
89 {
90
91 std::string::size_type
pos =
s1.find_first_of(s2);
93 if ( pos == std::string::npos ) return "";
94
95 s3 =
s1.substr(pos+1,
s1.size());
96 s1.erase(pos,
s1.size());
97
99 }
◆ chop()
| std::string ChainString::chop |
( |
std::string & | s1, |
|
|
const std::string & | s2 ) |
|
inlinestatic |
Definition at line 72 of file ChainString.h.
72 {
73 std::string::size_type
pos =
s1.find_first_of(s2);
75 if ( pos == std::string::npos ) {
77 s1.erase(0,
s1.size());
78 }
79 else {
80 s3 =
s1.substr(0, pos);
82 }
84 }
◆ element()
| const std::string & ChainString::element |
( |
| ) |
const |
|
inline |
◆ extra()
| const std::string & ChainString::extra |
( |
| ) |
const |
|
inline |
◆ findkey()
| int ChainString::findkey |
( |
const std::string & | key | ) |
const |
|
inlineprotected |
◆ head()
| const std::string & ChainString::head |
( |
| ) |
const |
|
inline |
◆ keys()
| const std::vector< std::string > & ChainString::keys |
( |
| ) |
const |
|
inline |
◆ operator=()
◆ parse()
| void ChainString::parse |
( |
std::string | s | ) |
|
|
protected |
parse the full specification string
replace the string by a parsed basic string
overwrite with the parsed string
Definition at line 38 of file ChainString.cxx.
38 {
39
40 std::vector<std::string>
fields;
41
42 while ( !
s.empty() )
fields.push_back(
chop( s,
":" ) );
43
44 bool postkeys = false;
45
46 size_t keycount = 0;
47
49
50 for (
size_t i=1 ;
i<
fields.size() ;
i++ ) {
51 std::string dte =
chomp( fields[i],
";" );
52 if ( !postkeys && dte==
"DTE" )
m_passed =
false;
53 if ( fields[i]==
"DTE" )
m_passed =
false;
54 else if ( fields[i]=="post" ) postkeys = true;
55 else {
57 std::string
key =
chop( f,
"=" );
58 if ( f=="" ) {
61 }
63 else keycount++;
66 }
67 }
68
69 std::string
tags[5] = {
"key",
"roi",
"vtx",
"te",
"extra" };
70 bool tagged[5] = { false, false, false, false, false };
71
73
74 for (
size_t i=0 ;
i<keycount &&
i<5 ;
i++ ) {
76 if ( tagged[i] ) std::cerr <<
"tag already allocated : " <<
tags[
i] <<
" with value " << *
values[
i] << std::endl;
78 }
79 else {
80 bool unset = true;
81 for ( int j=0 ; j<5 ; j++ ) {
83 if ( tagged[j] ) std::cerr <<
"tag already allocated : " <<
tags[j] <<
" with value " << *
values[j] << std::endl;
84 else {
86 unset = false;
87 tagged[j] = true;
88 }
89 }
90 }
91 if ( unset ) std::cerr <<
"no such tag: " <<
m_keys[
i] << std::endl;
92 }
93 }
94
95#if 0
96 std::cout <<
"head: " <<
m_head << std::endl;
97 std::cout <<
"key: " <<
m_tail << std::endl;
98 std::cout <<
"roi: " <<
m_roi << std::endl;
99 std::cout <<
"vtx: " <<
m_vtx << std::endl;
100 std::cout <<
"te: " <<
m_element << std::endl;
101 std::cout <<
"ind: " <<
m_extra << std::endl;
102 std::cout <<
"pass: " <<
m_passed << std::endl;
103#endif
104
106
110
112 *
static_cast<std::string*
>(
this) =
raw;
113
117
119
121
122}
const std::vector< std::string > & values() const
const std::string & raw() const
static char tolower(char c)
convert to lower case
static std::string chop(std::string &s1, const std::string &s2)
static std::string chomp(std::string &s1, const std::string &s2)
std::vector< std::string > tags
◆ passed()
| bool ChainString::passed |
( |
| ) |
const |
|
inline |
◆ post()
| const std::string & ChainString::post |
( |
| ) |
const |
|
inline |
◆ postcount()
| size_t ChainString::postcount |
( |
| ) |
const |
|
inline |
◆ postvalue()
| std::string ChainString::postvalue |
( |
const std::string & | key | ) |
const |
|
inline |
same here regarding returning a reference
Definition at line 54 of file ChainString.h.
54 {
56 return "";
57 }
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...
◆ pre()
| std::string ChainString::pre |
( |
| ) |
const |
|
inline |
◆ raw()
| const std::string & ChainString::raw |
( |
| ) |
const |
|
inline |
◆ roi()
| const std::string & ChainString::roi |
( |
| ) |
const |
|
inline |
◆ subs()
| std::string ChainString::subs |
( |
std::string | s | ) |
const |
Definition at line 127 of file ChainString.cxx.
127 {
128
129 std::string
tags[5] = {
"key=",
"roi=",
"vtx=",
"te=",
"extra=" };
130
132
135
137
139}
◆ tail()
| const std::string & ChainString::tail |
( |
| ) |
const |
|
inline |
◆ tolower() [1/2]
| char ChainString::tolower |
( |
char | c | ) |
|
|
inlinestaticprotected |
convert to lower case
Definition at line 114 of file ChainString.h.
114{ return ( c>='A' && c<='Z' ? c-'A'+'a' : c ); }
◆ tolower() [2/2]
| std::string ChainString::tolower |
( |
const std::string & | s | ) |
|
|
inlinestaticprotected |
convert to lower case
Definition at line 117 of file ChainString.h.
117 {
118 const char*
c =
s.c_str();
121 while (( *tp++ =
tolower(*c++) ));
123 }
◆ toupper() [1/2]
| char ChainString::toupper |
( |
char | c | ) |
|
|
inlinestaticprotected |
convert to upper case
Definition at line 102 of file ChainString.h.
102{ return ( c>='a' && c<='z' ? c+'A'-'a' : c ); }
◆ toupper() [2/2]
| std::string ChainString::toupper |
( |
const std::string & | s | ) |
|
|
inlinestaticprotected |
convert to upper case
Definition at line 105 of file ChainString.h.
105 {
106 const char*
c =
s.c_str();
109 while (( *tp++ =
toupper(*c++) ));
111 }
static char toupper(char c)
convert to upper case
◆ value()
| std::string ChainString::value |
( |
const std::string & | key | ) |
const |
|
inline |
can't make this return a reference in case there is no such key - could throw an exception then it would work, but that is far too excessive
Definition at line 47 of file ChainString.h.
47 {
50 return "";
51 }
int findkey(const std::string &key) const
◆ values()
| const std::vector< std::string > & ChainString::values |
( |
| ) |
const |
|
inline |
◆ vtx()
| const std::string & ChainString::vtx |
( |
| ) |
const |
|
inline |
◆ m_element
| std::string ChainString::m_element |
|
private |
◆ m_extra
| std::string ChainString::m_extra |
|
private |
◆ m_head
| std::string ChainString::m_head |
|
private |
◆ m_keys
| std::vector<std::string> ChainString::m_keys |
|
private |
◆ m_passed
| bool ChainString::m_passed |
|
private |
◆ m_post
| std::string ChainString::m_post |
|
private |
◆ m_postcount
| size_t ChainString::m_postcount |
|
private |
◆ m_raw
| std::string ChainString::m_raw |
|
private |
◆ m_roi
| std::string ChainString::m_roi |
|
private |
◆ m_tail
| std::string ChainString::m_tail |
|
private |
◆ m_values
| std::vector<std::string> ChainString::m_values |
|
private |
◆ m_vtx
| std::string ChainString::m_vtx |
|
private |
The documentation for this class was generated from the following files: