FACT++  1.0
string Tools::TrimQuotes ( const std::string &  str)

This is a static helper to remove leading and trailing whitespaces and if available leading and trailing quotes, can be either ' or "

Parameters
bufa pointer to the char array to be trimmed
Returns
a std::string with the content trimmed

Definition at line 92 of file tools.cc.

References Trim().

93 {
94  string rc = Trim(str);
95  if (rc.length()<2)
96  return rc;
97 
98  const char b = rc[0];
99  const char e = rc[rc.length()-1];
100 
101  if ((b=='\"' && e=='\"') || (b=='\'' && e=='\''))
102  return rc.substr(1, rc.length()-2);
103 
104  return rc;
105 }
char str[80]
Definition: test_client.c:7
std::string Trim(const std::string &str)
Definition: tools.cc:68

+ Here is the call graph for this function: