Trim a string
| 3071 | |
| 3072 | // Trim a string |
| 3073 | void trimWhitespace(std::string* pStr) { |
| 3074 | |
| 3075 | // skip empty case |
| 3076 | if (pStr->empty()) |
| 3077 | return; // #nocov |
| 3078 | |
| 3079 | // trim right |
| 3080 | std::string::size_type pos = pStr->find_last_not_of(kWhitespaceChars); |
| 3081 | if (pos != std::string::npos) |
| 3082 | pStr->erase(pos + 1); |
| 3083 | |
| 3084 | // trim left |
| 3085 | pos = pStr->find_first_not_of(kWhitespaceChars); |
| 3086 | pStr->erase(0, pos); |
| 3087 | } |
| 3088 | |
| 3089 | // Strip balanced quotes from around a string (assumes already trimmed) |
| 3090 | void stripQuotes(std::string* pStr) { |
no test coverage detected