summaryrefslogtreecommitdiff
path: root/src/strutils.cc
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2015-06-04 00:22:57 +0200
committerJoel Klinghed <the_jk@yahoo.com>2015-06-04 00:22:57 +0200
commita6dfc269d93cdf557f6dac62b03b886d694faecd (patch)
tree8f9c04a4200a99fc4e986f1b0b23808040580011 /src/strutils.cc
parent052a162715449252bb6126c41dd1700b1440c394 (diff)
Add config and change all commands to one
Diffstat (limited to 'src/strutils.cc')
-rw-r--r--src/strutils.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/strutils.cc b/src/strutils.cc
index e7b7c93..1687f53 100644
--- a/src/strutils.cc
+++ b/src/strutils.cc
@@ -26,4 +26,18 @@ std::string ascii_tolower(const std::string& str) {
return str;
}
+namespace {
+bool is_ws(char c) {
+ return c == ' ' || c == '\t' || c == '\n' || c == '\r';
+}
+} // namespace
+
+std::string trim(const std::string& str) {
+ auto start = str.begin();
+ while (start != str.end() && is_ws(*start)) start++;
+ auto end = str.end() - 1;
+ while (end >= start && is_ws(*end)) end--;
+ return std::string(start, end + 1);
+}
+
} // namespace stuff