Core/StringExt: Add TrimLeftCount and TrimRightCount

This commit is contained in:
SirLynix
2024-01-26 15:11:31 +01:00
parent 22a047b3b1
commit f10671ac2a
4 changed files with 85 additions and 0 deletions

View File

@@ -301,6 +301,11 @@ namespace Nz
return str;
}
inline std::string_view TrimLeftCount(std::string_view str, std::size_t n)
{
return str.substr(std::min(n, str.size()));
}
inline std::string_view TrimRight(std::string_view str, char c)
{
while (!str.empty() && str.back() == c)
@@ -326,6 +331,11 @@ namespace Nz
return str;
}
inline std::string_view TrimRightCount(std::string_view str, std::size_t n)
{
return str.substr(0, (str.size() > n) ? str.size() - n : 0);
}
}
#include <Nazara/Core/DebugOff.hpp>