20 if ( s.find(
":post")!=std::string::npos )
m_post = s.substr( s.find(
":post")+6, s.size() );
40 std::vector<std::string> fields;
42 while ( !s.empty() ) fields.push_back(
chop( s,
":" ) );
44 bool postkeys =
false;
48 if ( fields.size() )
m_head = fields[0];
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;
56 std::string f = fields[i];
57 std::string key =
chop( f,
"=" );
69 std::string
tags[5] = {
"key",
"roi",
"vtx",
"te",
"extra" };
70 bool tagged[5] = {
false,
false,
false,
false,
false };
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;
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;
91 if ( unset ) std::cerr <<
"no such tag: " <<
m_keys[i] << std::endl;
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;
108 for (
int i=0 ; i<5 ; i++ )
if ( *
values[i]!=
"" )
raw +=
":" + *
values[i];
112 *
static_cast<std::string*
>(
this) =
raw;
129 std::string
tags[5] = {
"key=",
"roi=",
"vtx=",
"te=",
"extra=" };
133 for (
int i=0 ; i<5 ; i++ )
if ( *
values[i]!=
"" ) s +=
":" +
tags[i] + *
values[i];
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
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 > m_values
std::vector< std::string > tags