Choose your operating system:
Windows
macOS
Linux
Deprecated
'TFixedAnsiStringBuilder' is deprecated. Please use 'TAnsiStringBuilder' instead!
Module |
|
Header |
/Engine/Source/Runtime/Core/Public/Containers/StringFwd.h |
Include |
#include "Containers/StringFwd.h" |
template<typename CharType>
class TStringView
A fixed-size string builder for TCHAR. A fixed-size string builder for ANSICHAR.
A string view is a non-owning view of a range of characters.
Ensure that the underlying string is valid for the lifetime of the string view.
Be careful when constructing a string view from a temporary. Make a local copy if necessary.
FStringView View = Object->GetPathName(); // Invalid
FString PathName = Object->GetPathName(); // Valid FStringView View = PathName;
void ProcessPath(FStringView Path); // Valid ProcessPath(Object->GetPathName());
A string view is implicitly constructible from null-terminated strings, from contiguous ranges of characters such as FString and TStringBuilder, and from literals such as TEXT("..."_SV).
A string view is cheap to copy and is meant to be passed by value. Avoid passing by reference.
A string view is not guaranteed to represent a null-terminated string.
Log or format a string view using UE_LOG(TEXT("%.*s"), View.Len(), View.GetData());
A string view is a good fit for function parameters where the function has no requirements for how the string is stored. A caller may use FString, FStringView, TStringBuilder, a char array, a null-terminated string, or any other type which can convert to a string view.
The UE::String namespace contains many functions that can operate on string views. Most of these functions can be found in String/___.h in Core.
voidUseString(FStringViewInString);FStringString(TEXT("ABC"));constTCHAR*CString=*String;TStringBuilder<16>StringBuilder;StringBuilder.Append(TEXT("ABC"));UseString(String);UseString(CString);UseString(StringBuilder);UseString(TEXT("ABC"));UseString(TEXT("ABC"_SV));
Name | Description | |
---|---|---|
|
TStringView() |
Construct an empty view. |
|
TStringView ( |
Construct a view of the null-terminated string pointed to by InData. |
|
TStringView ( |
Construct a view of the null-terminated string pointed to by InData. |
|
TStringView ( |
Construct a view from a contiguous range of characters, such as FString or TStringBuilder. |
|
TStringView ( |
Construct a view of InSize characters beginning at InData. |
|
TStringView ( |
Construct a view of InSize characters beginning at InData. |
Name | Description | ||
---|---|---|---|
|
constexpr co... |
begin() |
DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support. |
|
Compare ( |
Compare this view with a null-terminated string. |
|
|
Compare ( |
Compare this view with a string view. |
|
|
Compare ( |
Compare this view with a character range. |
|
|
Contains ( |
Returns whether this view contains the specified substring. |
|
|
CopyString |
Copy characters from the view into a destination buffer without null termination. |
|
|
constexpr co... |
end() |
|
|
EndsWith ( |
Returns whether this view ends with the suffix with optional case sensitivity. |
|
|
EndsWith ( |
Returns whether this view ends with the suffix character compared case-sensitively. |
|
|
Equals ( |
Check whether this view is equivalent to a string view. |
|
|
Equals ( |
Check whether this view is equivalent to a character range. |
|
|
Find |
Search the view for the first occurrence of a search string. |
|
|
FindChar ( |
Search the view for the first occurrence of a character. |
|
|
FindLastChar ( |
Search the view for the last occurrence of a character. |
|
|
constexpr co... |
GetData() |
Returns a pointer to the start of the view. This is NOT guaranteed to be null-terminated! |
|
constexpr bo... |
IsEmpty() |
Returns whether the string view is empty. |
|
Left ( |
Returns the left-most part of the view by taking the given number of characters from the left. |
|
|
LeftChop ( |
Returns the left-most part of the view by chopping the given number of characters from the right. |
|
|
LeftChopInline ( |
Modifies the view by chopping the given number of characters from the right. |
|
|
LeftInline ( |
Modifies the view to be the given number of characters from the left. |
|
|
constexpr in... |
Len() |
Returns the length of the string view. |
|
Mid |
Returns the middle part of the view by taking up to the given number of characters from the given position. |
|
|
MidInline |
Modifies the view to be the middle part by taking up to the given number of characters from the given position. |
|
|
RemovePrefix ( |
Modifies the view to remove the given number of characters from the start. |
|
|
RemoveSuffix ( |
Modifies the view to remove the given number of characters from the end. |
|
|
Reset() |
Resets to an empty view |
|
|
Right ( |
Returns the right-most part of the view by taking the given number of characters from the right. |
|
|
RightChop ( |
Returns the right-most part of the view by chopping the given number of characters from the left. |
|
|
RightChopInline ( |
Modifies the view by chopping the given number of characters from the left. |
|
|
RightInline ( |
Modifies the view to be the given number of characters from the right. |
|
|
StartsWith ( |
Returns whether this view starts with the prefix character compared case-sensitively. |
|
|
StartsWith ( |
Returns whether this view starts with the prefix with optional case sensitivity. |
|
|
SubStr |
Alias for Mid. |
|
|
TrimEnd() |
Returns the left part of the view before any whitespace at the end. |
|
|
TrimEndInline() |
Modifies the view to be the left part before any whitespace at the end. |
|
|
TrimStart() |
Returns the right part of the view after any whitespace at the start. |
|
|
TrimStartAndEnd() |
Returns the middle part of the view between any whitespace at the start and end. |
|
|
TrimStartAndEndInline() |
Modifies the view to be the middle part between any whitespace at the start and end. |
|
|
TrimStartInline() |
Modifies the view to be the right part after any whitespace at the start. |
Name | Description | ||
---|---|---|---|
|
const CharTy... |
operator[] ( |
Access the character at the given index in the view. |
Name |
Description |
---|---|
ElementType |
|
ViewType |