20 return c==
' ' || c==
'\t' || c==
'\n';
23 if(
s.empty())
return s;
24 std::string::const_iterator firstNonBlank=
s.begin();
25 for(firstNonBlank=
s.begin();
26 firstNonBlank !=
s.end() && (isBlank(*firstNonBlank));
30 string new_s(firstNonBlank,
s.end());
34 if(
s.empty())
return s;
35 std::string::const_iterator lastNonBlank =
s.end();
36 for(string::const_iterator it=
s.begin();
38 if(! isBlank(*it)) lastNonBlank = it;
40 if(lastNonBlank !=
s.end()) lastNonBlank++;
42 string new_s(
s.begin(), lastNonBlank);
46 return removeTrailingBlanks(removeLeadingBlanks(
s));
50 if(s_in.empty())
return s_in;
52 int commentStart =
s.find(_commentStart);
54 if(commentStart >= 0 && commentStart < (
int)
s.size()){
55 s.resize(commentStart);
61 return removeComment(removeLeadingBlanks(s_in));
65 return (! _parsedStrings.empty()) && isalpha(name()[0]);
69 , std::vector<std::string>& fillThisList){
71 string s = removeLeadingBlanks(
76 if(
s.empty())
return 0;
80 string::const_iterator prev=
s.begin();
82 bool insideQuotes=
false;
92 for(string::const_iterator it=
s.begin();
95 if( ((! insideQuotes) && isBlank(*it)) || *it ==
'"' || ignore){
97 string tmp_s(prev, it);
98 fillThisList.push_back(tmp_s);
102 if(prevBlank) prev=it;
106 if(*it ==
'"') insideQuotes = ! insideQuotes;
109 cout <<
"WARNING in ParsedParameterLine::makeParsedStrings \n" 110 <<
" unbalanced quotes in string:\n" 113 return fillThisList.size();
117 makeParsedStrings(line, _parsedStrings);
118 return ! _parsedStrings.empty();
122 for(
unsigned int i=0; i<_parsedStrings.size(); i++){
123 os << _parsedStrings[i];
124 if(i != _parsedStrings.size()-1) os <<
"; ";
129 os <<
"Testing the String Parsing in ParsedParameterLine:" << endl;
130 os <<
" test string is (w/o the '>' and '<'):\n" 131 <<
" >" << _testString <<
"<" << endl;
132 string noBlanks = removeLeadingBlanks(_testString);
133 os <<
" ... removing leading blanks gives:\n" 134 <<
" >" << noBlanks <<
"<" << endl;
135 os <<
" ... removing trailing blanks gives:\n" 136 <<
" >" << removeTrailingBlanks(_testString) <<
"<" << endl;
137 string noComment = removeComment(_testString);
138 os <<
" ... string without comment:\n" 139 <<
" >" << noComment <<
"<" 141 os <<
" ... string without comment run through removeComment again:\n" 142 <<
" >" << removeComment(noComment) <<
"<" 144 os <<
" ... removeCommentAndLeadingBlanks\n" 145 <<
" >" << removeCommentAndLeadingBlanks(_testString) <<
"<" 148 vector<string> valueStringList;
149 makeParsedStrings(_testString, valueStringList);
150 os <<
" made value string list:\n";
151 for(
unsigned int i=0; i< valueStringList.size(); i++){
152 os <<
" " << i <<
") >" << valueStringList[i] <<
"< " << endl;
154 os <<
"test done." << endl;
static std::string removeCommentAndLeadingBlanks(const std::string &line)
static std::string removeComment(const std::string &line)
static int makeParsedStrings(const std::string &line, std::vector< std::string > &fillThisList)
std::ostream & operator<<(std::ostream &os, const ParsedParameterLine &ppl)
static std::string removeLeadingAndTrailingBlanks(const std::string &s)
static std::string removeTrailingBlanks(const std::string &s)
static std::string removeLeadingBlanks(const std::string &s)
static const std::string _testName
static bool isBlank(char c)
static const std::string _commentStart
virtual void stringParsingTest(std::ostream &os=std::cout) const
virtual void print(std::ostream &os=std::cout) const
static const std::string _testString