remove duplicated string manipulation methods

This commit is contained in:
Alex Maystrenko 2022-02-05 21:01:07 +01:00
parent 2697d432a4
commit f3819ee954

View File

@ -4,6 +4,7 @@
#include "glibmm/fileutils.h" #include "glibmm/fileutils.h"
#include "glibmm/refptr.h" #include "glibmm/refptr.h"
#include "util/format.hpp" #include "util/format.hpp"
#include "util/string.hpp"
#include <algorithm> #include <algorithm>
#include <cctype> #include <cctype>
@ -26,27 +27,6 @@
namespace waybar::modules::wlr { namespace waybar::modules::wlr {
/* String manipulation methods */
const std::string WHITESPACE = " \n\r\t\f\v";
static std::string ltrim(const std::string& s)
{
size_t start = s.find_first_not_of(WHITESPACE);
return (start == std::string::npos) ? "" : s.substr(start);
}
static std::string rtrim(const std::string& s)
{
size_t end = s.find_last_not_of(WHITESPACE);
return (end == std::string::npos) ? "" : s.substr(0, end + 1);
}
static std::string trim(const std::string& s)
{
return rtrim(ltrim(s));
}
/* Icon loading functions */ /* Icon loading functions */
static std::vector<std::string> search_prefix() static std::vector<std::string> search_prefix()
{ {