1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-01-19 03:57:14 +01:00

Update String.hpp

This commit is contained in:
Sandu Liviu Catalin 2021-04-18 13:14:41 +03:00
parent eb7cafac46
commit 0223621b75

View File

@ -20,8 +20,6 @@ namespace SqMod {
*/ */
struct SqString struct SqString
{ {
static constexpr const char WHITESPACE[] = " \n\t\v\b\r\f\a";
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* String instance. * String instance.
*/ */
@ -598,11 +596,11 @@ struct SqString
*/ */
SQMOD_NODISCARD LightObj Trimmed() SQMOD_NODISCARD LightObj Trimmed()
{ {
const auto sb = mS.find_first_not_of(WHITESPACE); const auto sb = mS.find_first_not_of(" \n\t\v\b\r\f\a");
// Is it all white-space? // Is it all white-space?
if (sb != String::npos) if (sb != String::npos)
{ {
const auto se = mS.find_last_not_of(WHITESPACE); const auto se = mS.find_last_not_of(" \n\t\v\b\r\f\a");
// Return the portion of the string that isn't surrounded by white-space // Return the portion of the string that isn't surrounded by white-space
return LightObj(mS.data() + sb, se - sb); return LightObj(mS.data() + sb, se - sb);
} }
@ -921,7 +919,4 @@ struct SqString
SQMOD_NODISCARD SQInteger GetLevenshtein(SqString & o) const; SQMOD_NODISCARD SQInteger GetLevenshtein(SqString & o) const;
}; };
// ------------------------------------------------------------------------------------------------
constexpr const char SqString::WHITESPACE[];
} // Namespace:: SqMod } // Namespace:: SqMod