Refactor GetNonTerminatedText into GetText in StringView
This commit is contained in:
@@ -62,12 +62,12 @@ StringAnsi StringView::ToStringAnsi() const
|
||||
|
||||
bool operator==(const String& a, const StringView& b)
|
||||
{
|
||||
return a.Length() == b.Length() && StringUtils::Compare(a.GetText(), b.GetNonTerminatedText(), b.Length()) == 0;
|
||||
return a.Length() == b.Length() && StringUtils::Compare(a.GetText(), b.GetText(), b.Length()) == 0;
|
||||
}
|
||||
|
||||
bool operator!=(const String& a, const StringView& b)
|
||||
{
|
||||
return a.Length() != b.Length() || StringUtils::Compare(a.GetText(), b.GetNonTerminatedText(), b.Length()) != 0;
|
||||
return a.Length() != b.Length() || StringUtils::Compare(a.GetText(), b.GetText(), b.Length()) != 0;
|
||||
}
|
||||
|
||||
StringAnsiView StringAnsiView::Empty;
|
||||
@@ -111,10 +111,10 @@ StringAnsi StringAnsiView::ToStringAnsi() const
|
||||
|
||||
bool operator==(const StringAnsi& a, const StringAnsiView& b)
|
||||
{
|
||||
return a.Length() == b.Length() && StringUtils::Compare(a.GetText(), b.GetNonTerminatedText(), b.Length()) == 0;
|
||||
return a.Length() == b.Length() && StringUtils::Compare(a.GetText(), b.GetText(), b.Length()) == 0;
|
||||
}
|
||||
|
||||
bool operator!=(const StringAnsi& a, const StringAnsiView& b)
|
||||
{
|
||||
return a.Length() != b.Length() || StringUtils::Compare(a.GetText(), b.GetNonTerminatedText(), b.Length()) != 0;
|
||||
return a.Length() != b.Length() || StringUtils::Compare(a.GetText(), b.GetText(), b.Length()) != 0;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
{
|
||||
const bool thisIsShorter = Length() < str.Length();
|
||||
const int32 minLength = thisIsShorter ? Length() : str.Length();
|
||||
const int32 prefixCompare = searchCase == StringSearchCase::CaseSensitive ? StringUtils::Compare(GetNonTerminatedText(), str.GetNonTerminatedText(), minLength) : StringUtils::CompareIgnoreCase(GetNonTerminatedText(), str.GetNonTerminatedText(), minLength);
|
||||
const int32 prefixCompare = searchCase == StringSearchCase::CaseSensitive ? StringUtils::Compare(GetText(), str.GetText(), minLength) : StringUtils::CompareIgnoreCase(GetText(), str.GetText(), minLength);
|
||||
if (prefixCompare != 0)
|
||||
return prefixCompare;
|
||||
if (Length() == str.Length())
|
||||
@@ -111,8 +111,18 @@ public:
|
||||
|
||||
/// <summary>
|
||||
/// Gets the pointer to the string or to the static empty text if string is null. Returned pointer is always non-null, but is not null-terminated.
|
||||
/// [Deprecated on 26.10.2022, expires on 26.10.2024] Use GetText()
|
||||
/// </summary>
|
||||
FORCE_INLINE const T* GetNonTerminatedText() const
|
||||
FORCE_INLINE DEPRECATED const T* GetNonTerminatedText() const
|
||||
{
|
||||
return _data ? _data : (const T*)TEXT("");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the pointer to the string or to the static empty text if string is null. Returned pointer is always valid (read-only).
|
||||
/// </summary>
|
||||
/// <returns>The string handle.</returns>
|
||||
FORCE_INLINE const T* GetText() const
|
||||
{
|
||||
return _data ? _data : (const T*)TEXT("");
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ String LocalizedStringTable::GetPluralString(const String& id, int32 n) const
|
||||
result = messages->At(n);
|
||||
if (result.IsEmpty() && FallbackTable)
|
||||
result = FallbackTable->GetPluralString(id, n);
|
||||
return String::Format(result.GetNonTerminatedText(), n);
|
||||
return String::Format(result.GetText(), n);
|
||||
}
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
@@ -27,7 +27,7 @@ void WindowsClipboard::SetText(const StringView& text)
|
||||
const HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, sizeWithoutNull + sizeof(Char));
|
||||
|
||||
Char* pMem = static_cast<Char*>(GlobalLock(hMem));
|
||||
Platform::MemoryCopy(pMem, text.GetNonTerminatedText(), sizeWithoutNull);
|
||||
Platform::MemoryCopy(pMem, text.GetText(), sizeWithoutNull);
|
||||
Platform::MemorySet(pMem + text.Length(), sizeof(Char), 0);
|
||||
GlobalUnlock(hMem);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user