From a9845dc02659378e2ac71c6e871c3d8c87ea9948 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Mon, 1 Oct 2018 16:48:38 -0500 Subject: [PATCH] Add overload of wcstringutil::trim that automatically trims whitespace --- src/wcstringutil.cpp | 4 ++++ src/wcstringutil.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/wcstringutil.cpp b/src/wcstringutil.cpp index d4904584d..094e661fe 100644 --- a/src/wcstringutil.cpp +++ b/src/wcstringutil.cpp @@ -46,6 +46,10 @@ wcstring truncate(const wcstring &input, int max_len, ellipsis_type etype) { return output; } +wcstring trim(const wcstring &input) { + return trim(input, whitespace.c_str()); +} + wcstring trim(const wcstring &input, const wchar_t *any_of) { auto begin_offset = input.find_first_not_of(any_of); if (begin_offset == wcstring::npos) { diff --git a/src/wcstringutil.h b/src/wcstringutil.h index 483817bff..91800cdec 100644 --- a/src/wcstringutil.h +++ b/src/wcstringutil.h @@ -64,6 +64,7 @@ enum class ellipsis_type { }; wcstring truncate(const wcstring &input, int max_len, ellipsis_type etype = ellipsis_type::Prettiest); +wcstring trim(const wcstring &input); wcstring trim(const wcstring &input, const wchar_t *any_of); #endif