TStringBuilderBase

String Builder

Windows
MacOS
Linux

Inheritance Hierarchy

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

Name Description

Protected variable

CharType *

 

Base

Protected variable

bool

 

bIsDynamic

Protected variable

CharType *

 

CurPos

Protected variable

CharType *

 

End

Constructors

Name Description

Public function

TStringBuilderBase()

Public function

TStringBuilderBase

(
    const TStringBuilderBase&
)

Public function

TStringBuilderBase

(
    TStringBuilderBase&&
)

Public function

TStringBuilderBase

(
    CharType* BufferPointer,
    int32 BufferCapacity
)

Destructors

Name Description

Public function

~TStringBuilderBase()

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 CharCount
)

Public function

BuilderType ...

 

Append

(
    const CharType* String,
    int32 Length
)

Public function

BuilderType ...

 

Append

(
    const ViewType& StringView
)

Public function

BuilderType ...

 

Append

(
    const CharType* NulTerminatedS...
)

Public function

BuilderType ...

 

Append

(
    CharType Char
)

Public function

BuilderType ...

 

AppendAnsi

(
    const ANSICHAR* String,
    const int32 Length
)

Public function

BuilderType ...

 

AppendAnsi

(
    const FAnsiStringView& AnsiString
)

Public function

BuilderType ...

 

AppendAnsi

(
    const ANSICHAR* NulTerminatedS...
)

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 CharCount
)

Public function Const

const CharTy...

 

GetData()

Public function

CharType ...

 

GetData()

Protected function

void

 

Initialize

(
    CharType* 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 CharTy...

 

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 CharTy...

 

ToString()

Operators

Name Description

Public function Const

const CharTy...

 

operator*()

Public function

TStringBuild...

 

operator=

(
    const TStringBuilderBase&
)

Public function

TStringBuild...

 

operator=

(
    TStringBuilderBase&&
)

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