diff options
Diffstat (limited to 'src/auxiliary')
-rw-r--r-- | src/auxiliary/functions.cc | 10 | ||||
-rw-r--r-- | src/auxiliary/functions.h | 3 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/auxiliary/functions.cc b/src/auxiliary/functions.cc index e9861ac..5edff56 100644 --- a/src/auxiliary/functions.cc +++ b/src/auxiliary/functions.cc @@ -122,4 +122,14 @@ const std::string lowercase(const std::string &text) return t; } +void trim(std::string &text) +{ + while (text.size() && text[0] == ' ') { + text.erase(0, 1); + } + while (text.size() && text[text.size()-1] == ' ') { + text.erase(text.size()-1, 1); + } +} + } diff --git a/src/auxiliary/functions.h b/src/auxiliary/functions.h index 90eb2ed..ceab0de 100644 --- a/src/auxiliary/functions.h +++ b/src/auxiliary/functions.h @@ -49,6 +49,9 @@ const std::string text_strip(const std::string &text); /// return text, stripped of color codes and converted to lowercase const std::string text_strip_lowercase(const std::string &text); +/// trim leading ad trailing spaces from a string +void trim(std::string &text); + } #endif // __INCLUDED_AUX_FUNCTIONS_H__ |