Navigation
Unreal Engine C++ API Reference > Runtime > Core > Containers
Inheritance Hierarchy
- TStringBuilderBase
- TStringBuilderWithBuffer
- FNameBuilder
References
Module | Core |
Header | /Engine/Source/Runtime/Core/Public/Containers/StringFwd.h |
Include | #include "Containers/StringFwd.h" |
Syntax
template<typename CharType>
class TStringBuilderBase
Remarks
String Builder
This class helps with the common task of constructing new strings.
It does this by allocating buffer space which is used to hold the constructed string. The intent is that the builder is allocated on the stack as a function local variable to avoid heap allocations.
The buffer is always contiguous and the class is not intended to be used to construct extremely large strings.
This is not intended to be used as a mechanism for holding on to strings for a long time. The use case is explicitly to aid in constructing strings on the stack and subsequently passing the string into a function call or a more permanent string storage mechanism like FString et al.
The amount of buffer space to allocate is specified via a template parameter and if the constructed string should overflow this initial buffer, a new buffer will be allocated using regular dynamic memory allocations.
Overflow allocation should be the exceptional case however always try to size the buffer so that it can hold the vast majority of strings you expect to construct.
Be mindful that stack is a limited resource, so if you are writing a highly recursive function you may want to use some other mechanism to build your strings.
Variables
Type | Name | Description | |
---|---|---|---|
![]() |
CharType * | Base | |
![]() |
bool | bIsDynamic | |
![]() |
CharType * | CurPos | |
![]() |
CharType * | End |
Constructors
Type | Name | Description | |
---|---|---|---|
![]() |
|||
![]() |
TStringBuilderBase
(
const TStringBuilderBase& |
||
![]() |
|||
![]() |
TStringBuilderBase
(
CharType* BufferPointer, |
Destructors
Type | Name | Description | |
---|---|---|---|
![]() |
CORE_API |
Functions
Type | Name | Description | |
---|---|---|---|
![]() |
int32 | AddUninitialized
(
int32 InCount |
Adds a given number of uninitialized characters into the string builder. |
![]() |
void * | AllocBuffer
(
SIZE_T CharCount |
|
![]() |
BuilderType & | Append
(
const OtherCharType*const String, |
|
![]() |
auto | Append
(
CharRangeType&& Range |
|
![]() |
BuilderType & | AppendChar
(
AppendedCharType Char |
|
![]() |
BuilderType & | Appendf
(
const FmtType& Fmt, |
Appends to the string builder similarly to how classic sprintf works. |
![]() |
BuilderType & | AppendV
(
const CharType* Fmt, |
Appends to the string builder similarly to how classic vsprintf works. |
![]() |
void | EnsureAdditionalCapacity
(
int32 RequiredAdditionalCapacity |
|
![]() ![]() |
void | ||
![]() |
void | Extend
(
SIZE_T ExtraCapacity |
|
![]() |
void | FreeBuffer
(
void* Buffer, |
|
![]() ![]() |
SIZE_T | Helper function to return the amount of memory allocated by this container. | |
![]() ![]() |
const CharType * | GetData () |
|
![]() |
CharType * | GetData () |
Returns a pointer to Len() code units that are not necessarily null-terminated. |
![]() |
void | Initialize
(
CharType* InBase, |
|
![]() |
void | Insert substring at given position | |
![]() |
BuilderType & | Join
(
RangeType&& InRange, |
Append every element of the range to the builder, separating the elements by the delimiter. |
![]() |
BuilderType & | JoinQuoted
(
RangeType&& InRange, |
Append every element of the range to the builder, separating the elements by the delimiter, and surrounding every element on each side with the given quote. |
![]() ![]() |
const CharType | LastChar () |
Returns the last character, technically the last code unit. |
![]() ![]() |
int32 | Len () |
|
![]() |
void | Insert prefix | |
![]() |
void | RemoveAt
(
int32 Pos, |
Remove characters at given position |
![]() |
void | RemoveSuffix
(
int32 InCount |
Modifies the string builder to remove the given number of characters from the end. |
![]() |
void | Replace characters at given position and length with substring | |
![]() |
void | Reset () |
Empties the string builder, but doesn't change memory allocation. |
![]() ![]() |
const CharType * | ToString () |
Returns a pointer to a null-terminated string that is valid until the builder is mutated. |
![]() ![]() |
ViewType | ToView () |
Returns a view of the string that is valid until the builder is mutated. |
Operators
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
const CharType * | operator* () |
Returns a pointer to a null-terminated string that is valid until the builder is mutated. |
![]() |
TStringBuilderBase & | operator=
(
const TStringBuilderBase& |
|
![]() |
TStringBuilderBase & | operator=
(
TStringBuilderBase&& |
|
![]() |
TStringBuilderBase & | ||
![]() |
TStringBuilderBase & | operator=
(
const CharType* Str |
Typedefs
Name | Description |
---|---|
BuilderType | The string builder base type to be used by append operators and function output parameters. |
ElementType | The character type that this builder operates on. |
TIsCharEncodingCompatibleWithCharType | |
ViewType | The string view type that this builder is compatible with. |
Constants
Name | Description |
---|---|
EmptyBuffer | |
TCanAppend_V | Whether the given type can be appended to this builder using the append operator. |
TCanAppendRange_V | Whether the given range type can have its elements appended to the builder using the append operator. |
Deprecated Functions
Type | Name | Description | |
---|---|---|---|
![]() |
BuilderType & | AppendAnsi
(
const FAnsiStringView String |
Use Append instead of AppendAnsi. |