engine
 
载入中...
搜索中...
未找到
Public 类型 | Public 成员函数 | 所有成员列表
TStringBuilderBase< CharType > 模板类 参考

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.
 

详细描述

template<typename CharType>
class TStringBuilderBase< CharType >

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.

成员函数说明

◆ AddUninitialized()

template<typename CharType >
int32 TStringBuilderBase< CharType >::AddUninitialized ( int32  InCount)
inline

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

参数
InCountThe number of uninitialized characters to add.
返回
The number of characters in the string builder before adding the new characters.

◆ Appendf()

template<typename CharType >
template<typename FmtType , typename... Types>
TEnableIf< TIsArrayOrRefOfType< FmtType, CharType >::Value, BuilderType & >::Type TStringBuilderBase< CharType >::Appendf ( const FmtType &  Fmt,
Types...  Args 
)
inline

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

参数
FormatA format string that specifies how to format the additional arguments. Refer to standard printf format.

◆ Join()

template<typename CharType >
template<typename RangeType , typename DelimiterType , typename = typename TEnableIf<TAnd<TCanAppendRange<RangeType&&>, TCanAppend<DelimiterType&&>>::Value>::Type>
BuilderType & TStringBuilderBase< CharType >::Join ( RangeType &&  InRange,
DelimiterType &&  InDelimiter 
)
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.

参数
InRangeThe range of elements to join and append.
InDelimiterThe delimiter to append as a separator for the elements.
返回
The builder, to allow additional operations to be composed with this one.

◆ JoinQuoted()

template<typename CharType >
template<typename RangeType , typename DelimiterType , typename QuoteType , typename = typename TEnableIf<TAnd<TCanAppendRange<RangeType>, TCanAppend<DelimiterType&&>, TCanAppend<QuoteType&&>>::Value>::Type>
BuilderType & TStringBuilderBase< CharType >::JoinQuoted ( RangeType &&  InRange,
DelimiterType &&  InDelimiter,
QuoteType &&  InQuote 
)
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.

参数
InRangeThe range of elements to join and append.
InDelimiterThe delimiter to append as a separator for the elements.
InQuoteThe quote to append on both sides of each element.
返回
The builder, to allow additional operations to be composed with this one.

该类的文档由以下文件生成: