8#ifndef MODELVIEWER_STRINGHELPERS_HPP
9#define MODELVIEWER_STRINGHELPERS_HPP
22 return std::isspace(ch) == 0;
29inline void ltrim(std::string &s) {
30 s.erase(s.begin(), std::ranges::find_if(s,
isNotSpace));
37inline void rtrim(std::string &s) {
38 s.erase(std::find_if(s.rbegin(), s.rend(),
39 [](
unsigned char ch) { return !std::isspace(ch); })
48inline void trim(std::string &s) {
90 const std::string fileScheme =
"file://";
91 if (p.rfind(fileScheme, 0) == 0) {
92 p.erase(0, fileScheme.size());
94 if (p.size() >= 3 && p[0] ==
'/' &&
95 std::isalpha(
static_cast<unsigned char>(p[1])) && p[2] ==
':') {
Definition StringHelpers.hpp:19
void ltrim(std::string &s)
Trim from the start (in place)
Definition StringHelpers.hpp:29
void trim(std::string &s)
Trim from both ends (in place)
Definition StringHelpers.hpp:48
bool isNotSpace(const unsigned char ch) noexcept
Definition StringHelpers.hpp:21
std::string trim_copy(std::string s)
Trim from both ends (copying)
Definition StringHelpers.hpp:78
std::string ltrim_copy(std::string s)
Trim from the start (copying)
Definition StringHelpers.hpp:58
void rtrim(std::string &s)
Trim from the end (in place)
Definition StringHelpers.hpp:37
std::string rtrim_copy(std::string s)
Trim from the end (copying)
Definition StringHelpers.hpp:68
std::string normalizePath(std::string p)
Normalize a file path by removing "file://" scheme and leading slash on Windows paths.
Definition StringHelpers.hpp:89