From a6dfc269d93cdf557f6dac62b03b886d694faecd Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Thu, 4 Jun 2015 00:22:57 +0200 Subject: Add config and change all commands to one --- src/strutils.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/strutils.cc') 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 -- cgit v1.2.3-70-g09d2