String Builder 更多...
#include <StringBuilder.h>
类 TStringBuilderBase< CharType > 继承关系图:Public 类型 | |
| using | BuilderType = TStringBuilderBase< ElementType > |
| The string builder base type to be used by append operators and function output parameters. | |
| using | ElementType = CharType |
| The character type that this builder operates on. | |
| template<typename AppendType > | |
| using | TCanAppend = TIsSame< BuilderType &, decltype(DeclVal< BuilderType & >()<< DeclVal< AppendType >())> |
| Whether the given type can be appended to this builder using the append operator. | |
| template<typename RangeType > | |
| using | TCanAppendRange = TAnd< TIsContiguousContainer< RangeType >, TCanAppend< decltype(*::GetData(DeclVal< RangeType >()))> > |
| Whether the given range type can have its elements appended to the builder using the append operator. | |
| using | ViewType = TStringView< ElementType > |
| The string view type that this builder is compatible with. | |
Public 成员函数 | |
| int32 | AddUninitialized (int32 InCount) |
| Adds a given number of uninitialized characters into the string builder. 更多... | |
| template<typename FmtType , typename... Types> | |
| TEnableIf< TIsArrayOrRefOfType< FmtType, CharType >::Value, BuilderType & >::Type | Appendf (const FmtType &Fmt, Types... Args) |
| Appends to the string builder similarly to how classic sprintf works. 更多... | |
| template<typename RangeType , typename DelimiterType , typename = typename TEnableIf<TAnd<TCanAppendRange<RangeType&&>, TCanAppend<DelimiterType&&>>::Value>::Type> | |
| BuilderType & | Join (RangeType &&InRange, DelimiterType &&InDelimiter) |
| Append every element of the range to the builder, separating the elements by the delimiter. 更多... | |
| template<typename RangeType , typename DelimiterType , typename QuoteType , typename = typename TEnableIf<TAnd<TCanAppendRange<RangeType>, TCanAppend<DelimiterType&&>, TCanAppend<QuoteType&&>>::Value>::Type> | |
| 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. 更多... | |
| void | RemoveSuffix (int32 InCount) |
| Modifies the string builder to remove the given number of characters from the end. | |
| void | Reset () |
| Empties the string builder, but doesn't change memory allocation. | |
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.
|
inline |
Adds a given number of uninitialized characters into the string builder.
| InCount | The number of uninitialized characters to add. |
|
inline |
Appends to the string builder similarly to how classic sprintf works.
| Format | A format string that specifies how to format the additional arguments. Refer to standard printf format. |
|
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. |
|
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. |