Skip to content

Commit

Permalink
[REFACT] Fixed compatibility with MinGW
Browse files Browse the repository at this point in the history
  • Loading branch information
hasherezade committed Feb 3, 2025
1 parent 848a9c6 commit 5d24f38
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions etw_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,29 @@

namespace util {

std::string WHITESPACES = " \t\n\v\f\r";

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);
}));
size_t startpos = s.find_first_not_of(WHITESPACES);
if (startpos != std::string::npos) {
s = s.substr(startpos);
}
}

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());
size_t endpos = s.find_last_not_of(WHITESPACES);
if (endpos != std::string::npos) {
s = s.substr(0, endpos + 1);
}
}

void trim(std::string& s)
std::string trim(std::string& s)
{
ltrim(s);
rtrim(s);
return s;
}

bool iequals(const std::string& a, const std::string& b)
Expand Down

0 comments on commit 5d24f38

Please sign in to comment.