refactor(*): make type alias identifiers conform to the style for general type identifiers
This commit is contained in:
@ -68,31 +68,31 @@ static_assert(CUnsigned<unicodechar>, "TChar assumes unicodechar is an unsigned
|
||||
template <CCharType T>
|
||||
struct TChar
|
||||
{
|
||||
using CharType = T;
|
||||
using FCharType = T;
|
||||
|
||||
/** The maximum number of code units required to represent a single character. if unknown, guess 1. */
|
||||
static constexpr size_t MaxCodeUnitLength =
|
||||
CSameAs<CharType, char> ? MB_LEN_MAX :
|
||||
CSameAs<CharType, wchar> ?
|
||||
CSameAs<FCharType, char> ? MB_LEN_MAX :
|
||||
CSameAs<FCharType, wchar> ?
|
||||
PLATFORM_WINDOWS ? 2 :
|
||||
PLATFORM_LINUX ? 1 : 1 :
|
||||
CSameAs<CharType, u8char> ? 4 :
|
||||
CSameAs<CharType, u16char> ? 2 :
|
||||
CSameAs<CharType, u32char> ? 1 : 1;
|
||||
CSameAs<FCharType, u8char> ? 4 :
|
||||
CSameAs<FCharType, u16char> ? 2 :
|
||||
CSameAs<FCharType, u32char> ? 1 : 1;
|
||||
|
||||
/** Whether the character type is fixed-length. */
|
||||
static constexpr bool bIsFixedLength = MaxCodeUnitLength == 1;
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr bool IsValid(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr bool IsValid(FCharType InChar)
|
||||
{
|
||||
if constexpr (CSameAs<CharType, u8char>)
|
||||
if constexpr (CSameAs<FCharType, u8char>)
|
||||
{
|
||||
if ((InChar & 0b10000000) == 0b00000000) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u16char> || CSameAs<CharType, u32char>)
|
||||
else if constexpr (CSameAs<FCharType, u16char> || CSameAs<FCharType, u32char>)
|
||||
{
|
||||
if (InChar >= 0xD800 && InChar <= 0xDBFF) return false;
|
||||
if (InChar >= 0xDC00 && InChar <= 0xDFFF) return false;
|
||||
@ -101,30 +101,30 @@ struct TChar
|
||||
}
|
||||
|
||||
// Windows uses UTF-16 encoding for wchar.
|
||||
else if constexpr (PLATFORM_WINDOWS && (CSameAs<CharType, wchar>))
|
||||
else if constexpr (PLATFORM_WINDOWS && (CSameAs<FCharType, wchar>))
|
||||
{
|
||||
return TChar::IsValid(static_cast<u16char>(InChar));
|
||||
}
|
||||
|
||||
// Linux uses UTF-32 encoding for wchar.
|
||||
else if constexpr (PLATFORM_LINUX && (CSameAs<CharType, wchar>))
|
||||
else if constexpr (PLATFORM_LINUX && (CSameAs<FCharType, wchar>))
|
||||
{
|
||||
return TChar::IsValid(static_cast<u32char>(InChar));
|
||||
}
|
||||
|
||||
else static_assert(sizeof(CharType) == -1, "Unsupported character type");
|
||||
else static_assert(sizeof(FCharType) == -1, "Unsupported character type");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr bool IsNonch(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr bool IsNonch(FCharType InChar)
|
||||
{
|
||||
if constexpr (CSameAs<CharType, u8char>)
|
||||
if constexpr (CSameAs<FCharType, u8char>)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u16char>)
|
||||
else if constexpr (CSameAs<FCharType, u16char>)
|
||||
{
|
||||
if (InChar >= U16TEXT('\uFDD0') && InChar <= U16TEXT('\uFDEF')) return true;
|
||||
|
||||
@ -134,7 +134,7 @@ struct TChar
|
||||
return false;
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u32char>)
|
||||
else if constexpr (CSameAs<FCharType, u32char>)
|
||||
{
|
||||
if (InChar >= U32TEXT('\uFDD0') && InChar <= U32TEXT('\uFDEF')) return true;
|
||||
|
||||
@ -144,25 +144,25 @@ struct TChar
|
||||
}
|
||||
|
||||
// Windows uses UTF-16 encoding for wchar.
|
||||
else if constexpr (PLATFORM_WINDOWS && (CSameAs<CharType, wchar>))
|
||||
else if constexpr (PLATFORM_WINDOWS && (CSameAs<FCharType, wchar>))
|
||||
{
|
||||
return TChar::IsNonch(static_cast<u16char>(InChar));
|
||||
}
|
||||
|
||||
// Linux uses UTF-32 encoding for wchar.
|
||||
else if constexpr (PLATFORM_LINUX && (CSameAs<CharType, wchar>))
|
||||
else if constexpr (PLATFORM_LINUX && (CSameAs<FCharType, wchar>))
|
||||
{
|
||||
return TChar::IsNonch(static_cast<u32char>(InChar));
|
||||
}
|
||||
|
||||
else static_assert(sizeof(CharType) == -1, "Unsupported character type");
|
||||
else static_assert(sizeof(FCharType) == -1, "Unsupported character type");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr bool IsASCII(CharType InChar = LITERAL(CharType, '\0'))
|
||||
NODISCARD FORCEINLINE static constexpr bool IsASCII(FCharType InChar = LITERAL(FCharType, '\0'))
|
||||
{
|
||||
if constexpr (CSameAs<CharType, char>)
|
||||
if constexpr (CSameAs<FCharType, char>)
|
||||
{
|
||||
constexpr bool ASCIICompatible = []() -> bool
|
||||
{
|
||||
@ -188,7 +188,7 @@ struct TChar
|
||||
return ASCIICompatible && 0x00 <= InChar && InChar <= 0x7F;
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, wchar>)
|
||||
else if constexpr (CSameAs<FCharType, wchar>)
|
||||
{
|
||||
constexpr bool ASCIICompatible = []() -> bool
|
||||
{
|
||||
@ -214,19 +214,19 @@ struct TChar
|
||||
return ASCIICompatible && 0x00 <= InChar && InChar <= 0x7F;
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u8char> || CSameAs<CharType, u16char> || CSameAs<CharType, u32char> || CSameAs<CharType, unicodechar>)
|
||||
else if constexpr (CSameAs<FCharType, u8char> || CSameAs<FCharType, u16char> || CSameAs<FCharType, u32char> || CSameAs<FCharType, unicodechar>)
|
||||
{
|
||||
return InChar <= 0x7F;
|
||||
}
|
||||
|
||||
else static_assert(sizeof(CharType) == -1, "Unsupported character type");
|
||||
else static_assert(sizeof(FCharType) == -1, "Unsupported character type");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr bool IsAlnum(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr bool IsAlnum(FCharType InChar)
|
||||
{
|
||||
if constexpr (CSameAs<CharType, char> || CSameAs<CharType, wchar>)
|
||||
if constexpr (CSameAs<FCharType, char> || CSameAs<FCharType, wchar>)
|
||||
{
|
||||
NAMESPACE_STD::locale Loc("");
|
||||
return NAMESPACE_STD::isalnum(InChar, Loc);
|
||||
@ -237,15 +237,15 @@ struct TChar
|
||||
}
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr bool IsAlpha(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr bool IsAlpha(FCharType InChar)
|
||||
{
|
||||
if constexpr (CSameAs<CharType, char> || CSameAs<CharType, wchar>)
|
||||
if constexpr (CSameAs<FCharType, char> || CSameAs<FCharType, wchar>)
|
||||
{
|
||||
NAMESPACE_STD::locale Loc("");
|
||||
return NAMESPACE_STD::isalpha(InChar, Loc);
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u8char>)
|
||||
else if constexpr (CSameAs<FCharType, u8char>)
|
||||
{
|
||||
/*
|
||||
* BASIC LATIN
|
||||
@ -258,29 +258,29 @@ struct TChar
|
||||
return false;
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u16char> || CSameAs<CharType, u32char>)
|
||||
else if constexpr (CSameAs<FCharType, u16char> || CSameAs<FCharType, u32char>)
|
||||
{
|
||||
checkf(InChar <= LITERAL(CharType, '\u007F'), TEXT("TChar::IsAlpha() only supports basic latin block."));
|
||||
checkf(InChar <= LITERAL(FCharType, '\u007F'), TEXT("TChar::IsAlpha() only supports basic latin block."));
|
||||
|
||||
if (InChar > LITERAL(CharType, '\u007F')) return false;
|
||||
if (InChar > LITERAL(FCharType, '\u007F')) return false;
|
||||
|
||||
return TChar<u8char>::IsAlpha(static_cast<u8char>(InChar));
|
||||
}
|
||||
|
||||
else static_assert(sizeof(CharType) == -1, "Unsupported character type");
|
||||
else static_assert(sizeof(FCharType) == -1, "Unsupported character type");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr bool IsLower(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr bool IsLower(FCharType InChar)
|
||||
{
|
||||
if constexpr (CSameAs<CharType, char> || CSameAs<CharType, wchar>)
|
||||
if constexpr (CSameAs<FCharType, char> || CSameAs<FCharType, wchar>)
|
||||
{
|
||||
NAMESPACE_STD::locale Loc("");
|
||||
return NAMESPACE_STD::islower(InChar, Loc);
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u8char>)
|
||||
else if constexpr (CSameAs<FCharType, u8char>)
|
||||
{
|
||||
/*
|
||||
* BASIC LATIN
|
||||
@ -291,7 +291,7 @@ struct TChar
|
||||
return false;
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u16char>)
|
||||
else if constexpr (CSameAs<FCharType, u16char>)
|
||||
{
|
||||
checkf(InChar <= U16TEXT('\u007F'), TEXT("TChar::IsLower() only supports basic latin block."));
|
||||
|
||||
@ -300,7 +300,7 @@ struct TChar
|
||||
return TChar<u8char>::IsLower(static_cast<u8char>(InChar));
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u32char>)
|
||||
else if constexpr (CSameAs<FCharType, u32char>)
|
||||
{
|
||||
checkf(InChar <= U32TEXT('\u007F'), TEXT("TChar::IsLower() only supports basic latin block."));
|
||||
|
||||
@ -309,20 +309,20 @@ struct TChar
|
||||
return TChar<u8char>::IsLower(static_cast<u8char>(InChar));
|
||||
}
|
||||
|
||||
else static_assert(sizeof(CharType) == -1, "Unsupported character type");
|
||||
else static_assert(sizeof(FCharType) == -1, "Unsupported character type");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr bool IsUpper(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr bool IsUpper(FCharType InChar)
|
||||
{
|
||||
if constexpr (CSameAs<CharType, char> || CSameAs<CharType, wchar>)
|
||||
if constexpr (CSameAs<FCharType, char> || CSameAs<FCharType, wchar>)
|
||||
{
|
||||
NAMESPACE_STD::locale Loc("");
|
||||
return NAMESPACE_STD::isupper(InChar, Loc);
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u8char>)
|
||||
else if constexpr (CSameAs<FCharType, u8char>)
|
||||
{
|
||||
/*
|
||||
* BASIC LATIN
|
||||
@ -333,7 +333,7 @@ struct TChar
|
||||
return false;
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u16char>)
|
||||
else if constexpr (CSameAs<FCharType, u16char>)
|
||||
{
|
||||
checkf(InChar <= U16TEXT('\u007F'), TEXT("TChar::IsUpper() only supports basic latin block."));
|
||||
|
||||
@ -342,7 +342,7 @@ struct TChar
|
||||
return TChar<u8char>::IsUpper(static_cast<u8char>(InChar));
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u32char>)
|
||||
else if constexpr (CSameAs<FCharType, u32char>)
|
||||
{
|
||||
checkf(InChar <= U32TEXT('\u007F'), TEXT("TChar::IsUpper() only supports basic latin block."));
|
||||
|
||||
@ -351,20 +351,20 @@ struct TChar
|
||||
return TChar<u8char>::IsUpper(static_cast<u8char>(InChar));
|
||||
}
|
||||
|
||||
else static_assert(sizeof(CharType) == -1, "Unsupported character type");
|
||||
else static_assert(sizeof(FCharType) == -1, "Unsupported character type");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr bool IsDigit(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr bool IsDigit(FCharType InChar)
|
||||
{
|
||||
static_assert(TChar::IsASCII());
|
||||
|
||||
/* <U0030>..<U0039>; */
|
||||
return InChar >= LITERAL(CharType, '0') && InChar <= LITERAL(CharType, '9');
|
||||
return InChar >= LITERAL(FCharType, '0') && InChar <= LITERAL(FCharType, '9');
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr bool IsDigit(CharType InChar, unsigned Base)
|
||||
NODISCARD FORCEINLINE static constexpr bool IsDigit(FCharType InChar, unsigned Base)
|
||||
{
|
||||
checkf(Base >= 2 && Base <= 36, TEXT("Base must be in the range [2, 36]."));
|
||||
|
||||
@ -373,32 +373,32 @@ struct TChar
|
||||
bool bResult = false;
|
||||
|
||||
/* <U0030>..<U0039>; */
|
||||
bResult |= InChar >= LITERAL(CharType, '0') && InChar < LITERAL(CharType, '0') + static_cast<signed>(Base);
|
||||
bResult |= InChar >= LITERAL(FCharType, '0') && InChar < LITERAL(FCharType, '0') + static_cast<signed>(Base);
|
||||
|
||||
/* <U0041>..<U0046>; */
|
||||
bResult |= InChar >= LITERAL(CharType, 'a') && InChar < LITERAL(CharType, 'a') + static_cast<signed>(Base) - 10;
|
||||
bResult |= InChar >= LITERAL(FCharType, 'a') && InChar < LITERAL(FCharType, 'a') + static_cast<signed>(Base) - 10;
|
||||
|
||||
/* <U0061>..<U0066>; */
|
||||
bResult |= InChar >= LITERAL(CharType, 'A') && InChar < LITERAL(CharType, 'A') + static_cast<signed>(Base) - 10;
|
||||
bResult |= InChar >= LITERAL(FCharType, 'A') && InChar < LITERAL(FCharType, 'A') + static_cast<signed>(Base) - 10;
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr bool IsCntrl(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr bool IsCntrl(FCharType InChar)
|
||||
{
|
||||
if constexpr (CSameAs<CharType, char> || CSameAs<CharType, wchar>)
|
||||
if constexpr (CSameAs<FCharType, char> || CSameAs<FCharType, wchar>)
|
||||
{
|
||||
NAMESPACE_STD::locale Loc("");
|
||||
return NAMESPACE_STD::iscntrl(InChar, Loc);
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u8char>)
|
||||
else if constexpr (CSameAs<FCharType, u8char>)
|
||||
{
|
||||
/* <U0000>..<U001F>;<U007F>; */
|
||||
return (InChar >= U8TEXT('\u0000') && InChar <= U8TEXT('\u001F')) || InChar == U8TEXT('\u007F');
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u16char>)
|
||||
else if constexpr (CSameAs<FCharType, u16char>)
|
||||
{
|
||||
/* <U0000>..<U001F>;<U007F>..<U009F>;<U2028>;<U2029>; */
|
||||
return
|
||||
@ -407,7 +407,7 @@ struct TChar
|
||||
(InChar == U16TEXT('\u2028') || InChar == U16TEXT('\u2029'));
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u32char>)
|
||||
else if constexpr (CSameAs<FCharType, u32char>)
|
||||
{
|
||||
/* <U0000>..<U001F>;<U007F>..<U009F>;<U2028>;<U2029>; */
|
||||
return
|
||||
@ -416,20 +416,20 @@ struct TChar
|
||||
(InChar == U32TEXT('\u2028') || InChar == U32TEXT('\u2029'));
|
||||
}
|
||||
|
||||
else static_assert(sizeof(CharType) == -1, "Unsupported character type");
|
||||
else static_assert(sizeof(FCharType) == -1, "Unsupported character type");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr bool IsGraph(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr bool IsGraph(FCharType InChar)
|
||||
{
|
||||
if constexpr (CSameAs<CharType, char> || CSameAs<CharType, wchar>)
|
||||
if constexpr (CSameAs<FCharType, char> || CSameAs<FCharType, wchar>)
|
||||
{
|
||||
NAMESPACE_STD::locale Loc("");
|
||||
return NAMESPACE_STD::isgraph(InChar, Loc);
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u8char>)
|
||||
else if constexpr (CSameAs<FCharType, u8char>)
|
||||
{
|
||||
/*
|
||||
* BASIC LATIN
|
||||
@ -440,7 +440,7 @@ struct TChar
|
||||
return false;
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u16char>)
|
||||
else if constexpr (CSameAs<FCharType, u16char>)
|
||||
{
|
||||
checkf(InChar <= U16TEXT('\u007F'), TEXT("TChar::IsGraph() only supports basic latin block."));
|
||||
|
||||
@ -449,7 +449,7 @@ struct TChar
|
||||
return TChar<u8char>::IsGraph(static_cast<u8char>(InChar));
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u32char>)
|
||||
else if constexpr (CSameAs<FCharType, u32char>)
|
||||
{
|
||||
checkf(InChar <= U32TEXT('\u007F'), TEXT("TChar::IsGraph() only supports basic latin block."));
|
||||
|
||||
@ -458,20 +458,20 @@ struct TChar
|
||||
return TChar<u8char>::IsGraph(static_cast<u8char>(InChar));
|
||||
}
|
||||
|
||||
else static_assert(sizeof(CharType) == -1, "Unsupported character type");
|
||||
else static_assert(sizeof(FCharType) == -1, "Unsupported character type");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr bool IsSpace(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr bool IsSpace(FCharType InChar)
|
||||
{
|
||||
if constexpr (CSameAs<CharType, char> || CSameAs<CharType, wchar>)
|
||||
if constexpr (CSameAs<FCharType, char> || CSameAs<FCharType, wchar>)
|
||||
{
|
||||
NAMESPACE_STD::locale Loc("");
|
||||
return NAMESPACE_STD::isspace(InChar, Loc);
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u8char>)
|
||||
else if constexpr (CSameAs<FCharType, u8char>)
|
||||
{
|
||||
/*
|
||||
* ISO/IEC 6429
|
||||
@ -488,7 +488,7 @@ struct TChar
|
||||
return false;
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u16char>)
|
||||
else if constexpr (CSameAs<FCharType, u16char>)
|
||||
{
|
||||
/*
|
||||
* ISO/IEC 6429
|
||||
@ -533,7 +533,7 @@ struct TChar
|
||||
return false;
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u32char>)
|
||||
else if constexpr (CSameAs<FCharType, u32char>)
|
||||
{
|
||||
/*
|
||||
* ISO/IEC 6429
|
||||
@ -578,26 +578,26 @@ struct TChar
|
||||
return false;
|
||||
}
|
||||
|
||||
else static_assert(sizeof(CharType) == -1, "Unsupported character type");
|
||||
else static_assert(sizeof(FCharType) == -1, "Unsupported character type");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr bool IsBlank(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr bool IsBlank(FCharType InChar)
|
||||
{
|
||||
if constexpr (CSameAs<CharType, char> || CSameAs<CharType, wchar>)
|
||||
if constexpr (CSameAs<FCharType, char> || CSameAs<FCharType, wchar>)
|
||||
{
|
||||
NAMESPACE_STD::locale Loc("");
|
||||
return NAMESPACE_STD::isblank(InChar, Loc);
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u8char>)
|
||||
else if constexpr (CSameAs<FCharType, u8char>)
|
||||
{
|
||||
/* <U0009>;<U0020>; */
|
||||
return InChar == U8TEXT('\u0009') || InChar == U8TEXT('\u0020');
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u16char>)
|
||||
else if constexpr (CSameAs<FCharType, u16char>)
|
||||
{
|
||||
/* <U0009>;<U0020>;<U1680>;<U180E>;<U2000>..<U2006>;<U2008>..<U200A>;<U205F>;<U3000>; */
|
||||
return
|
||||
@ -608,7 +608,7 @@ struct TChar
|
||||
(InChar == U16TEXT('\u205F') || InChar == U16TEXT('\u3000'));
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u32char>)
|
||||
else if constexpr (CSameAs<FCharType, u32char>)
|
||||
{
|
||||
/* <U0009>;<U0020>;<U1680>;<U180E>;<U2000>..<U2006>;<U2008>..<U200A>;<U205F>;<U3000>; */
|
||||
return
|
||||
@ -619,20 +619,20 @@ struct TChar
|
||||
(InChar == U32TEXT('\u205F') || InChar == U32TEXT('\u3000'));
|
||||
}
|
||||
|
||||
else static_assert(sizeof(CharType) == -1, "Unsupported character type");
|
||||
else static_assert(sizeof(FCharType) == -1, "Unsupported character type");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr bool IsPrint(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr bool IsPrint(FCharType InChar)
|
||||
{
|
||||
if constexpr (CSameAs<CharType, char> || CSameAs<CharType, wchar>)
|
||||
if constexpr (CSameAs<FCharType, char> || CSameAs<FCharType, wchar>)
|
||||
{
|
||||
NAMESPACE_STD::locale Loc("");
|
||||
return NAMESPACE_STD::isprint(InChar, Loc);
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u8char>)
|
||||
else if constexpr (CSameAs<FCharType, u8char>)
|
||||
{
|
||||
/*
|
||||
* BASIC LATIN
|
||||
@ -643,7 +643,7 @@ struct TChar
|
||||
return false;
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u16char>)
|
||||
else if constexpr (CSameAs<FCharType, u16char>)
|
||||
{
|
||||
checkf(InChar <= U16TEXT('\u007F'), TEXT("TChar::IsPrint() only supports basic latin block."));
|
||||
|
||||
@ -652,7 +652,7 @@ struct TChar
|
||||
return TChar<u8char>::IsPrint(static_cast<u8char>(InChar));
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u32char>)
|
||||
else if constexpr (CSameAs<FCharType, u32char>)
|
||||
{
|
||||
checkf(InChar <= U32TEXT('\u007F'), TEXT("TChar::IsPrint() only supports basic latin block."));
|
||||
|
||||
@ -661,20 +661,20 @@ struct TChar
|
||||
return TChar<u8char>::IsPrint(static_cast<u8char>(InChar));
|
||||
}
|
||||
|
||||
else static_assert(sizeof(CharType) == -1, "Unsupported character type");
|
||||
else static_assert(sizeof(FCharType) == -1, "Unsupported character type");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr bool IsPunct(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr bool IsPunct(FCharType InChar)
|
||||
{
|
||||
if constexpr (CSameAs<CharType, char> || CSameAs<CharType, wchar>)
|
||||
if constexpr (CSameAs<FCharType, char> || CSameAs<FCharType, wchar>)
|
||||
{
|
||||
NAMESPACE_STD::locale Loc("");
|
||||
return NAMESPACE_STD::ispunct(InChar, Loc);
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u8char>)
|
||||
else if constexpr (CSameAs<FCharType, u8char>)
|
||||
{
|
||||
/*
|
||||
* BASIC LATIN
|
||||
@ -689,7 +689,7 @@ struct TChar
|
||||
return false;
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u16char>)
|
||||
else if constexpr (CSameAs<FCharType, u16char>)
|
||||
{
|
||||
checkf(InChar <= U16TEXT('\u007F'), TEXT("TChar::IsPunct() only supports basic latin block."));
|
||||
|
||||
@ -698,7 +698,7 @@ struct TChar
|
||||
return TChar<u8char>::IsPunct(static_cast<u8char>(InChar));
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u32char>)
|
||||
else if constexpr (CSameAs<FCharType, u32char>)
|
||||
{
|
||||
checkf(InChar <= U32TEXT('\u007F'), TEXT("TChar::IsPunct() only supports basic latin block."));
|
||||
|
||||
@ -707,20 +707,20 @@ struct TChar
|
||||
return TChar<u8char>::IsPunct(static_cast<u8char>(InChar));
|
||||
}
|
||||
|
||||
else static_assert(sizeof(CharType) == -1, "Unsupported character type");
|
||||
else static_assert(sizeof(FCharType) == -1, "Unsupported character type");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr CharType ToLower(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr FCharType ToLower(FCharType InChar)
|
||||
{
|
||||
if constexpr (CSameAs<CharType, char> || CSameAs<CharType, wchar>)
|
||||
if constexpr (CSameAs<FCharType, char> || CSameAs<FCharType, wchar>)
|
||||
{
|
||||
NAMESPACE_STD::locale Loc("");
|
||||
return static_cast<CharType>(NAMESPACE_STD::tolower(InChar, Loc));
|
||||
return static_cast<FCharType>(NAMESPACE_STD::tolower(InChar, Loc));
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u8char>)
|
||||
else if constexpr (CSameAs<FCharType, u8char>)
|
||||
{
|
||||
/*
|
||||
* BASIC LATIN
|
||||
@ -737,7 +737,7 @@ struct TChar
|
||||
return InChar;
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u16char>)
|
||||
else if constexpr (CSameAs<FCharType, u16char>)
|
||||
{
|
||||
checkf(InChar <= U16TEXT('\u007F'), TEXT("TChar::ToLower() only supports basic latin block."));
|
||||
|
||||
@ -746,7 +746,7 @@ struct TChar
|
||||
return static_cast<u16char>(TChar<u8char>::ToLower(static_cast<u8char>(InChar)));
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u32char>)
|
||||
else if constexpr (CSameAs<FCharType, u32char>)
|
||||
{
|
||||
checkf(InChar <= U32TEXT('\u007F'), TEXT("TChar::ToLower() only supports basic latin block."));
|
||||
|
||||
@ -755,20 +755,20 @@ struct TChar
|
||||
return static_cast<u16char>(TChar<u8char>::ToLower(static_cast<u8char>(InChar)));
|
||||
}
|
||||
|
||||
else static_assert(sizeof(CharType) == -1, "Unsupported character type");
|
||||
else static_assert(sizeof(FCharType) == -1, "Unsupported character type");
|
||||
|
||||
return InChar;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr CharType ToUpper(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr FCharType ToUpper(FCharType InChar)
|
||||
{
|
||||
if constexpr (CSameAs<CharType, char> || CSameAs<CharType, wchar>)
|
||||
if constexpr (CSameAs<FCharType, char> || CSameAs<FCharType, wchar>)
|
||||
{
|
||||
NAMESPACE_STD::locale Loc("");
|
||||
return static_cast<CharType>(NAMESPACE_STD::toupper(InChar, Loc));
|
||||
return static_cast<FCharType>(NAMESPACE_STD::toupper(InChar, Loc));
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u8char>)
|
||||
else if constexpr (CSameAs<FCharType, u8char>)
|
||||
{
|
||||
/*
|
||||
* BASIC LATIN
|
||||
@ -785,7 +785,7 @@ struct TChar
|
||||
return InChar;
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u16char>)
|
||||
else if constexpr (CSameAs<FCharType, u16char>)
|
||||
{
|
||||
checkf(InChar <= U16TEXT('\u007F'), TEXT("TChar::ToUpper() only supports basic latin block."));
|
||||
|
||||
@ -794,7 +794,7 @@ struct TChar
|
||||
return static_cast<u16char>(TChar<u8char>::ToUpper(static_cast<u8char>(InChar)));
|
||||
}
|
||||
|
||||
else if constexpr (CSameAs<CharType, u32char>)
|
||||
else if constexpr (CSameAs<FCharType, u32char>)
|
||||
{
|
||||
checkf(InChar <= U32TEXT('\u007F'), TEXT("TChar::ToUpper() only supports basic latin block."));
|
||||
|
||||
@ -803,12 +803,12 @@ struct TChar
|
||||
return static_cast<u16char>(TChar<u8char>::ToUpper(static_cast<u8char>(InChar)));
|
||||
}
|
||||
|
||||
else static_assert(sizeof(CharType) == -1, "Unsupported character type");
|
||||
else static_assert(sizeof(FCharType) == -1, "Unsupported character type");
|
||||
|
||||
return InChar;
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr unsigned ToDigit(CharType InChar)
|
||||
NODISCARD FORCEINLINE static constexpr unsigned ToDigit(FCharType InChar)
|
||||
{
|
||||
static_assert(TChar::IsASCII());
|
||||
|
||||
@ -834,12 +834,12 @@ struct TChar
|
||||
|
||||
static_assert(sizeof(DigitFromChar) == 256);
|
||||
|
||||
if constexpr (sizeof(CharType) > 1) if (InChar >> 8) return DigitFromChar[0];
|
||||
if constexpr (sizeof(FCharType) > 1) if (InChar >> 8) return DigitFromChar[0];
|
||||
|
||||
return DigitFromChar[InChar];
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr unsigned ToDigit(CharType InChar, bool bLowercase)
|
||||
NODISCARD FORCEINLINE static constexpr unsigned ToDigit(FCharType InChar, bool bLowercase)
|
||||
{
|
||||
static_assert(TChar::IsASCII());
|
||||
|
||||
@ -867,7 +867,7 @@ struct TChar
|
||||
|
||||
static_assert(sizeof(DigitFromChar) == 256);
|
||||
|
||||
if constexpr (sizeof(CharType) > 1) if (InChar >> 8) return DigitFromChar[0];
|
||||
if constexpr (sizeof(FCharType) > 1) if (InChar >> 8) return DigitFromChar[0];
|
||||
|
||||
return DigitFromChar[InChar];
|
||||
}
|
||||
@ -894,25 +894,25 @@ struct TChar
|
||||
|
||||
static_assert(sizeof(DigitFromChar) == 256);
|
||||
|
||||
if constexpr (sizeof(CharType) > 1) if (InChar >> 8) return DigitFromChar[0];
|
||||
if constexpr (sizeof(FCharType) > 1) if (InChar >> 8) return DigitFromChar[0];
|
||||
|
||||
return DigitFromChar[InChar];
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr CharType FromDigit(unsigned InDigit)
|
||||
NODISCARD FORCEINLINE static constexpr FCharType FromDigit(unsigned InDigit)
|
||||
{
|
||||
checkf(InDigit < 36, TEXT("Digit must be in the range [0, 35]."));
|
||||
|
||||
return LITERAL(CharType, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")[InDigit];
|
||||
return LITERAL(FCharType, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")[InDigit];
|
||||
}
|
||||
|
||||
NODISCARD FORCEINLINE static constexpr CharType FromDigit(unsigned InDigit, bool bLowercase)
|
||||
NODISCARD FORCEINLINE static constexpr FCharType FromDigit(unsigned InDigit, bool bLowercase)
|
||||
{
|
||||
checkf(InDigit < 36, TEXT("Digit must be in the range [0, 35]."));
|
||||
|
||||
if (bLowercase) return LITERAL(CharType, "0123456789abcdefghijklmnopqrstuvwxyz")[InDigit];
|
||||
if (bLowercase) return LITERAL(FCharType, "0123456789abcdefghijklmnopqrstuvwxyz")[InDigit];
|
||||
|
||||
return LITERAL(CharType, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")[InDigit];
|
||||
return LITERAL(FCharType, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")[InDigit];
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -264,6 +264,7 @@ struct TStringObjectFormatter
|
||||
{
|
||||
static bool Do(auto& Result, auto& Object, auto Param)
|
||||
{
|
||||
// ReSharper disable once CppInconsistentNaming
|
||||
using U = TRemoveCVRef<decltype(Object)>;
|
||||
|
||||
if constexpr (!CConst<TRemoveReference<decltype(Object)>>)
|
||||
@ -1065,9 +1066,9 @@ struct TStringObjectFormatter
|
||||
}
|
||||
}
|
||||
|
||||
using UnsignedU = TMakeUnsigned<U>;
|
||||
using FUnsignedU = TMakeUnsigned<U>;
|
||||
|
||||
UnsignedU Unsigned = static_cast<UnsignedU>(Object);
|
||||
FUnsignedU Unsigned = static_cast<FUnsignedU>(Object);
|
||||
|
||||
bool bNegative = false;
|
||||
|
||||
@ -1077,11 +1078,11 @@ struct TStringObjectFormatter
|
||||
{
|
||||
bNegative = true;
|
||||
|
||||
Unsigned = static_cast<UnsignedU>(-Unsigned);
|
||||
Unsigned = static_cast<FUnsignedU>(-Unsigned);
|
||||
}
|
||||
}
|
||||
|
||||
constexpr size_t BufferSize = sizeof(UnsignedU) * 8 + 4;
|
||||
constexpr size_t BufferSize = sizeof(FUnsignedU) * 8 + 4;
|
||||
|
||||
T Buffer[BufferSize];
|
||||
|
||||
@ -1111,8 +1112,8 @@ struct TStringObjectFormatter
|
||||
case 6:
|
||||
case 7:
|
||||
case 9:
|
||||
case 10: do { *--Iter = static_cast<T>('0' + Unsigned % Param.Base); Unsigned = static_cast<UnsignedU>(Unsigned / Param.Base); } while (Unsigned != 0); break;
|
||||
default: do { *--Iter = TChar<T>::FromDigit(Unsigned % Param.Base, bLowercase); Unsigned = static_cast<UnsignedU>(Unsigned / Param.Base); } while (Unsigned != 0); break;
|
||||
case 10: do { *--Iter = static_cast<T>('0' + Unsigned % Param.Base); Unsigned = static_cast<FUnsignedU>(Unsigned / Param.Base); } while (Unsigned != 0); break;
|
||||
default: do { *--Iter = TChar<T>::FromDigit(Unsigned % Param.Base, bLowercase); Unsigned = static_cast<FUnsignedU>(Unsigned / Param.Base); } while (Unsigned != 0); break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1130,12 +1131,12 @@ struct TStringObjectFormatter
|
||||
case 6:
|
||||
case 7:
|
||||
case 9:
|
||||
case 10: do { *--Iter = static_cast<T>('0' + Unsigned % Param.Base); Unsigned = static_cast<UnsignedU>(Unsigned / Param.Base); } while (Unsigned != 0); break;
|
||||
default: do { *--Iter = TChar<T>::FromDigit(Unsigned % Param.Base); Unsigned = static_cast<UnsignedU>(Unsigned / Param.Base); } while (Unsigned != 0); break;
|
||||
case 10: do { *--Iter = static_cast<T>('0' + Unsigned % Param.Base); Unsigned = static_cast<FUnsignedU>(Unsigned / Param.Base); } while (Unsigned != 0); break;
|
||||
default: do { *--Iter = TChar<T>::FromDigit(Unsigned % Param.Base); Unsigned = static_cast<FUnsignedU>(Unsigned / Param.Base); } while (Unsigned != 0); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else do { *--Iter = static_cast<T>('0' + Unsigned % 10); Unsigned = static_cast<UnsignedU>(Unsigned / 10); } while (Unsigned != 0);
|
||||
else do { *--Iter = static_cast<T>('0' + Unsigned % 10); Unsigned = static_cast<FUnsignedU>(Unsigned / 10); } while (Unsigned != 0);
|
||||
|
||||
T* DigitBegin = Iter;
|
||||
|
||||
@ -1144,7 +1145,7 @@ struct TStringObjectFormatter
|
||||
{
|
||||
const size_t Padding = Param.Padding - (DigitEnd - DigitBegin);
|
||||
|
||||
if (Param.Padding < sizeof(UnsignedU) * 8) for (size_t Index = 0; Index != Padding; ++Index) *--Iter = LITERAL(T, '0');
|
||||
if (Param.Padding < sizeof(FUnsignedU) * 8) for (size_t Index = 0; Index != Padding; ++Index) *--Iter = LITERAL(T, '0');
|
||||
}
|
||||
|
||||
// Append the prefix to the buffer.
|
||||
@ -1171,7 +1172,7 @@ struct TStringObjectFormatter
|
||||
{
|
||||
const size_t Padding = Param.Padding - (DigitEnd - DigitBegin);
|
||||
|
||||
if (Param.Padding > sizeof(UnsignedU) * 8)
|
||||
if (Param.Padding > sizeof(FUnsignedU) * 8)
|
||||
{
|
||||
Result.Reserve(Result.Num() + (DigitBegin - Iter) + Param.Padding);
|
||||
|
||||
@ -1349,6 +1350,7 @@ struct TStringObjectParser
|
||||
{
|
||||
static bool Do(auto& View, auto& Object, auto Param)
|
||||
{
|
||||
// ReSharper disable once CppInconsistentNaming
|
||||
using U = TRemoveCVRef<decltype(Object)>;
|
||||
|
||||
if constexpr (CConst<TRemoveReference<decltype(Object)>>)
|
||||
@ -2200,17 +2202,17 @@ struct TStringObjectParser
|
||||
return TChar<T>::ToDigit(Char);
|
||||
};
|
||||
|
||||
using UnsignedU = TMakeUnsigned<U>;
|
||||
using FUnsignedU = TMakeUnsigned<U>;
|
||||
|
||||
// The limit value that can be stored in an unsigned integer.
|
||||
constexpr UnsignedU UnsignedMaximum = static_cast<UnsignedU>(-1);
|
||||
constexpr FUnsignedU UnsignedMaximum = static_cast<FUnsignedU>(-1);
|
||||
|
||||
// The limit value that can be stored in a signed integer.
|
||||
constexpr U SignedMaximum = static_cast<U>(UnsignedMaximum >> 1);
|
||||
constexpr U SignedMinimum = -static_cast<U>(SignedMaximum) - 1;
|
||||
|
||||
UnsignedU LastValue = 0;
|
||||
UnsignedU Unsigned = 0;
|
||||
FUnsignedU LastValue = 0;
|
||||
FUnsignedU Unsigned = 0;
|
||||
|
||||
if (TrimmedView.IsEmpty()) return false;
|
||||
|
||||
@ -2223,7 +2225,7 @@ struct TStringObjectParser
|
||||
|
||||
TrimmedView.RemovePrefix(1);
|
||||
|
||||
Unsigned = static_cast<UnsignedU>(Digit);
|
||||
Unsigned = static_cast<FUnsignedU>(Digit);
|
||||
|
||||
while (!TrimmedView.IsEmpty())
|
||||
{
|
||||
@ -2235,7 +2237,7 @@ struct TStringObjectParser
|
||||
|
||||
LastValue = Unsigned;
|
||||
|
||||
Unsigned = static_cast<UnsignedU>(LastValue * Base + Digit);
|
||||
Unsigned = static_cast<FUnsignedU>(LastValue * Base + Digit);
|
||||
|
||||
if (Unsigned < LastValue) return false;
|
||||
}
|
||||
@ -2245,11 +2247,11 @@ struct TStringObjectParser
|
||||
if constexpr (CSigned<U>)
|
||||
{
|
||||
// Handle overflow.
|
||||
if (!bNegative && Unsigned >= static_cast<UnsignedU>(SignedMaximum)) return false;
|
||||
if ( bNegative && Unsigned >= static_cast<UnsignedU>(SignedMinimum)) return false;
|
||||
if (!bNegative && Unsigned >= static_cast<FUnsignedU>(SignedMaximum)) return false;
|
||||
if ( bNegative && Unsigned >= static_cast<FUnsignedU>(SignedMinimum)) return false;
|
||||
|
||||
// Handle negative sign.
|
||||
if (bNegative) Unsigned = static_cast<UnsignedU>(-Unsigned);
|
||||
if (bNegative) Unsigned = static_cast<FUnsignedU>(-Unsigned);
|
||||
}
|
||||
|
||||
Object = static_cast<U>(Unsigned);
|
||||
@ -2705,14 +2707,14 @@ NAMESPACE_PRIVATE_END
|
||||
|
||||
template <CCharType T, CAllocator<T> Allocator>
|
||||
template <typename ... Ts>
|
||||
void TString<T, Allocator>::AppendFormat(TStringView<ElementType> Fmt, const Ts&... Args)
|
||||
void TString<T, Allocator>::AppendFormat(TStringView<FElementType> Fmt, const Ts&... Args)
|
||||
{
|
||||
// The Unreal Engine says that the starting buffer size catches 99.97% of printf calls.
|
||||
constexpr size_t ReserveBufferSize = 512;
|
||||
|
||||
TString<T, TInlineAllocator<ReserveBufferSize>> Result;
|
||||
|
||||
NAMESPACE_PRIVATE::TStringFormatOrParseHelper<ElementType, true>::Do(Result, Fmt, ForwardAsTuple(Args...));
|
||||
NAMESPACE_PRIVATE::TStringFormatOrParseHelper<FElementType, true>::Do(Result, Fmt, ForwardAsTuple(Args...));
|
||||
|
||||
Append(Result.Begin(), Result.End());
|
||||
}
|
||||
@ -2721,13 +2723,13 @@ template <CCharType T>
|
||||
template <typename ... Ts>
|
||||
size_t TStringView<T>::ParseAndTrim(TStringView Fmt, Ts&... Args)
|
||||
{
|
||||
return NAMESPACE_PRIVATE::TStringFormatOrParseHelper<ElementType, false>::Do(*this, Fmt, ForwardAsTuple(Args...));
|
||||
return NAMESPACE_PRIVATE::TStringFormatOrParseHelper<FElementType, false>::Do(*this, Fmt, ForwardAsTuple(Args...));
|
||||
}
|
||||
|
||||
template <CCharType T, CAllocator<T> Allocator>
|
||||
void TString<T, Allocator>::AppendBool(bool Value)
|
||||
{
|
||||
NAMESPACE_PRIVATE::TStringObjectFormatter<ElementType>::Do(*this, AsConst(Value), Invalid);
|
||||
NAMESPACE_PRIVATE::TStringObjectFormatter<FElementType>::Do(*this, AsConst(Value), Invalid);
|
||||
}
|
||||
|
||||
template <CCharType T, CAllocator<T> Allocator>
|
||||
@ -2738,13 +2740,13 @@ void TString<T, Allocator>::AppendInt(U Value, unsigned Base)
|
||||
|
||||
struct { unsigned Base; } Param = { Base };
|
||||
|
||||
NAMESPACE_PRIVATE::TStringObjectFormatter<ElementType>::Do(*this, AsConst(Value), Param);
|
||||
NAMESPACE_PRIVATE::TStringObjectFormatter<FElementType>::Do(*this, AsConst(Value), Param);
|
||||
}
|
||||
|
||||
template <CCharType T, CAllocator<T> Allocator> template <CFloatingPoint U> requires (!CConst<U> && !CVolatile<U>)
|
||||
void TString<T, Allocator>::AppendFloat(U Value)
|
||||
{
|
||||
NAMESPACE_PRIVATE::TStringObjectFormatter<ElementType>::Do(*this, AsConst(Value), Invalid);
|
||||
NAMESPACE_PRIVATE::TStringObjectFormatter<FElementType>::Do(*this, AsConst(Value), Invalid);
|
||||
}
|
||||
|
||||
template <CCharType T, CAllocator<T> Allocator> template <CFloatingPoint U> requires (!CConst<U> && !CVolatile<U>)
|
||||
@ -2752,7 +2754,7 @@ void TString<T, Allocator>::AppendFloat(U Value, bool bFixed, bool bScientific)
|
||||
{
|
||||
struct { bool bFixed; bool bScientific; } Param = { bFixed, bScientific };
|
||||
|
||||
NAMESPACE_PRIVATE::TStringObjectFormatter<ElementType>::Do(*this, AsConst(Value), Param);
|
||||
NAMESPACE_PRIVATE::TStringObjectFormatter<FElementType>::Do(*this, AsConst(Value), Param);
|
||||
}
|
||||
|
||||
template <CCharType T, CAllocator<T> Allocator> template <CFloatingPoint U> requires (!CConst<U> && !CVolatile<U>)
|
||||
@ -2760,7 +2762,7 @@ void TString<T, Allocator>::AppendFloat(U Value, bool bFixed, bool bScientific,
|
||||
{
|
||||
struct { bool bFixed; bool bScientific; unsigned Precision; } Param = { bFixed, bScientific, Precision };
|
||||
|
||||
NAMESPACE_PRIVATE::TStringObjectFormatter<ElementType>::Do(*this, AsConst(Value), Param);
|
||||
NAMESPACE_PRIVATE::TStringObjectFormatter<FElementType>::Do(*this, AsConst(Value), Param);
|
||||
}
|
||||
|
||||
template <CCharType T>
|
||||
@ -2768,9 +2770,9 @@ constexpr bool TStringView<T>::ToBoolAndTrim()
|
||||
{
|
||||
bool Value = false;
|
||||
|
||||
if (!NAMESPACE_PRIVATE::TStringObjectParser<ElementType>::Do(*this, Value, Invalid))
|
||||
if (!NAMESPACE_PRIVATE::TStringObjectParser<FElementType>::Do(*this, Value, Invalid))
|
||||
{
|
||||
if (int IntValue; NAMESPACE_PRIVATE::TStringObjectParser<ElementType>::Do(*this, IntValue, Invalid))
|
||||
if (int IntValue; NAMESPACE_PRIVATE::TStringObjectParser<FElementType>::Do(*this, IntValue, Invalid))
|
||||
{
|
||||
Value = IntValue != 0;
|
||||
}
|
||||
@ -2789,7 +2791,7 @@ constexpr U TStringView<T>::ToIntAndTrim(unsigned Base)
|
||||
|
||||
struct { unsigned Base; } Param = { Base };
|
||||
|
||||
NAMESPACE_PRIVATE::TStringObjectParser<ElementType>::Do(*this, Value, Param);
|
||||
NAMESPACE_PRIVATE::TStringObjectParser<FElementType>::Do(*this, Value, Param);
|
||||
|
||||
return Value;
|
||||
}
|
||||
@ -2802,7 +2804,7 @@ constexpr U TStringView<T>::ToFloatAndTrim(bool bFixed, bool bScientific)
|
||||
|
||||
struct { bool bFixed; bool bScientific; } Param = { bFixed, bScientific };
|
||||
|
||||
NAMESPACE_PRIVATE::TStringObjectParser<ElementType>::Do(*this, Value, Param);
|
||||
NAMESPACE_PRIVATE::TStringObjectParser<FElementType>::Do(*this, Value, Param);
|
||||
|
||||
return Value;
|
||||
}
|
||||
|
@ -35,33 +35,33 @@ class TString : public TArray<T, Allocator>
|
||||
{
|
||||
private:
|
||||
|
||||
using Super = TArray<T, Allocator>;
|
||||
using FSuper = TArray<T, Allocator>;
|
||||
|
||||
public:
|
||||
|
||||
using ElementType = typename Super::ElementType;
|
||||
using AllocatorType = typename Super::AllocatorType;
|
||||
using FElementType = typename FSuper::FElementType;
|
||||
using FAllocatorType = typename FSuper::FAllocatorType;
|
||||
|
||||
using Reference = typename Super:: Reference;
|
||||
using ConstReference = typename Super::ConstReference;
|
||||
using FReference = typename FSuper:: FReference;
|
||||
using FConstReference = typename FSuper::FConstReference;
|
||||
|
||||
using Iterator = typename Super:: Iterator;
|
||||
using ConstIterator = typename Super::ConstIterator;
|
||||
using FIterator = typename FSuper:: FIterator;
|
||||
using FConstIterator = typename FSuper::FConstIterator;
|
||||
|
||||
using ReverseIterator = typename Super:: ReverseIterator;
|
||||
using ConstReverseIterator = typename Super::ConstReverseIterator;
|
||||
using FReverseIterator = typename FSuper:: FReverseIterator;
|
||||
using FConstReverseIterator = typename FSuper::FConstReverseIterator;
|
||||
|
||||
static_assert(CContiguousIterator< Iterator>);
|
||||
static_assert(CContiguousIterator<ConstIterator>);
|
||||
static_assert(CContiguousIterator< FIterator>);
|
||||
static_assert(CContiguousIterator<FConstIterator>);
|
||||
|
||||
/** Default constructor. Constructs an empty string. */
|
||||
FORCEINLINE TString() = default;
|
||||
|
||||
/** Constructs the string with 'Count' copies of characters with 'InValue'. */
|
||||
FORCEINLINE TString(size_t Count, ElementType InChar) : Super(Count, InChar) { }
|
||||
FORCEINLINE TString(size_t Count, FElementType InChar) : FSuper(Count, InChar) { }
|
||||
|
||||
/** Constructs a string with the contents of the range ['InPtr', 'InPtr' + 'Count'). */
|
||||
FORCEINLINE TString(const ElementType* InPtr, size_t Count) : TString(TStringView<ElementType>(InPtr, Count))
|
||||
FORCEINLINE TString(const FElementType* InPtr, size_t Count) : TString(TStringView<FElementType>(InPtr, Count))
|
||||
{
|
||||
checkf(InPtr != nullptr, TEXT("TString cannot be initialized by nullptr. Please check the pointer."));
|
||||
}
|
||||
@ -69,7 +69,7 @@ public:
|
||||
FORCEINLINE TString(nullptr_t, size_t) = delete;
|
||||
|
||||
/** Constructs a string with the contents of the range ['InPtr', '\0'). */
|
||||
FORCEINLINE TString(const ElementType* InPtr) : TString(TStringView<ElementType>(InPtr))
|
||||
FORCEINLINE TString(const FElementType* InPtr) : TString(TStringView<FElementType>(InPtr))
|
||||
{
|
||||
checkf(InPtr != nullptr, TEXT("TString cannot be initialized by nullptr. Please check the pointer."));
|
||||
}
|
||||
@ -77,11 +77,11 @@ public:
|
||||
FORCEINLINE TString(nullptr_t) = delete;
|
||||
|
||||
/** Constructs the string with the contents of the 'View'. */
|
||||
FORCEINLINE TString(TStringView<ElementType> View) : TString(View.Begin(), View.End()) { }
|
||||
FORCEINLINE TString(TStringView<FElementType> View) : TString(View.Begin(), View.End()) { }
|
||||
|
||||
/** Constructs the string with the contents of the range ['First', 'Last'). */
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<ElementType, TIteratorReferenceType<I>>)
|
||||
FORCEINLINE TString(I First, S Last) : Super(MoveTemp(First), MoveTemp(Last)) { }
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<FElementType, TIteratorReferenceType<I>>)
|
||||
FORCEINLINE TString(I First, S Last) : FSuper(MoveTemp(First), MoveTemp(Last)) { }
|
||||
|
||||
/** Copy constructor. Constructs the string with the copy of the contents of 'InValue'. */
|
||||
FORCEINLINE TString(const TString&) = default;
|
||||
@ -90,7 +90,7 @@ public:
|
||||
FORCEINLINE TString(TString&&) = default;
|
||||
|
||||
/** Constructs the string with the contents of the initializer list. */
|
||||
FORCEINLINE TString(initializer_list<ElementType> IL) : TString(Iteration::Begin(IL), Iteration::End(IL)) { }
|
||||
FORCEINLINE TString(initializer_list<FElementType> IL) : TString(Iteration::Begin(IL), Iteration::End(IL)) { }
|
||||
|
||||
/** Copy assignment operator. Replaces the contents with a copy of the contents of 'InValue'. */
|
||||
FORCEINLINE TString& operator=(const TString&) = default;
|
||||
@ -99,27 +99,27 @@ public:
|
||||
FORCEINLINE TString& operator=(TString&&) = default;
|
||||
|
||||
/** Compares the contents of two strings. */
|
||||
NODISCARD friend FORCEINLINE bool operator==(const TString& LHS, const TString& RHS) { return TStringView<ElementType>(LHS) == TStringView<ElementType>(RHS); }
|
||||
NODISCARD friend FORCEINLINE bool operator==(const TString& LHS, const TString& RHS) { return TStringView<FElementType>(LHS) == TStringView<FElementType>(RHS); }
|
||||
|
||||
/** Compares the contents of a string and a character. */
|
||||
NODISCARD friend FORCEINLINE bool operator==(const TString& LHS, ElementType RHS) { return TStringView<ElementType>(LHS) == RHS; }
|
||||
NODISCARD friend FORCEINLINE bool operator==(const TString& LHS, const ElementType* RHS) { return TStringView<ElementType>(LHS) == RHS; }
|
||||
NODISCARD friend FORCEINLINE bool operator==( ElementType LHS, const TString& RHS) { return LHS == TStringView<ElementType>(RHS); }
|
||||
NODISCARD friend FORCEINLINE bool operator==(const ElementType* LHS, const TString& RHS) { return LHS == TStringView<ElementType>(RHS); }
|
||||
NODISCARD friend FORCEINLINE bool operator==(const TString& LHS, FElementType RHS) { return TStringView<FElementType>(LHS) == RHS; }
|
||||
NODISCARD friend FORCEINLINE bool operator==(const TString& LHS, const FElementType* RHS) { return TStringView<FElementType>(LHS) == RHS; }
|
||||
NODISCARD friend FORCEINLINE bool operator==( FElementType LHS, const TString& RHS) { return LHS == TStringView<FElementType>(RHS); }
|
||||
NODISCARD friend FORCEINLINE bool operator==(const FElementType* LHS, const TString& RHS) { return LHS == TStringView<FElementType>(RHS); }
|
||||
|
||||
/** Compares the contents of 'LHS' and 'RHS' lexicographically. */
|
||||
NODISCARD friend FORCEINLINE auto operator<=>(const TString& LHS, const TString& RHS) { return TStringView<ElementType>(LHS) <=> TStringView<ElementType>(RHS); }
|
||||
NODISCARD friend FORCEINLINE auto operator<=>(const TString& LHS, const TString& RHS) { return TStringView<FElementType>(LHS) <=> TStringView<FElementType>(RHS); }
|
||||
|
||||
/** Compares the contents of 'LHS' and 'RHS' lexicographically. */
|
||||
NODISCARD friend FORCEINLINE auto operator<=>(const TString& LHS, ElementType RHS) { return TStringView<ElementType>(LHS) <=> RHS; }
|
||||
NODISCARD friend FORCEINLINE auto operator<=>(const TString& LHS, const ElementType* RHS) { return TStringView<ElementType>(LHS) <=> RHS; }
|
||||
NODISCARD friend FORCEINLINE auto operator<=>( ElementType LHS, const TString& RHS) { return LHS <=> TStringView<ElementType>(RHS); }
|
||||
NODISCARD friend FORCEINLINE auto operator<=>(const ElementType* LHS, const TString& RHS) { return LHS <=> TStringView<ElementType>(RHS); }
|
||||
NODISCARD friend FORCEINLINE auto operator<=>(const TString& LHS, FElementType RHS) { return TStringView<FElementType>(LHS) <=> RHS; }
|
||||
NODISCARD friend FORCEINLINE auto operator<=>(const TString& LHS, const FElementType* RHS) { return TStringView<FElementType>(LHS) <=> RHS; }
|
||||
NODISCARD friend FORCEINLINE auto operator<=>( FElementType LHS, const TString& RHS) { return LHS <=> TStringView<FElementType>(RHS); }
|
||||
NODISCARD friend FORCEINLINE auto operator<=>(const FElementType* LHS, const TString& RHS) { return LHS <=> TStringView<FElementType>(RHS); }
|
||||
|
||||
public:
|
||||
|
||||
/** Inserts 'InValue' before 'Index' in the string. */
|
||||
FORCEINLINE Iterator Insert(size_t Index, ElementType InValue)
|
||||
FORCEINLINE FIterator Insert(size_t Index, FElementType InValue)
|
||||
{
|
||||
checkf(Index <= this->Num(), TEXT("Illegal index. Please check Index <= Num()."));
|
||||
|
||||
@ -127,15 +127,15 @@ public:
|
||||
}
|
||||
|
||||
/** Inserts 'InValue' before 'Iter' in the string. */
|
||||
FORCEINLINE Iterator Insert(ConstIterator Iter, ElementType InValue)
|
||||
FORCEINLINE FIterator Insert(FConstIterator Iter, FElementType InValue)
|
||||
{
|
||||
checkf(this->IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
return Super::Insert(Iter, InValue);
|
||||
return FSuper::Insert(Iter, InValue);
|
||||
}
|
||||
|
||||
/** Inserts 'Count' copies of the 'InValue' before 'Index' in the string. */
|
||||
FORCEINLINE Iterator Insert(size_t Index, size_t Count, ElementType InValue)
|
||||
FORCEINLINE FIterator Insert(size_t Index, size_t Count, FElementType InValue)
|
||||
{
|
||||
checkf(Index <= this->Num(), TEXT("Illegal index. Please check Index <= Num()."));
|
||||
|
||||
@ -143,15 +143,15 @@ public:
|
||||
}
|
||||
|
||||
/** Inserts 'Count' copies of the 'InValue' before 'Iter' in the string. */
|
||||
FORCEINLINE Iterator Insert(ConstIterator Iter, size_t Count, ElementType InValue)
|
||||
FORCEINLINE FIterator Insert(FConstIterator Iter, size_t Count, FElementType InValue)
|
||||
{
|
||||
checkf(this->IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
return Super::Insert(Iter, Count, InValue);
|
||||
return FSuper::Insert(Iter, Count, InValue);
|
||||
}
|
||||
|
||||
/** Inserts characters from the 'View' before 'Index' in the string. */
|
||||
FORCEINLINE Iterator Insert(size_t Index, TStringView<ElementType> View)
|
||||
FORCEINLINE FIterator Insert(size_t Index, TStringView<FElementType> View)
|
||||
{
|
||||
checkf(Index <= this->Num(), TEXT("Illegal index. Please check Index <= Num()."));
|
||||
|
||||
@ -159,7 +159,7 @@ public:
|
||||
}
|
||||
|
||||
/** Inserts characters from the 'View' before 'Iter' in the string. */
|
||||
FORCEINLINE Iterator Insert(ConstIterator Iter, TStringView<ElementType> View)
|
||||
FORCEINLINE FIterator Insert(FConstIterator Iter, TStringView<FElementType> View)
|
||||
{
|
||||
checkf(this->IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
@ -167,8 +167,8 @@ public:
|
||||
}
|
||||
|
||||
/** Inserts characters from the range ['First', 'Last') before 'Index' in the string. */
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<ElementType, TIteratorReferenceType<I>>)
|
||||
FORCEINLINE Iterator Insert(size_t Index, I First, S Last)
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<FElementType, TIteratorReferenceType<I>>)
|
||||
FORCEINLINE FIterator Insert(size_t Index, I First, S Last)
|
||||
{
|
||||
checkf(Index <= this->Num(), TEXT("Illegal index. Please check Index <= Num()."));
|
||||
|
||||
@ -176,16 +176,16 @@ public:
|
||||
}
|
||||
|
||||
/** Inserts characters from the range ['First', 'Last') before 'Iter'. */
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<ElementType, TIteratorReferenceType<I>>)
|
||||
FORCEINLINE Iterator Insert(ConstIterator Iter, I First, S Last)
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<FElementType, TIteratorReferenceType<I>>)
|
||||
FORCEINLINE FIterator Insert(FConstIterator Iter, I First, S Last)
|
||||
{
|
||||
checkf(this->IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
return Super::Insert(Iter, MoveTemp(First), MoveTemp(Last));
|
||||
return FSuper::Insert(Iter, MoveTemp(First), MoveTemp(Last));
|
||||
}
|
||||
|
||||
/** Inserts characters from the initializer list before 'Index' in the string. */
|
||||
FORCEINLINE Iterator Insert(size_t Index, initializer_list<ElementType> IL)
|
||||
FORCEINLINE FIterator Insert(size_t Index, initializer_list<FElementType> IL)
|
||||
{
|
||||
checkf(Index <= this->Num(), TEXT("Illegal index. Please check Index <= Num()."));
|
||||
|
||||
@ -193,15 +193,15 @@ public:
|
||||
}
|
||||
|
||||
/** Inserts characters from the initializer list before 'Iter' in the string. */
|
||||
FORCEINLINE Iterator Insert(ConstIterator Iter, initializer_list<ElementType> IL)
|
||||
FORCEINLINE FIterator Insert(FConstIterator Iter, initializer_list<FElementType> IL)
|
||||
{
|
||||
checkf(this->IsValidIterator(Iter), TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
return Super::Insert(Iter, IL);
|
||||
return FSuper::Insert(Iter, IL);
|
||||
}
|
||||
|
||||
/** Erases the character at 'Index' in the string. But it may change the order of characters. */
|
||||
FORCEINLINE Iterator Erase(size_t Index, bool bAllowShrinking = true)
|
||||
FORCEINLINE FIterator Erase(size_t Index, bool bAllowShrinking = true)
|
||||
{
|
||||
checkf(Index < this->Num(), TEXT("Illegal index. Please check Index < Num()."));
|
||||
|
||||
@ -209,15 +209,15 @@ public:
|
||||
}
|
||||
|
||||
/** Erases the character at 'Iter' in the string. But it may change the order of characters. */
|
||||
FORCEINLINE Iterator Erase(ConstIterator Iter, bool bAllowShrinking = true)
|
||||
FORCEINLINE FIterator Erase(FConstIterator Iter, bool bAllowShrinking = true)
|
||||
{
|
||||
checkf(this->IsValidIterator(Iter) && Iter != this->End(), TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
return Super::StableErase(Iter, bAllowShrinking);
|
||||
return FSuper::StableErase(Iter, bAllowShrinking);
|
||||
}
|
||||
|
||||
/** Erases 'CountToErase' characters starting from 'Index' in the string. But it may change the order of characters. */
|
||||
FORCEINLINE Iterator Erase(size_t Index, size_t CountToErase, bool bAllowShrinking = true)
|
||||
FORCEINLINE FIterator Erase(size_t Index, size_t CountToErase, bool bAllowShrinking = true)
|
||||
{
|
||||
checkf(Index <= this->Num() && Index + CountToErase <= this->Num(), TEXT("Illegal substring range. Please check Index and CountToErase."));
|
||||
|
||||
@ -226,24 +226,24 @@ public:
|
||||
}
|
||||
|
||||
/** Erases the characters in the range ['First', 'Last') in the string. But it may change the order of characters. */
|
||||
FORCEINLINE Iterator Erase(ConstIterator First, ConstIterator Last, bool bAllowShrinking = true)
|
||||
FORCEINLINE FIterator Erase(FConstIterator First, FConstIterator Last, bool bAllowShrinking = true)
|
||||
{
|
||||
checkf(this->IsValidIterator(First) && this->IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
return Super::StableErase(First, Last, bAllowShrinking);
|
||||
return FSuper::StableErase(First, Last, bAllowShrinking);
|
||||
}
|
||||
|
||||
/** Here, the 'Erase' is already stable and there is no need to provide 'StableErase'. */
|
||||
void StableErase(...) = delete;
|
||||
|
||||
/** Appends 'Count' copies of the 'InValue' to the end of the string. */
|
||||
TString& Append(size_t Count, ElementType InChar) { return Append(MakeCountedConstantIterator(InChar, Count), DefaultSentinel); }
|
||||
TString& Append(size_t Count, FElementType InChar) { return Append(MakeCountedConstantIterator(InChar, Count), DefaultSentinel); }
|
||||
|
||||
/** Appends the contents of the 'View' to the end of the string. */
|
||||
FORCEINLINE TString& Append(TStringView<ElementType> View) { return Append(View.Begin(), View.End()); }
|
||||
FORCEINLINE TString& Append(TStringView<FElementType> View) { return Append(View.Begin(), View.End()); }
|
||||
|
||||
/** Appends the contents of the range ['First', 'Last') to the end of the string. */
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<ElementType, TIteratorReferenceType<I>>)
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<FElementType, TIteratorReferenceType<I>>)
|
||||
TString& Append(I First, S Last)
|
||||
{
|
||||
if constexpr (CForwardIterator<I>)
|
||||
@ -258,7 +258,7 @@ public:
|
||||
|
||||
for (size_t Index = CurrentNum; Index != CurrentNum + Count; ++Index)
|
||||
{
|
||||
(*this)[Index] = ElementType(*First++);
|
||||
(*this)[Index] = FElementType(*First++);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -270,40 +270,40 @@ public:
|
||||
}
|
||||
|
||||
/** Appends the contents of the initializer list to the end of the string. */
|
||||
FORCEINLINE TString& Append(initializer_list<ElementType> IL) { return Append(Iteration::Begin(IL), Iteration::End(IL)); }
|
||||
FORCEINLINE TString& Append(initializer_list<FElementType> IL) { return Append(Iteration::Begin(IL), Iteration::End(IL)); }
|
||||
|
||||
/** Appends the given character value to the end of the string. */
|
||||
FORCEINLINE TString& operator+=(ElementType InChar) { return Append(1, InChar); }
|
||||
FORCEINLINE TString& operator+=(FElementType InChar) { return Append(1, InChar); }
|
||||
|
||||
/** Appends the contents of the 'View' to the end of the string. */
|
||||
FORCEINLINE TString& operator+=(TStringView<ElementType> View) { return Append(View); }
|
||||
FORCEINLINE TString& operator+=(TStringView<FElementType> View) { return Append(View); }
|
||||
|
||||
/** Appends the contents of the range ['First', 'Last') to the end of the string. */
|
||||
FORCEINLINE TString& operator+=(initializer_list<ElementType> IL) { return Append(IL); }
|
||||
FORCEINLINE TString& operator+=(initializer_list<FElementType> IL) { return Append(IL); }
|
||||
|
||||
/** Concatenates two strings. */
|
||||
NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, const TString& RHS) { return TString(LHS).Append(RHS); }
|
||||
|
||||
/** Concatenates the string with the given character value. */
|
||||
NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, ElementType RHS) { return TString(LHS).Append(1, RHS); }
|
||||
NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, const ElementType* RHS) { return TString(LHS).Append( RHS); }
|
||||
NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, TStringView<ElementType> RHS) { return TString(LHS).Append( RHS); }
|
||||
NODISCARD friend FORCEINLINE TString operator+( ElementType LHS, const TString& RHS) { return TString(1, LHS).Append(RHS); }
|
||||
NODISCARD friend FORCEINLINE TString operator+( const ElementType* LHS, const TString& RHS) { return TString( LHS).Append(RHS); }
|
||||
NODISCARD friend FORCEINLINE TString operator+(TStringView<ElementType> LHS, const TString& RHS) { return TString( LHS).Append(RHS); }
|
||||
NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, FElementType RHS) { return TString(LHS).Append(1, RHS); }
|
||||
NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, const FElementType* RHS) { return TString(LHS).Append( RHS); }
|
||||
NODISCARD friend FORCEINLINE TString operator+(const TString& LHS, TStringView<FElementType> RHS) { return TString(LHS).Append( RHS); }
|
||||
NODISCARD friend FORCEINLINE TString operator+( FElementType LHS, const TString& RHS) { return TString(1, LHS).Append(RHS); }
|
||||
NODISCARD friend FORCEINLINE TString operator+( const FElementType* LHS, const TString& RHS) { return TString( LHS).Append(RHS); }
|
||||
NODISCARD friend FORCEINLINE TString operator+(TStringView<FElementType> LHS, const TString& RHS) { return TString( LHS).Append(RHS); }
|
||||
|
||||
/** Concatenates two strings. The rvalue maybe modified. */
|
||||
NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, TString&& RHS) { LHS.Append(MoveTemp(RHS)); return LHS; }
|
||||
|
||||
/** Concatenates two strings. The rvalue maybe modified. */
|
||||
NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, ElementType RHS) { LHS.Append(1, RHS); return LHS; }
|
||||
NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, const ElementType* RHS) { LHS.Append( RHS); return LHS; }
|
||||
NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, TStringView<ElementType> RHS) { LHS.Append( RHS); return LHS; }
|
||||
NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, const TString<ElementType>& RHS) { LHS.Append( RHS); return LHS; }
|
||||
NODISCARD friend FORCEINLINE TString operator+( ElementType LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; }
|
||||
NODISCARD friend FORCEINLINE TString operator+( const ElementType* LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; }
|
||||
NODISCARD friend FORCEINLINE TString operator+( TStringView<ElementType> LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; }
|
||||
NODISCARD friend FORCEINLINE TString operator+(const TString<ElementType>& LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; }
|
||||
NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, FElementType RHS) { LHS.Append(1, RHS); return LHS; }
|
||||
NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, const FElementType* RHS) { LHS.Append( RHS); return LHS; }
|
||||
NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, TStringView<FElementType> RHS) { LHS.Append( RHS); return LHS; }
|
||||
NODISCARD friend FORCEINLINE TString operator+(TString&& LHS, const TString<FElementType>& RHS) { LHS.Append( RHS); return LHS; }
|
||||
NODISCARD friend FORCEINLINE TString operator+( FElementType LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; }
|
||||
NODISCARD friend FORCEINLINE TString operator+( const FElementType* LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; }
|
||||
NODISCARD friend FORCEINLINE TString operator+( TStringView<FElementType> LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; }
|
||||
NODISCARD friend FORCEINLINE TString operator+(const TString<FElementType>& LHS, TString&& RHS) { RHS.Insert(0, LHS); return RHS; }
|
||||
|
||||
public:
|
||||
|
||||
@ -330,7 +330,7 @@ public:
|
||||
/** Removes whitespace characters from the start of this string. */
|
||||
FORCEINLINE constexpr TString& TrimStart(bool bAllowShrinking = true)
|
||||
{
|
||||
auto Index = Find([](ElementType Char) { return !TChar<ElementType>::IsSpace(Char); });
|
||||
auto Index = Find([](FElementType Char) { return !TChar<FElementType>::IsSpace(Char); });
|
||||
|
||||
if (Index != INDEX_NONE)
|
||||
{
|
||||
@ -344,7 +344,7 @@ public:
|
||||
/** Removes whitespace characters from the end of this string. */
|
||||
FORCEINLINE constexpr TString& TrimEnd(bool bAllowShrinking = true)
|
||||
{
|
||||
auto Index = RFind([](ElementType Char) { return !TChar<ElementType>::IsSpace(Char); });
|
||||
auto Index = RFind([](FElementType Char) { return !TChar<FElementType>::IsSpace(Char); });
|
||||
|
||||
if (Index != INDEX_NONE)
|
||||
{
|
||||
@ -367,7 +367,7 @@ public:
|
||||
/** Removes characters after the first null-terminator. */
|
||||
FORCEINLINE constexpr TString& TrimToNullTerminator(bool bAllowShrinking = true)
|
||||
{
|
||||
auto Index = Find(LITERAL(ElementType, '\0'));
|
||||
auto Index = Find(LITERAL(FElementType, '\0'));
|
||||
|
||||
if (Index != INDEX_NONE)
|
||||
{
|
||||
@ -380,50 +380,50 @@ public:
|
||||
public:
|
||||
|
||||
/** @return true if the string view starts with the given prefix, false otherwise. */
|
||||
NODISCARD FORCEINLINE bool StartsWith(TStringView<ElementType> Prefix) const
|
||||
NODISCARD FORCEINLINE bool StartsWith(TStringView<FElementType> Prefix) const
|
||||
{
|
||||
return TStringView<ElementType>(*this).StartsWith(Prefix);
|
||||
return TStringView<FElementType>(*this).StartsWith(Prefix);
|
||||
}
|
||||
|
||||
/** @return true if the string view starts with the given prefix, false otherwise. */
|
||||
NODISCARD FORCEINLINE bool StartsWith(ElementType Prefix) const
|
||||
NODISCARD FORCEINLINE bool StartsWith(FElementType Prefix) const
|
||||
{
|
||||
return TStringView<ElementType>(*this).StartsWith(Prefix);
|
||||
return TStringView<FElementType>(*this).StartsWith(Prefix);
|
||||
}
|
||||
|
||||
/** @return true if the string view ends with the given suffix, false otherwise. */
|
||||
NODISCARD FORCEINLINE bool EndsWith(TStringView<ElementType> Suffix) const
|
||||
NODISCARD FORCEINLINE bool EndsWith(TStringView<FElementType> Suffix) const
|
||||
{
|
||||
return TStringView<ElementType>(*this).EndsWith(Suffix);
|
||||
return TStringView<FElementType>(*this).EndsWith(Suffix);
|
||||
}
|
||||
|
||||
/** @return true if the string view ends with the given suffix, false otherwise. */
|
||||
NODISCARD FORCEINLINE bool EndsWith(ElementType Suffix) const
|
||||
NODISCARD FORCEINLINE bool EndsWith(FElementType Suffix) const
|
||||
{
|
||||
return TStringView<ElementType>(*this).EndsWith(Suffix);
|
||||
return TStringView<FElementType>(*this).EndsWith(Suffix);
|
||||
}
|
||||
|
||||
/** @return true if the string view contains the given substring, false otherwise. */
|
||||
NODISCARD FORCEINLINE bool Contains(TStringView<ElementType> View) const
|
||||
NODISCARD FORCEINLINE bool Contains(TStringView<FElementType> View) const
|
||||
{
|
||||
return TStringView<ElementType>(*this).Contains(View);
|
||||
return TStringView<FElementType>(*this).Contains(View);
|
||||
}
|
||||
|
||||
/** @return true if the string view contains the given character, false otherwise. */
|
||||
NODISCARD FORCEINLINE bool Contains(ElementType Char) const
|
||||
NODISCARD FORCEINLINE bool Contains(FElementType Char) const
|
||||
{
|
||||
return TStringView<ElementType>(*this).Contains(Char);
|
||||
return TStringView<FElementType>(*this).Contains(Char);
|
||||
}
|
||||
|
||||
/** @return true if the string view contains character that satisfy the given predicate, false otherwise. */
|
||||
template <CPredicate<ElementType> F>
|
||||
template <CPredicate<FElementType> F>
|
||||
NODISCARD FORCEINLINE bool Contains(F&& InPredicate) const
|
||||
{
|
||||
return TStringView<ElementType>(*this).Contains(Forward<F>(InPredicate));
|
||||
return TStringView<FElementType>(*this).Contains(Forward<F>(InPredicate));
|
||||
}
|
||||
|
||||
/** Replace the substring [Index, Index + CountToReplace) with 'Count' copies of the 'InChar'. */
|
||||
FORCEINLINE TString& Replace(size_t Index, size_t CountToReplace, size_t Count, ElementType InChar)
|
||||
FORCEINLINE TString& Replace(size_t Index, size_t CountToReplace, size_t Count, FElementType InChar)
|
||||
{
|
||||
checkf(Index <= this->Num() && Index + CountToReplace <= this->Num(), TEXT("Illegal substring range. Please check Index and CountToReplace."));
|
||||
|
||||
@ -431,7 +431,7 @@ public:
|
||||
}
|
||||
|
||||
/** Replace the substring ['First', 'Last') with 'Count' copies of the 'InChar'. */
|
||||
FORCEINLINE TString& Replace(ConstIterator First, ConstIterator Last, size_t Count, ElementType InChar)
|
||||
FORCEINLINE TString& Replace(FConstIterator First, FConstIterator Last, size_t Count, FElementType InChar)
|
||||
{
|
||||
checkf(this->IsValidIterator(First) && this->IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
@ -439,7 +439,7 @@ public:
|
||||
}
|
||||
|
||||
/** Replace the substring [Index, Index + CountToReplace) with the contents of the 'View'. */
|
||||
FORCEINLINE TString& Replace(size_t Index, size_t CountToReplace, TStringView<ElementType> View)
|
||||
FORCEINLINE TString& Replace(size_t Index, size_t CountToReplace, TStringView<FElementType> View)
|
||||
{
|
||||
checkf(Index <= this->Num() && Index + CountToReplace <= this->Num(), TEXT("Illegal substring range. Please check Index and CountToReplace."));
|
||||
|
||||
@ -447,7 +447,7 @@ public:
|
||||
}
|
||||
|
||||
/** Replace the substring ['First', 'Last') with the contents of the 'View'. */
|
||||
FORCEINLINE TString& Replace(ConstIterator First, ConstIterator Last, TStringView<ElementType> View)
|
||||
FORCEINLINE TString& Replace(FConstIterator First, FConstIterator Last, TStringView<FElementType> View)
|
||||
{
|
||||
checkf(this->IsValidIterator(First) && this->IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
@ -455,7 +455,7 @@ public:
|
||||
}
|
||||
|
||||
/** Replace the substring [Index, Index + CountToReplace) with the contents of the range ['First', 'Last'). */
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<ElementType, TIteratorReferenceType<I>>)
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<FElementType, TIteratorReferenceType<I>>)
|
||||
FORCEINLINE TString& Replace(size_t Index, size_t CountToReplace, I InString, S Sentinel)
|
||||
{
|
||||
checkf(Index <= this->Num() && Index + CountToReplace <= this->Num(), TEXT("Illegal substring range. Please check Index and CountToReplace."));
|
||||
@ -464,8 +464,8 @@ public:
|
||||
}
|
||||
|
||||
/** Replace the substring ['First', 'Last') with the contents of the range ['InString', 'Sentinel'). */
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<ElementType, TIteratorReferenceType<I>>)
|
||||
TString& Replace(ConstIterator First, ConstIterator Last, I InString, S Sentinel)
|
||||
template <CInputIterator I, CSentinelFor<I> S> requires (CConstructibleFrom<FElementType, TIteratorReferenceType<I>>)
|
||||
TString& Replace(FConstIterator First, FConstIterator Last, I InString, S Sentinel)
|
||||
{
|
||||
checkf(this->IsValidIterator(First) && this->IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
@ -484,7 +484,7 @@ public:
|
||||
{
|
||||
for (size_t Index = InsertIndex; Index != InsertIndex + InsertCount; ++Index)
|
||||
{
|
||||
(*this)[Index] = ElementType(*InString++);
|
||||
(*this)[Index] = FElementType(*InString++);
|
||||
}
|
||||
|
||||
for (size_t Index = InsertIndex + InsertCount; Index != NumToReset; ++Index)
|
||||
@ -505,7 +505,7 @@ public:
|
||||
|
||||
for (size_t Index = InsertIndex; Index != InsertIndex + InsertCount; ++Index)
|
||||
{
|
||||
(*this)[Index] = ElementType(*InString++);
|
||||
(*this)[Index] = FElementType(*InString++);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -520,7 +520,7 @@ public:
|
||||
}
|
||||
|
||||
/** Replace the substring [Index, Index + CountToReplace) with the contents of the initializer list. */
|
||||
FORCEINLINE TString& Replace(size_t Index, size_t CountToReplace, initializer_list<ElementType> IL)
|
||||
FORCEINLINE TString& Replace(size_t Index, size_t CountToReplace, initializer_list<FElementType> IL)
|
||||
{
|
||||
checkf(Index <= this->Num() && Index + CountToReplace <= this->Num(), TEXT("Illegal substring range. Please check Index and CountToReplace."));
|
||||
|
||||
@ -528,7 +528,7 @@ public:
|
||||
}
|
||||
|
||||
/** Replace the substring ['First', 'Last') with the contents of the initializer list. */
|
||||
FORCEINLINE TString& Replace(ConstIterator First, ConstIterator Last, initializer_list<ElementType> IL)
|
||||
FORCEINLINE TString& Replace(FConstIterator First, FConstIterator Last, initializer_list<FElementType> IL)
|
||||
{
|
||||
checkf(this->IsValidIterator(First) && this->IsValidIterator(Last) && First <= Last, TEXT("Read access violation. Please check IsValidIterator()."));
|
||||
|
||||
@ -540,133 +540,133 @@ public:
|
||||
{
|
||||
checkf(Offset <= this->Num() && Offset + Count <= this->Num(), TEXT("Illegal substring range. Please check Offset and Count."));
|
||||
|
||||
return TStringView<ElementType>(*this).Substr(Offset, Count);
|
||||
return TStringView<FElementType>(*this).Substr(Offset, Count);
|
||||
}
|
||||
|
||||
/** Copies the characters of this string to the destination buffer without null-termination. */
|
||||
FORCEINLINE size_t Copy(ElementType* Dest, size_t Count = DynamicExtent, size_t Offset = 0) const
|
||||
FORCEINLINE size_t Copy(FElementType* Dest, size_t Count = DynamicExtent, size_t Offset = 0) const
|
||||
{
|
||||
checkf(Dest != nullptr, TEXT("Illegal destination buffer. Please check the pointer."));
|
||||
|
||||
checkf(Offset <= this->Num() && (Count == DynamicExtent || Offset + Count <= this->Num()), TEXT("Illegal subview range. Please check Offset and Count."));
|
||||
|
||||
return TStringView<ElementType>(*this).Copy(Dest, Count, Offset);
|
||||
return TStringView<FElementType>(*this).Copy(Dest, Count, Offset);
|
||||
}
|
||||
|
||||
FORCEINLINE size_t Copy(nullptr_t, size_t = DynamicExtent, size_t = 0) const = delete;
|
||||
|
||||
/** @return The index of the first occurrence of the given substring, or INDEX_NONE if not found. */
|
||||
NODISCARD size_t Find(TStringView<ElementType> View, size_t Index = 0) const
|
||||
NODISCARD size_t Find(TStringView<FElementType> View, size_t Index = 0) const
|
||||
{
|
||||
checkf(Index < this->Num(), TEXT("Illegal index. Please check Index."));
|
||||
|
||||
return TStringView<ElementType>(*this).Find(View, Index);
|
||||
return TStringView<FElementType>(*this).Find(View, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the first occurrence of the given character, or INDEX_NONE if not found. */
|
||||
NODISCARD size_t Find(ElementType Char, size_t Index = 0) const
|
||||
NODISCARD size_t Find(FElementType Char, size_t Index = 0) const
|
||||
{
|
||||
checkf(Index < this->Num(), TEXT("Illegal index. Please check Index."));
|
||||
|
||||
return TStringView<ElementType>(*this).Find(Char, Index);
|
||||
return TStringView<FElementType>(*this).Find(Char, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the first occurrence of the character that satisfy the given predicate, or INDEX_NONE if not found. */
|
||||
template <CPredicate<ElementType> F>
|
||||
template <CPredicate<FElementType> F>
|
||||
NODISCARD size_t Find(F&& InPredicate, size_t Index = 0) const
|
||||
{
|
||||
checkf(Index < this->Num(), TEXT("Illegal index. Please check Index."));
|
||||
|
||||
return TStringView<ElementType>(*this).Find(Forward<F>(InPredicate), Index);
|
||||
return TStringView<FElementType>(*this).Find(Forward<F>(InPredicate), Index);
|
||||
}
|
||||
|
||||
/** @return The index of the last occurrence of the given substring, or INDEX_NONE if not found. */
|
||||
NODISCARD size_t RFind(TStringView<ElementType> View, size_t Index = INDEX_NONE) const
|
||||
NODISCARD size_t RFind(TStringView<FElementType> View, size_t Index = INDEX_NONE) const
|
||||
{
|
||||
checkf(Index == INDEX_NONE || Index < this->Num(), TEXT("Illegal index. Please check Index."));
|
||||
|
||||
return TStringView<ElementType>(*this).RFind(View, Index);
|
||||
return TStringView<FElementType>(*this).RFind(View, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the last occurrence of the given character, or INDEX_NONE if not found. */
|
||||
NODISCARD size_t RFind(ElementType Char, size_t Index = INDEX_NONE) const
|
||||
NODISCARD size_t RFind(FElementType Char, size_t Index = INDEX_NONE) const
|
||||
{
|
||||
checkf(Index == INDEX_NONE || Index < this->Num(), TEXT("Illegal index. Please check Index."));
|
||||
|
||||
return TStringView<ElementType>(*this).RFind(Char, Index);
|
||||
return TStringView<FElementType>(*this).RFind(Char, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the last occurrence of the character that satisfy the given predicate, or INDEX_NONE if not found. */
|
||||
template <CPredicate<ElementType> F>
|
||||
template <CPredicate<FElementType> F>
|
||||
NODISCARD size_t RFind(F&& InPredicate, size_t Index = INDEX_NONE) const
|
||||
{
|
||||
checkf(Index == INDEX_NONE || Index < this->Num(), TEXT("Illegal index. Please check Index."));
|
||||
|
||||
return TStringView<ElementType>(*this).RFind(Forward<F>(InPredicate), Index);
|
||||
return TStringView<FElementType>(*this).RFind(Forward<F>(InPredicate), Index);
|
||||
}
|
||||
|
||||
/** @return The index of the first occurrence of the character contained in the given view, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE size_t FindFirstOf(TStringView<ElementType> View, size_t Index = 0) const
|
||||
NODISCARD FORCEINLINE size_t FindFirstOf(TStringView<FElementType> View, size_t Index = 0) const
|
||||
{
|
||||
checkf(Index < this->Num(), TEXT("Illegal index. Please check Index."));
|
||||
|
||||
return TStringView<ElementType>(*this).FindFirstOf(View, Index);
|
||||
return TStringView<FElementType>(*this).FindFirstOf(View, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the first occurrence of the given character, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE size_t FindFirstOf(ElementType Char, size_t Index = 0) const
|
||||
NODISCARD FORCEINLINE size_t FindFirstOf(FElementType Char, size_t Index = 0) const
|
||||
{
|
||||
checkf(Index < this->Num(), TEXT("Illegal index. Please check Index."));
|
||||
|
||||
return TStringView<ElementType>(*this).FindFirstOf(Char, Index);
|
||||
return TStringView<FElementType>(*this).FindFirstOf(Char, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the last occurrence of the character contained in the given view, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE size_t FindLastOf(TStringView<ElementType> View, size_t Index = INDEX_NONE) const
|
||||
NODISCARD FORCEINLINE size_t FindLastOf(TStringView<FElementType> View, size_t Index = INDEX_NONE) const
|
||||
{
|
||||
checkf(Index == INDEX_NONE || Index < this->Num(), TEXT("Illegal index. Please check Index."));
|
||||
|
||||
return TStringView<ElementType>(*this).FindLastOf(View, Index);
|
||||
return TStringView<FElementType>(*this).FindLastOf(View, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the last occurrence of the given character, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE size_t FindLastOf(ElementType Char, size_t Index = INDEX_NONE) const
|
||||
NODISCARD FORCEINLINE size_t FindLastOf(FElementType Char, size_t Index = INDEX_NONE) const
|
||||
{
|
||||
checkf(Index == INDEX_NONE || Index < this->Num(), TEXT("Illegal index. Please check Index."));
|
||||
|
||||
return TStringView<ElementType>(*this).FindLastOf(Char, Index);
|
||||
return TStringView<FElementType>(*this).FindLastOf(Char, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the first absence of the character contained in the given view, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE size_t FindFirstNotOf(TStringView<ElementType> View, size_t Index = 0) const
|
||||
NODISCARD FORCEINLINE size_t FindFirstNotOf(TStringView<FElementType> View, size_t Index = 0) const
|
||||
{
|
||||
checkf(Index < this->Num(), TEXT("Illegal index. Please check Index."));
|
||||
|
||||
return TStringView<ElementType>(*this).FindFirstNotOf(View, Index);
|
||||
return TStringView<FElementType>(*this).FindFirstNotOf(View, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the first absence of the given character, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE size_t FindFirstNotOf(ElementType Char, size_t Index = 0) const
|
||||
NODISCARD FORCEINLINE size_t FindFirstNotOf(FElementType Char, size_t Index = 0) const
|
||||
{
|
||||
checkf(Index < this->Num(), TEXT("Illegal index. Please check Index."));
|
||||
|
||||
return TStringView<ElementType>(*this).FindFirstNotOf(Char, Index);
|
||||
return TStringView<FElementType>(*this).FindFirstNotOf(Char, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the last absence of the character contained in the given view, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE size_t FindLastNotOf(TStringView<ElementType> View, size_t Index = INDEX_NONE) const
|
||||
NODISCARD FORCEINLINE size_t FindLastNotOf(TStringView<FElementType> View, size_t Index = INDEX_NONE) const
|
||||
{
|
||||
checkf(Index == INDEX_NONE || Index < this->Num(), TEXT("Illegal index. Please check Index."));
|
||||
|
||||
return TStringView<ElementType>(*this).FindLastNotOf(View, Index);
|
||||
return TStringView<FElementType>(*this).FindLastNotOf(View, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the last absence of the given character, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE size_t FindLastNotOf(ElementType Char, size_t Index = INDEX_NONE) const
|
||||
NODISCARD FORCEINLINE size_t FindLastNotOf(FElementType Char, size_t Index = INDEX_NONE) const
|
||||
{
|
||||
checkf(Index == INDEX_NONE || Index < this->Num(), TEXT("Illegal index. Please check Index."));
|
||||
|
||||
return TStringView<ElementType>(*this).FindLastNotOf(Char, Index);
|
||||
return TStringView<FElementType>(*this).FindLastNotOf(Char, Index);
|
||||
}
|
||||
|
||||
public:
|
||||
@ -1028,7 +1028,7 @@ public:
|
||||
{
|
||||
if (this->Max() >= this->Num() + 1)
|
||||
{
|
||||
const_cast<ElementType*>(this->GetData())[this->Num()] = LITERAL(ElementType, '\0');
|
||||
const_cast<FElementType*>(this->GetData())[this->Num()] = LITERAL(FElementType, '\0');
|
||||
|
||||
return *TStringView(this->GetData(), this->Num() + 1);
|
||||
}
|
||||
@ -1052,31 +1052,31 @@ public:
|
||||
/** @return true if the string only contains valid characters, false otherwise. */
|
||||
NODISCARD FORCEINLINE bool IsValid() const
|
||||
{
|
||||
return TStringView<ElementType>(*this).IsValid();
|
||||
return TStringView<FElementType>(*this).IsValid();
|
||||
}
|
||||
|
||||
/** @return true if the string only contains ASCII characters, false otherwise. */
|
||||
NODISCARD FORCEINLINE bool IsASCII() const
|
||||
{
|
||||
return TStringView<ElementType>(*this).IsASCII();
|
||||
return TStringView<FElementType>(*this).IsASCII();
|
||||
}
|
||||
|
||||
/** @return true if the string can be fully represented as a boolean value, false otherwise. */
|
||||
NODISCARD FORCEINLINE bool IsBoolean() const
|
||||
{
|
||||
return TStringView<ElementType>(*this).IsBoolean();
|
||||
return TStringView<FElementType>(*this).IsBoolean();
|
||||
}
|
||||
|
||||
/** @return true if the string can be fully represented as an integer value, false otherwise. */
|
||||
NODISCARD FORCEINLINE bool IsInteger(unsigned Base = 10, bool bSigned = true) const
|
||||
{
|
||||
return TStringView<ElementType>(*this).IsInteger(Base, bSigned);
|
||||
return TStringView<FElementType>(*this).IsInteger(Base, bSigned);
|
||||
}
|
||||
|
||||
/** @return true if the string can be fully represented as a floating-point value, false otherwise. */
|
||||
NODISCARD FORCEINLINE bool IsFloatingPoint(bool bFixed = true, bool bScientific = true, bool bSigned = true) const
|
||||
{
|
||||
return TStringView<ElementType>(*this).IsFloatingPoint(bFixed, bScientific, bSigned);
|
||||
return TStringView<FElementType>(*this).IsFloatingPoint(bFixed, bScientific, bSigned);
|
||||
}
|
||||
|
||||
public:
|
||||
@ -1202,7 +1202,7 @@ public:
|
||||
*/
|
||||
NODISCARD FORCEINLINE bool ToBool() const
|
||||
{
|
||||
return TStringView<ElementType>(*this).ToBool();
|
||||
return TStringView<FElementType>(*this).ToBool();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1223,7 +1223,7 @@ public:
|
||||
{
|
||||
checkf(Base >= 2 && Base <= 36, TEXT("Illegal base. Please check the base."));
|
||||
|
||||
return TStringView<ElementType>(*this).template ToInt<U>(Base);
|
||||
return TStringView<FElementType>(*this).template ToInt<U>(Base);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1244,13 +1244,13 @@ public:
|
||||
template <CFloatingPoint U = float> requires (!CConst<U> && !CVolatile<U>)
|
||||
NODISCARD FORCEINLINE U ToFloat(bool bFixed = true, bool bScientific = false) const
|
||||
{
|
||||
return TStringView<ElementType>(*this).template ToFloat<U>(bFixed, bScientific);
|
||||
return TStringView<FElementType>(*this).template ToFloat<U>(bFixed, bScientific);
|
||||
}
|
||||
|
||||
/** Converts a string into a boolean value and remove the parsed substring. */
|
||||
NODISCARD FORCEINLINE bool ToBoolAndTrim()
|
||||
{
|
||||
TStringView<ElementType> View = *this;
|
||||
TStringView<FElementType> View = *this;
|
||||
|
||||
bool Result = View.ToBoolAndTrim();
|
||||
|
||||
@ -1265,7 +1265,7 @@ public:
|
||||
template <CIntegral U = int> requires (!CSameAs<U, bool> && !CConst<U> && !CVolatile<U>)
|
||||
NODISCARD FORCEINLINE U ToIntAndTrim(unsigned Base = 10)
|
||||
{
|
||||
TStringView<ElementType> View = *this;
|
||||
TStringView<FElementType> View = *this;
|
||||
|
||||
U Result = View.template ToIntAndTrim<U>(Base);
|
||||
|
||||
@ -1280,7 +1280,7 @@ public:
|
||||
template <CFloatingPoint U = float> requires (!CConst<U> && !CVolatile<U>)
|
||||
NODISCARD FORCEINLINE U ToFloatAndTrim(bool bFixed = true, bool bScientific = true)
|
||||
{
|
||||
TStringView<ElementType> View = *this;
|
||||
TStringView<FElementType> View = *this;
|
||||
|
||||
U Result = View.template ToFloatAndTrim<U>(bFixed, bScientific);
|
||||
|
||||
@ -1302,7 +1302,7 @@ public:
|
||||
* @return The formatted string containing the objects.
|
||||
*/
|
||||
template <typename... Ts>
|
||||
NODISCARD static FORCEINLINE TString Format(TStringView<ElementType> Fmt, const Ts&... Args)
|
||||
NODISCARD static FORCEINLINE TString Format(TStringView<FElementType> Fmt, const Ts&... Args)
|
||||
{
|
||||
TString Result;
|
||||
|
||||
@ -1313,7 +1313,7 @@ public:
|
||||
|
||||
/** Format some objects using a format string and append to the string. */
|
||||
template <typename... Ts>
|
||||
void AppendFormat(TStringView<ElementType> Fmt, const Ts&... Args);
|
||||
void AppendFormat(TStringView<FElementType> Fmt, const Ts&... Args);
|
||||
|
||||
/**
|
||||
* Parse a string using a format string to objects.
|
||||
@ -1324,16 +1324,16 @@ public:
|
||||
* @return The number of objects successfully parsed.
|
||||
*/
|
||||
template <typename... Ts>
|
||||
FORCEINLINE size_t Parse(TStringView<ElementType> Fmt, Ts&... Args) const
|
||||
FORCEINLINE size_t Parse(TStringView<FElementType> Fmt, Ts&... Args) const
|
||||
{
|
||||
return TStringView(*this).Parse(Fmt, Args...);
|
||||
}
|
||||
|
||||
/** Parse a string using a format string to objects and remove the parsed substring. */
|
||||
template <typename... Ts>
|
||||
FORCEINLINE size_t ParseAndTrim(TStringView<ElementType> Fmt, Ts&... Args)
|
||||
FORCEINLINE size_t ParseAndTrim(TStringView<FElementType> Fmt, Ts&... Args)
|
||||
{
|
||||
TStringView<ElementType> View = *this;
|
||||
TStringView<FElementType> View = *this;
|
||||
|
||||
size_t Result = View.ParseAndTrim(Fmt, Args...);
|
||||
|
||||
@ -1347,10 +1347,10 @@ public:
|
||||
public:
|
||||
|
||||
/** Overloads the GetTypeHash algorithm for TString. */
|
||||
NODISCARD friend FORCEINLINE size_t GetTypeHash(const TString& A) { return GetTypeHash(TStringView<ElementType>(A)); }
|
||||
NODISCARD friend FORCEINLINE size_t GetTypeHash(const TString& A) { return GetTypeHash(TStringView<FElementType>(A)); }
|
||||
|
||||
/** Overloads the Swap algorithm for TString. */
|
||||
friend FORCEINLINE void Swap(TString& A, TString& B) { Swap(static_cast<Super&>(A), static_cast<Super&>(B)); }
|
||||
friend FORCEINLINE void Swap(TString& A, TString& B) { Swap(static_cast<FSuper&>(A), static_cast<FSuper&>(B)); }
|
||||
|
||||
};
|
||||
|
||||
@ -1373,7 +1373,7 @@ using FU16String = TString<u16char>;
|
||||
using FU32String = TString<u32char>;
|
||||
using FUnicodeString = TString<unicodechar>;
|
||||
|
||||
template <CCharType T> template <typename Allocator> constexpr TStringView<T>::TStringView(const TString<ElementType, Allocator>& InString)
|
||||
template <CCharType T> template <typename Allocator> constexpr TStringView<T>::TStringView(const TString<FElementType, Allocator>& InString)
|
||||
: TStringView(InString.GetData(), InString.Num()) { }
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
|
@ -82,36 +82,36 @@ class TStringView : public TArrayView<const T>
|
||||
{
|
||||
private:
|
||||
|
||||
using Super = TArrayView<const T>;
|
||||
using FSuper = TArrayView<const T>;
|
||||
|
||||
public:
|
||||
|
||||
using ElementType = T;
|
||||
using FElementType = T;
|
||||
|
||||
using Reference = typename Super::Reference;
|
||||
using FReference = typename FSuper::FReference;
|
||||
|
||||
using Iterator = typename Super::Iterator;
|
||||
using ReverseIterator = typename Super::ReverseIterator;
|
||||
using FIterator = typename FSuper:: FIterator;
|
||||
using FReverseIterator = typename FSuper::FReverseIterator;
|
||||
|
||||
static_assert(CContiguousIterator<Iterator>);
|
||||
static_assert(CContiguousIterator<FIterator>);
|
||||
|
||||
/** Constructs an empty string view. */
|
||||
FORCEINLINE constexpr TStringView() = default;
|
||||
|
||||
/** Constructs a string view that is a view over the range ['InFirst', 'InFirst' + 'Count'). */
|
||||
template <CContiguousIterator I> requires (CConvertibleTo<TIteratorElementType<I>(*)[], const ElementType(*)[]>)
|
||||
FORCEINLINE constexpr TStringView(I InFirst, size_t InCount) : Super(InFirst, InCount) { }
|
||||
template <CContiguousIterator I> requires (CConvertibleTo<TIteratorElementType<I>(*)[], const FElementType(*)[]>)
|
||||
FORCEINLINE constexpr TStringView(I InFirst, size_t InCount) : FSuper(InFirst, InCount) { }
|
||||
|
||||
/** Constructs a string view that is a view over the range ['InFirst', 'InLast'). */
|
||||
template <CContiguousIterator I, CSizedSentinelFor<I> S> requires (CConvertibleTo<TIteratorElementType<I>(*)[], const ElementType(*)[]>)
|
||||
FORCEINLINE constexpr TStringView(I InFirst, S InLast) : Super(InFirst, InLast) { }
|
||||
template <CContiguousIterator I, CSizedSentinelFor<I> S> requires (CConvertibleTo<TIteratorElementType<I>(*)[], const FElementType(*)[]>)
|
||||
FORCEINLINE constexpr TStringView(I InFirst, S InLast) : FSuper(InFirst, InLast) { }
|
||||
|
||||
/** Constructs a string view that is a view over the string 'InString'. */
|
||||
template <typename Allocator>
|
||||
FORCEINLINE constexpr TStringView(const TString<ElementType, Allocator>& InString);
|
||||
FORCEINLINE constexpr TStringView(const TString<FElementType, Allocator>& InString);
|
||||
|
||||
/** Constructs a string view that is a view over the range ['InPtr', 'InPtr' + 'Count'). */
|
||||
FORCEINLINE constexpr TStringView(const ElementType* InPtr, size_t Count) : Super(InPtr, Count)
|
||||
FORCEINLINE constexpr TStringView(const FElementType* InPtr, size_t Count) : FSuper(InPtr, Count)
|
||||
{
|
||||
checkf(InPtr != nullptr, TEXT("TStringView cannot be initialized by nullptr. Please check the pointer."));
|
||||
}
|
||||
@ -119,23 +119,23 @@ public:
|
||||
FORCEINLINE constexpr TStringView(nullptr_t, size_t) = delete;
|
||||
|
||||
/** Constructs a string view that is a view over the range ['InPtr', '\0'). */
|
||||
FORCEINLINE constexpr TStringView(const ElementType* InPtr)
|
||||
FORCEINLINE constexpr TStringView(const FElementType* InPtr)
|
||||
{
|
||||
checkf(InPtr != nullptr, TEXT("TStringView cannot be initialized by nullptr. Please check the pointer."));
|
||||
|
||||
size_t Length = 0;
|
||||
|
||||
if constexpr (CSameAs<ElementType, char>)
|
||||
if constexpr (CSameAs<FElementType, char>)
|
||||
{
|
||||
Length = NAMESPACE_STD::strlen(InPtr);
|
||||
}
|
||||
else if constexpr (CSameAs<ElementType, wchar>)
|
||||
else if constexpr (CSameAs<FElementType, wchar>)
|
||||
{
|
||||
Length = NAMESPACE_STD::wcslen(InPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (InPtr[Length] != LITERAL(ElementType, '\0')) ++Length;
|
||||
while (InPtr[Length] != LITERAL(FElementType, '\0')) ++Length;
|
||||
}
|
||||
|
||||
*this = TStringView(InPtr, Length);
|
||||
@ -150,18 +150,18 @@ public:
|
||||
FORCEINLINE constexpr TStringView& operator=(const TStringView&) noexcept = default;
|
||||
|
||||
/** Compares the contents of two string views. */
|
||||
NODISCARD friend constexpr bool operator==(TStringView LHS, TStringView RHS) { return static_cast<Super>(LHS) == static_cast<Super>(RHS); }
|
||||
NODISCARD friend constexpr bool operator==(TStringView LHS, TStringView RHS) { return static_cast<FSuper>(LHS) == static_cast<FSuper>(RHS); }
|
||||
|
||||
/** Compares the contents of a string view and a character. */
|
||||
NODISCARD friend constexpr bool operator==(TStringView LHS, ElementType RHS) { return LHS == TStringView(&RHS, 1); }
|
||||
NODISCARD friend constexpr bool operator==(ElementType LHS, TStringView RHS) { return TStringView(&LHS, 1) == RHS; }
|
||||
NODISCARD friend constexpr bool operator==(TStringView LHS, FElementType RHS) { return LHS == TStringView(&RHS, 1); }
|
||||
NODISCARD friend constexpr bool operator==(FElementType LHS, TStringView RHS) { return TStringView(&LHS, 1) == RHS; }
|
||||
|
||||
/** Compares the contents of two string views. */
|
||||
NODISCARD friend constexpr auto operator<=>(TStringView LHS, TStringView RHS) { return static_cast<Super>(LHS) <=> static_cast<Super>(RHS); }
|
||||
NODISCARD friend constexpr auto operator<=>(TStringView LHS, TStringView RHS) { return static_cast<FSuper>(LHS) <=> static_cast<FSuper>(RHS); }
|
||||
|
||||
/** Compares the contents of a string view and a character. */
|
||||
NODISCARD friend constexpr auto operator<=>(TStringView LHS, ElementType RHS) { return LHS <=> TStringView(&RHS, 1); }
|
||||
NODISCARD friend constexpr auto operator<=>(ElementType LHS, TStringView RHS) { return TStringView(&LHS, 1) <=> RHS; }
|
||||
NODISCARD friend constexpr auto operator<=>(TStringView LHS, FElementType RHS) { return LHS <=> TStringView(&RHS, 1); }
|
||||
NODISCARD friend constexpr auto operator<=>(FElementType LHS, TStringView RHS) { return TStringView(&LHS, 1) <=> RHS; }
|
||||
|
||||
public:
|
||||
|
||||
@ -188,7 +188,7 @@ public:
|
||||
/** Removes whitespace characters from the start of this string. */
|
||||
FORCEINLINE constexpr TStringView& TrimStart()
|
||||
{
|
||||
auto Index = Find([](ElementType Char) { return !TChar<ElementType>::IsSpace(Char); });
|
||||
auto Index = Find([](FElementType Char) { return !TChar<FElementType>::IsSpace(Char); });
|
||||
|
||||
if (Index != INDEX_NONE)
|
||||
{
|
||||
@ -202,7 +202,7 @@ public:
|
||||
/** Removes whitespace characters from the end of this string. */
|
||||
FORCEINLINE constexpr TStringView& TrimEnd()
|
||||
{
|
||||
auto Index = RFind([](ElementType Char) { return !TChar<ElementType>::IsSpace(Char); });
|
||||
auto Index = RFind([](FElementType Char) { return !TChar<FElementType>::IsSpace(Char); });
|
||||
|
||||
if (Index != INDEX_NONE)
|
||||
{
|
||||
@ -225,7 +225,7 @@ public:
|
||||
/** Removes characters after the first null-terminator. */
|
||||
FORCEINLINE constexpr TStringView& TrimToNullTerminator()
|
||||
{
|
||||
auto Index = Find(LITERAL(ElementType, '\0'));
|
||||
auto Index = Find(LITERAL(FElementType, '\0'));
|
||||
|
||||
if (Index != INDEX_NONE)
|
||||
{
|
||||
@ -238,7 +238,7 @@ public:
|
||||
public:
|
||||
|
||||
/** Copies the elements of this string view to the destination buffer without null-termination. */
|
||||
FORCEINLINE constexpr size_t Copy(ElementType* Dest, size_t Count = DynamicExtent, size_t Offset = 0) const
|
||||
FORCEINLINE constexpr size_t Copy(FElementType* Dest, size_t Count = DynamicExtent, size_t Offset = 0) const
|
||||
{
|
||||
checkf(Dest != nullptr, TEXT("Illegal destination buffer. Please check the pointer."));
|
||||
|
||||
@ -277,7 +277,7 @@ public:
|
||||
{
|
||||
checkf(Offset <= this->Num() && (Count == DynamicExtent || Offset + Count <= this->Num()), TEXT("Illegal subview range. Please check Offset and Count."));
|
||||
|
||||
Super Temp = this->Subview(Offset, Count);
|
||||
FSuper Temp = this->Subview(Offset, Count);
|
||||
|
||||
return TStringView(Temp.GetData(), Temp.Num());
|
||||
}
|
||||
@ -289,7 +289,7 @@ public:
|
||||
}
|
||||
|
||||
/** @return true if the string view starts with the given prefix, false otherwise. */
|
||||
NODISCARD FORCEINLINE constexpr bool StartsWith(ElementType Prefix) const
|
||||
NODISCARD FORCEINLINE constexpr bool StartsWith(FElementType Prefix) const
|
||||
{
|
||||
return this->Num() >= 1 && this->Front() == Prefix;
|
||||
}
|
||||
@ -301,7 +301,7 @@ public:
|
||||
}
|
||||
|
||||
/** @return true if the string view ends with the given suffix, false otherwise. */
|
||||
NODISCARD FORCEINLINE constexpr bool EndsWith(ElementType Suffix) const
|
||||
NODISCARD FORCEINLINE constexpr bool EndsWith(FElementType Suffix) const
|
||||
{
|
||||
return this->Num() >= 1 && this->Back() == Suffix;
|
||||
}
|
||||
@ -313,13 +313,13 @@ public:
|
||||
}
|
||||
|
||||
/** @return true if the string view contains the given character, false otherwise. */
|
||||
NODISCARD FORCEINLINE constexpr bool Contains(ElementType Char) const
|
||||
NODISCARD FORCEINLINE constexpr bool Contains(FElementType Char) const
|
||||
{
|
||||
return Find(Char) != INDEX_NONE;
|
||||
}
|
||||
|
||||
/** @return true if the string view contains character that satisfy the given predicate, false otherwise. */
|
||||
template <CPredicate<ElementType> F>
|
||||
template <CPredicate<FElementType> F>
|
||||
NODISCARD FORCEINLINE constexpr bool Contains(F&& InPredicate) const
|
||||
{
|
||||
return Find(Forward<F>(InPredicate)) != INDEX_NONE;
|
||||
@ -346,7 +346,7 @@ public:
|
||||
}
|
||||
|
||||
/** @return The index of the first occurrence of the given character, or INDEX_NONE if not found. */
|
||||
NODISCARD constexpr size_t Find(ElementType Char, size_t Index = 0) const
|
||||
NODISCARD constexpr size_t Find(FElementType Char, size_t Index = 0) const
|
||||
{
|
||||
if (Index >= this->Num()) return INDEX_NONE;
|
||||
|
||||
@ -362,7 +362,7 @@ public:
|
||||
}
|
||||
|
||||
/** @return The index of the first occurrence of the character that satisfy the given predicate, or INDEX_NONE if not found. */
|
||||
template <CPredicate<ElementType> F>
|
||||
template <CPredicate<FElementType> F>
|
||||
NODISCARD constexpr size_t Find(F&& InPredicate, size_t Index = 0) const
|
||||
{
|
||||
if (Index >= this->Num()) return INDEX_NONE;
|
||||
@ -401,7 +401,7 @@ public:
|
||||
}
|
||||
|
||||
/** @return The index of the last occurrence of the given character, or INDEX_NONE if not found. */
|
||||
NODISCARD constexpr size_t RFind(ElementType Char, size_t Index = INDEX_NONE) const
|
||||
NODISCARD constexpr size_t RFind(FElementType Char, size_t Index = INDEX_NONE) const
|
||||
{
|
||||
if (Index != INDEX_NONE && Index >= this->Num()) return INDEX_NONE;
|
||||
|
||||
@ -419,7 +419,7 @@ public:
|
||||
}
|
||||
|
||||
/** @return The index of the last occurrence of the character that satisfy the given predicate, or INDEX_NONE if not found. */
|
||||
template <CPredicate<ElementType> F>
|
||||
template <CPredicate<FElementType> F>
|
||||
NODISCARD constexpr size_t RFind(F&& InPredicate, size_t Index = INDEX_NONE) const
|
||||
{
|
||||
if (Index != INDEX_NONE && Index >= this->Num()) return INDEX_NONE;
|
||||
@ -440,11 +440,11 @@ public:
|
||||
/** @return The index of the first occurrence of the character contained in the given view, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE constexpr size_t FindFirstOf(TStringView View, size_t Index = 0) const
|
||||
{
|
||||
return Find([View](ElementType Char) { return View.Contains(Char); }, Index);
|
||||
return Find([View](FElementType Char) { return View.Contains(Char); }, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the first occurrence of the given character, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE constexpr size_t FindFirstOf(ElementType Char, size_t Index = 0) const
|
||||
NODISCARD FORCEINLINE constexpr size_t FindFirstOf(FElementType Char, size_t Index = 0) const
|
||||
{
|
||||
return Find(Char, Index);
|
||||
}
|
||||
@ -452,11 +452,11 @@ public:
|
||||
/** @return The index of the last occurrence of the character contained in the given view, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE constexpr size_t FindLastOf(TStringView View, size_t Index = INDEX_NONE) const
|
||||
{
|
||||
return RFind([View](ElementType Char) { return View.Contains(Char); }, Index);
|
||||
return RFind([View](FElementType Char) { return View.Contains(Char); }, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the last occurrence of the given character, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE constexpr size_t FindLastOf(ElementType Char, size_t Index = INDEX_NONE) const
|
||||
NODISCARD FORCEINLINE constexpr size_t FindLastOf(FElementType Char, size_t Index = INDEX_NONE) const
|
||||
{
|
||||
return RFind(Char, Index);
|
||||
}
|
||||
@ -464,25 +464,25 @@ public:
|
||||
/** @return The index of the first absence of the character contained in the given view, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE constexpr size_t FindFirstNotOf(TStringView View, size_t Index = 0) const
|
||||
{
|
||||
return Find([View](ElementType Char) { return !View.Contains(Char); }, Index);
|
||||
return Find([View](FElementType Char) { return !View.Contains(Char); }, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the first absence of the given character, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE constexpr size_t FindFirstNotOf(ElementType Char, size_t Index = 0) const
|
||||
NODISCARD FORCEINLINE constexpr size_t FindFirstNotOf(FElementType Char, size_t Index = 0) const
|
||||
{
|
||||
return Find([Char](ElementType C) { return C != Char; }, Index);
|
||||
return Find([Char](FElementType C) { return C != Char; }, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the last absence of the character contained in the given view, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE constexpr size_t FindLastNotOf(TStringView View, size_t Index = INDEX_NONE) const
|
||||
{
|
||||
return RFind([View](ElementType Char) { return !View.Contains(Char); }, Index);
|
||||
return RFind([View](FElementType Char) { return !View.Contains(Char); }, Index);
|
||||
}
|
||||
|
||||
/** @return The index of the last absence of the given character, or INDEX_NONE if not found. */
|
||||
NODISCARD FORCEINLINE constexpr size_t FindLastNotOf(ElementType Char, size_t Index = INDEX_NONE) const
|
||||
NODISCARD FORCEINLINE constexpr size_t FindLastNotOf(FElementType Char, size_t Index = INDEX_NONE) const
|
||||
{
|
||||
return RFind([Char](ElementType C) { return C != Char; }, Index);
|
||||
return RFind([Char](FElementType C) { return C != Char; }, Index);
|
||||
}
|
||||
|
||||
public:
|
||||
@ -490,18 +490,18 @@ public:
|
||||
/** @return The non-modifiable standard C character string version of the string view. */
|
||||
NODISCARD FORCEINLINE auto operator*() const
|
||||
{
|
||||
if (this->Back() == LITERAL(ElementType, '\0') || Contains(LITERAL(ElementType, '\0')))
|
||||
if (this->Back() == LITERAL(FElementType, '\0') || Contains(LITERAL(FElementType, '\0')))
|
||||
{
|
||||
return NAMESPACE_PRIVATE::TCStringFromTStringView<ElementType>(this->GetData(), false);
|
||||
return NAMESPACE_PRIVATE::TCStringFromTStringView<FElementType>(this->GetData(), false);
|
||||
}
|
||||
|
||||
ElementType* Buffer = new ElementType[this->Num() + 1];
|
||||
FElementType* Buffer = new FElementType[this->Num() + 1];
|
||||
|
||||
Copy(Buffer);
|
||||
|
||||
Buffer[this->Num()] = LITERAL(ElementType, '\0');
|
||||
Buffer[this->Num()] = LITERAL(FElementType, '\0');
|
||||
|
||||
return NAMESPACE_PRIVATE::TCStringFromTStringView<ElementType>(Buffer, true);
|
||||
return NAMESPACE_PRIVATE::TCStringFromTStringView<FElementType>(Buffer, true);
|
||||
}
|
||||
|
||||
public:
|
||||
@ -509,9 +509,9 @@ public:
|
||||
/** @return true if the string only contains valid characters, false otherwise. */
|
||||
NODISCARD constexpr bool IsValid() const
|
||||
{
|
||||
for (ElementType Char : *this)
|
||||
for (FElementType Char : *this)
|
||||
{
|
||||
if (!TChar<ElementType>::IsValid(Char)) return false;
|
||||
if (!TChar<FElementType>::IsValid(Char)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -520,9 +520,9 @@ public:
|
||||
/** @return true if the string only contains ASCII characters, false otherwise. */
|
||||
NODISCARD constexpr bool IsASCII() const
|
||||
{
|
||||
for (ElementType Char : *this)
|
||||
for (FElementType Char : *this)
|
||||
{
|
||||
if (!TChar<ElementType>::IsASCII(Char)) return false;
|
||||
if (!TChar<FElementType>::IsASCII(Char)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -543,7 +543,7 @@ public:
|
||||
{
|
||||
TStringView View = *this;
|
||||
|
||||
if (View.StartsWith(LITERAL(ElementType, '-')))
|
||||
if (View.StartsWith(LITERAL(FElementType, '-')))
|
||||
{
|
||||
if (bSigned) View.RemovePrefix(1);
|
||||
else return false;
|
||||
@ -559,7 +559,7 @@ public:
|
||||
{
|
||||
TStringView View = *this;
|
||||
|
||||
if (View.StartsWith(LITERAL(ElementType, '-')))
|
||||
if (View.StartsWith(LITERAL(FElementType, '-')))
|
||||
{
|
||||
if (bSigned) View.RemovePrefix(1);
|
||||
else return false;
|
||||
@ -659,7 +659,7 @@ public:
|
||||
public:
|
||||
|
||||
/** Overloads the GetTypeHash algorithm for TStringView. */
|
||||
NODISCARD friend FORCEINLINE constexpr size_t GetTypeHash(TStringView A) { return GetTypeHash(static_cast<Super>(A)); }
|
||||
NODISCARD friend FORCEINLINE constexpr size_t GetTypeHash(TStringView A) { return GetTypeHash(static_cast<FSuper>(A)); }
|
||||
|
||||
};
|
||||
|
||||
@ -676,6 +676,8 @@ using FU16StringView = TStringView<u16char>;
|
||||
using FU32StringView = TStringView<u32char>;
|
||||
using FUnicodeStringView = TStringView<unicodechar>;
|
||||
|
||||
// ReSharper disable CppInconsistentNaming
|
||||
|
||||
#define TEXT_VIEW(X) TStringView(TEXT(X))
|
||||
#define WTEXT_VIEW(X) TStringView(WTEXT(X))
|
||||
#define U8TEXT_VIEW(X) TStringView(U8TEXT(X))
|
||||
@ -685,6 +687,8 @@ using FUnicodeStringView = TStringView<unicodechar>;
|
||||
|
||||
#define LITERAL_VIEW(T, X) TStringView(LITERAL(T, X))
|
||||
|
||||
// ReSharper restore CppInconsistentNaming
|
||||
|
||||
NAMESPACE_MODULE_END(Utility)
|
||||
NAMESPACE_MODULE_END(Redcraft)
|
||||
NAMESPACE_REDCRAFT_END
|
||||
|
Reference in New Issue
Block a user