+ std::string strip(std::string s) {
+ std::string ws = " \t\n";
+ int first = s.find_first_not_of(ws);
+ int last = s.find_last_not_of(ws);
+
+ if (first == -1) {
+ int pos_first = s.find_first_of(ws);
+ if (pos_first == -1) {
+ return s;
+ } else {
+ return std::string("");
+ }
+ }
+ return s.substr(first,last-first+1).c_str();