TStringBuilderImpl

String Builder implementation

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Misc/StringBuilder.h

Include

#include "Misc/StringBuilder.h"

Syntax

template<typename C>
class TStringBuilderImpl

Remarks

String Builder implementation

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. For instances where you absolutely must not allocate any memory, you should use the fixed variants named TFixed*StringBuilder

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

Name Description

Protected variable

C *

 

Base

Protected variable

bool

 

bIsDynamic

Protected variable

bool

 

bIsExtendable

Protected variable

C *

 

CurPos

Protected variable

C *

 

End

Constructors

Destructors

Name Description

Public function

~TStringBuilderImpl()

Functions

Name Description

Public function

int32

 

AddUninitialized

(
    int32 InCount
)

Adds a given number of uninitialized characters into the string builder.

Protected function

void *

 

AllocBuffer

(
    SIZE_T byteCount
)

Public function

BuilderType ...

 

Append

(
    const C* String,
    int32 Length
)

Public function

BuilderType ...

 

Append

(
    const C StringLiteral
)

Public function

BuilderType ...

 

Append

(
    C CharArray
)

Public function

BuilderType ...

 

Append

(
    const ViewType& StringView
)

Public function

BuilderType ...

 

Append

(
    const C*& NulTerminatedString
)

Public function

BuilderType ...

 

Append

(
    C Char
)

Public function

BuilderType ...

 

AppendAnsi

(
    const ANSICHAR*& NulTerminated...
)

Public function

BuilderType ...

 

AppendAnsi

(
    const ANSICHAR* String,
    const int32 Length
)

Public function

BuilderType ...

 

AppendAnsi

(
    const FAnsiStringView& AnsiString
)

Public function

BuilderType ...

 

AppendAnsi

(
    const ANSICHAR StringLiteral
)

Public function

TEnableIf< T...

 

Appendf

(
    const FmtType& Fmt,
    Types... Args
)

Appends to the string builder similarly to how classic sprintf works.

Protected function

void

 

EnsureCapacity

(
    int32 RequiredAdditionalCapacity
)

Protected function Const

void

 

EnsureNulTerminated()

Protected function

void

 

Extend

(
    SIZE_T extraCapacity
)

Protected function

void

 

FreeBuffer

(
    void* buffer,
    SIZE_T byteCount
)

Public function Const

const C *...

 

GetData()

Public function

C *

 

GetData()

Protected function

void

 

Initialize

(
    C* InBase,
    int32 InCapacity
)

Public function

BuilderType ...

 

Join

(
    RangeType&& InRange,
    DelimiterType&& InDelimiter
)

Append every element of the range to the builder, separating the elements by the delimiter.

Public function

BuilderType ...

 

JoinQuoted

(
    RangeType&& InRange,
    DelimiterType&& InDelimiter,
    QuoteType&& InQuote
)

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.

Public function Const

const C

 

LastChar()

Public function Const

int32

 

Len()

Public function

void

 

RemoveSuffix

(
    int32 InCount
)

Modifies the string builder to remove the given number of characters from the end.

Public function

void

 

Reset()

Empties the string builder, but doesn't change memory allocation.

Public function Const

const C *...

 

ToString()

Operators

Name Description

Public function Const

 

operator ViewType()

Public function Const

const C *...

 

operator*()

Public function

const TStrin...

 

operator=

(
    const TStringBuilderImpl&
)

Public function

const TStrin...

 

operator=

(
    TStringBuilderImpl&&
)

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.

TCanAppend

Whether the given type can be appended to this builder using the append operator.

TCanAppendRange

Whether the given range type can have its elements appended to the builder using the append operator.

ViewType

The string view type that this builder is compatible with.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss