* Trim the spaces from given string in place, i.e. the string buffer that * is passed will be modified whenever spaces exist in the given string. * When there are spaces at the begin, the whole string is moved forward * and when there are spaces at the back the '\0' termination is moved. * @param str The string to perform the in place trimming on. */
| 226 | * @param str The string to perform the in place trimming on. |
| 227 | */ |
| 228 | void StrTrimInPlace(std::string &str) |
| 229 | { |
| 230 | size_t first_pos = str.find_first_not_of(StringConsumer::WHITESPACE_NO_NEWLINE); |
| 231 | if (first_pos == std::string::npos) { |
| 232 | str.clear(); |
| 233 | return; |
| 234 | } |
| 235 | str.erase(0, first_pos); |
| 236 | |
| 237 | size_t last_pos = str.find_last_not_of(StringConsumer::WHITESPACE_NO_NEWLINE); |
| 238 | str.erase(last_pos + 1); |
| 239 | } |
| 240 | |
| 241 | std::string_view StrTrimView(std::string_view str, std::string_view characters_to_trim) |
| 242 | { |
no test coverage detected