From 2e7e352e3547a60b63adca2491cb965091b357d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sun, 3 Apr 2022 09:29:40 +0200 Subject: [PATCH] Utils: use trim functions from libgourou_common.h (avoid code duplication) --- utils/drmprocessorclientimpl.cpp | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/utils/drmprocessorclientimpl.cpp b/utils/drmprocessorclientimpl.cpp index 795d3c9..39a7dfa 100644 --- a/utils/drmprocessorclientimpl.cpp +++ b/utils/drmprocessorclientimpl.cpp @@ -45,27 +45,6 @@ #include #include "drmprocessorclientimpl.h" -// https://stackoverflow.com/questions/216823/how-to-trim-a-stdstring -// trim from start (in place) -static inline void ltrim(std::string &s) { - s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) { - return !std::isspace(ch); - })); -} - -// trim from end (in place) -static inline void rtrim(std::string &s) { - s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) { - return !std::isspace(ch); - }).base(), s.end()); -} - -// trim from both ends (in place) -static inline void trim(std::string &s) { - ltrim(s); - rtrim(s); -} - /* Digest interface */ void* DRMProcessorClientImpl::createDigest(const std::string& digestName) { @@ -163,8 +142,8 @@ static size_t curlHeaders(char *buffer, size_t size, size_t nitems, void *userda std::string key = std::string(buffer, pos); std::string value = std::string(&buffer[pos+1], (size*nitems)-(pos+1)); - trim(key); - trim(value); + key = gourou::trim(key); + value = gourou::trim(value); (*responseHeaders)[key] = value;