2022-02-05 20:47:29 +01:00
|
|
|
#pragma once
|
|
|
|
|
2021-07-13 03:33:12 +02:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
const std::string WHITESPACE = " \n\r\t\f\v";
|
|
|
|
|
2022-02-05 20:54:06 +01:00
|
|
|
inline std::string ltrim(const std::string& s) {
|
2021-07-13 03:33:12 +02:00
|
|
|
size_t begin = s.find_first_not_of(WHITESPACE);
|
|
|
|
return (begin == std::string::npos) ? "" : s.substr(begin);
|
|
|
|
}
|
|
|
|
|
2022-02-05 20:54:06 +01:00
|
|
|
inline std::string rtrim(const std::string& s) {
|
2021-07-13 03:33:12 +02:00
|
|
|
size_t end = s.find_last_not_of(WHITESPACE);
|
|
|
|
return (end == std::string::npos) ? "" : s.substr(0, end + 1);
|
|
|
|
}
|
|
|
|
|
2022-02-05 20:47:29 +01:00
|
|
|
inline std::string trim(const std::string& s) { return rtrim(ltrim(s)); }
|