| 1 |
#include "stringtrim.h" |
| 2 |
|
| 3 |
#include <cctype> |
| 4 |
#include "gplaut04.h" |
| 5 |
|
| 6 |
void strrighttrim(std::string& str) |
| 7 |
{ |
| 8 |
std::string::iterator it; |
| 9 |
|
| 10 |
for (it=str.end()-1; it > str.begin() && std::isspace(*it); it--); |
| 11 |
/* it now points to the right-most non-space character */ |
| 12 |
str.erase(it+1, str.end()); |
| 13 |
} |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
void strlefttrim(std::string& str) |
| 18 |
{ |
| 19 |
std::string::iterator it; |
| 20 |
|
| 21 |
for (it=str.begin(); it < str.end() && std::isspace(*it); it++); |
| 22 |
// it now points to the first non-space character, |
| 23 |
str.erase(str.begin(), it); |
| 24 |
} |