diff options
Diffstat (limited to 'src/utils/string.cpp')
| -rw-r--r-- | src/utils/string.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/utils/string.cpp b/src/utils/string.cpp index bb590ca..c0b7517 100644 --- a/src/utils/string.cpp +++ b/src/utils/string.cpp @@ -1,5 +1,8 @@ #include "string.hpp" +#include <algorithm> +#include <cctype> +#include <locale> #include <sstream> namespace silly::editor::utils { @@ -15,4 +18,22 @@ namespace silly::editor::utils { return parts; } + + void ltrim(std::string &s) { + s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) { + return !std::isspace(ch); + })); + } + + void rtrim(std::string &s) { + s.erase(std::find_if(s.rbegin(), s.rend(), + [](unsigned char ch) { return !std::isspace(ch); }) + .base(), + s.end()); + } + + void trim(std::string &s) { + rtrim(s); + ltrim(s); + } }
\ No newline at end of file |
