Ark Server API (ASA) - Wiki
|
#include <StringBuilder.h>
Public Types | |
using | ElementType = CharType |
using | BuilderType = TStringBuilderBase<ElementType> |
using | ViewType = TStringView<ElementType> |
Static Public Attributes | |
template<typename AppendType > | |
static constexpr bool | TCanAppend_V = std::is_same_v<BuilderType&, decltype(DeclVal<BuilderType&>() << DeclVal<AppendType>())> |
template<typename RangeType > | |
static constexpr bool | TCanAppendRange_V = TIsContiguousContainer<RangeType>::Value && TCanAppend_V<decltype(*::GetData(DeclVal<RangeType>()))> |
Protected Member Functions | |
void | Initialize (CharType *InBase, int32 InCapacity) |
void | EnsureNulTerminated () const |
void | EnsureAdditionalCapacity (int32 RequiredAdditionalCapacity) |
void | Extend (SIZE_T ExtraCapacity) |
void * | AllocBuffer (SIZE_T CharCount) |
void | FreeBuffer (void *Buffer, SIZE_T CharCount) |
Protected Attributes | |
CharType * | Base = EmptyBuffer |
CharType * | CurPos = Base |
CharType * | End = Base + 1 |
bool | bIsDynamic = false |
Static Protected Attributes | |
static CharType | EmptyBuffer [1] {} |
Private Types | |
template<typename SrcEncoding > | |
using | TIsCharEncodingCompatibleWithCharType = TIsCharEncodingCompatibleWith<SrcEncoding, CharType> |
Static Private Member Functions | |
static BuilderType &VARARGS | AppendfImpl (BuilderType &Self, const CharType *Fmt,...) |
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.
Definition at line 59 of file StringBuilder.h.
using TStringBuilderBase< CharType >::BuilderType = TStringBuilderBase<ElementType> |
The string builder base type to be used by append operators and function output parameters.
Definition at line 65 of file StringBuilder.h.
using TStringBuilderBase< CharType >::ElementType = CharType |
The character type that this builder operates on.
Definition at line 63 of file StringBuilder.h.
|
private |
Definition at line 323 of file StringBuilder.h.
using TStringBuilderBase< CharType >::ViewType = TStringView<ElementType> |
The string view type that this builder is compatible with.
Definition at line 67 of file StringBuilder.h.
|
default |
TStringBuilderBase< CharType >::~TStringBuilderBase | ( | ) |
|
delete |
|
delete |
|
inline |
Definition at line 97 of file StringBuilder.h.
|
inline |
Adds a given number of uninitialized characters into the string builder.
InCount | The number of uninitialized characters to add. |
Definition at line 137 of file StringBuilder.h.
|
protected |
|
inline |
Definition at line 197 of file StringBuilder.h.
|
inline |
Definition at line 165 of file StringBuilder.h.
|
inline |
Definition at line 156 of file StringBuilder.h.
|
inline |
Definition at line 204 of file StringBuilder.h.
|
inline |
Definition at line 206 of file StringBuilder.h.
|
inline |
Definition at line 202 of file StringBuilder.h.
|
inline |
Definition at line 175 of file StringBuilder.h.
|
inline |
Appends to the string builder similarly to how classic sprintf works.
Fmt | A format string that specifies how to format the additional arguments. Refer to standard printf format. |
Definition at line 333 of file StringBuilder.h.
|
staticprivate |
BuilderType & TStringBuilderBase< CharType >::AppendV | ( | const CharType * | Fmt, |
va_list | Args ) |
Appends to the string builder similarly to how classic vsprintf works.
Fmt | A format string that specifies how to format the additional arguments. Refer to standard printf format. |
|
inlineprotected |
Definition at line 362 of file StringBuilder.h.
|
inlineprotected |
Definition at line 357 of file StringBuilder.h.
|
protected |
|
protected |
|
inline |
Helper function to return the amount of memory allocated by this container. Does not include the sizeof of the inline buffer, only includes the size of the overflow buffer.
Definition at line 117 of file StringBuilder.h.
|
inline |
Definition at line 103 of file StringBuilder.h.
|
inline |
Definition at line 104 of file StringBuilder.h.
|
inlineprotected |
Definition at line 350 of file StringBuilder.h.
|
inline |
Insert substring at given position
Definition at line 240 of file StringBuilder.h.
|
inline |
Append every element of the range to the builder, separating the elements by the delimiter.
This function is only available when the elements of the range and the delimiter can both be written to the builder using the append operator.
InRange | The range of elements to join and append. |
InDelimiter | The delimiter to append as a separator for the elements. |
Definition at line 270 of file StringBuilder.h.
|
inline |
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.
This function is only available when the elements of the range, the delimiter, and the quote can be written to the builder using the append operator.
InRange | The range of elements to join and append. |
InDelimiter | The delimiter to append as a separator for the elements. |
InQuote | The quote to append on both sides of each element. |
Definition at line 303 of file StringBuilder.h.
|
inline |
Definition at line 109 of file StringBuilder.h.
|
inline |
Definition at line 102 of file StringBuilder.h.
|
inline |
Definition at line 107 of file StringBuilder.h.
|
inline |
Definition at line 92 of file StringBuilder.h.
|
delete |
|
delete |
|
inline |
Definition at line 86 of file StringBuilder.h.
|
inline |
Insert prefix
Definition at line 252 of file StringBuilder.h.
|
inline |
Remove characters at given position
Definition at line 246 of file StringBuilder.h.
|
inline |
Modifies the string builder to remove the given number of characters from the end.
Definition at line 148 of file StringBuilder.h.
|
inline |
Replace characters at given position and length with substring
Definition at line 209 of file StringBuilder.h.
|
inline |
Empties the string builder, but doesn't change memory allocation.
Definition at line 125 of file StringBuilder.h.
|
inline |
Definition at line 105 of file StringBuilder.h.
|
inline |
Definition at line 106 of file StringBuilder.h.
|
protected |
Definition at line 381 of file StringBuilder.h.
|
protected |
Definition at line 384 of file StringBuilder.h.
|
protected |
Definition at line 382 of file StringBuilder.h.
|
inlinestaticprotected |
Definition at line 379 of file StringBuilder.h.
|
protected |
Definition at line 383 of file StringBuilder.h.
|
inlinestaticconstexpr |
Whether the given type can be appended to this builder using the append operator.
Definition at line 71 of file StringBuilder.h.
|
inlinestaticconstexpr |
Whether the given range type can have its elements appended to the builder using the append operator.
Definition at line 75 of file StringBuilder.h.