UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
StringFormatter.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
8
10
12template <typename CharType>
14{
15public:
16
18
26 {
27 auto Result = FormatInternal(InExpression, InArgs, false);
28 if (ensure(Result.IsValid()))
29 {
30 return MoveTemp(Result.GetValue());
31 }
32
33 return InExpression;
34 }
35
42 TString<CharType> Format(const CharType* InExpression, const TArray<FStringFormatArg>& InArgs) const
43 {
44 auto Result = FormatInternal(InExpression, InArgs, false);
45 if (ensure(Result.IsValid()))
46 {
47 return MoveTemp(Result.GetValue());
48 }
49
50 return InExpression;
51 }
52
60 {
61 return FormatInternal(InExpression, InArgs, true);
62 }
63
71 {
72 return FormatInternal(InExpression, InArgs, true);
73 }
74
75private:
76
78 CORE_API TValueOrError<TString<CharType>, FExpressionError> FormatInternal(const CharType* InExpression, const TMap<TString<CharType>, FStringFormatArg>& InArgs, bool bStrict) const;
79 CORE_API TValueOrError<TString<CharType>, FExpressionError> FormatInternal(const CharType* InExpression, const TArray<FStringFormatArg>& InArgs, bool bStrict) const;
80
82 TTokenDefinitions<CharType> NamedDefinitions;
83 TTokenDefinitions<CharType> OrderedDefinitions;
84
86 TTokenDefinitions<CharType> StrictNamedDefinitions;
87 TTokenDefinitions<CharType> StrictOrderedDefinitions;
88};
89
90extern template class TStringFormatter<ANSICHAR>;
91extern template class TStringFormatter<UTF8CHAR>;
92extern template class TStringFormatter<WIDECHAR>;
#define ensure( InExpression)
Definition AssertionMacros.h:464
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition StringFormatter.h:14
CORE_API TStringFormatter()
Definition StringFormatter.cpp:371
TString< CharType > Format(const CharType *InExpression, const TArray< FStringFormatArg > &InArgs) const
Definition StringFormatter.h:42
TValueOrError< TString< CharType >, FExpressionError > FormatStrict(const CharType *InExpression, const TMap< TString< CharType >, FStringFormatArg > &InArgs) const
Definition StringFormatter.h:59
TValueOrError< TString< CharType >, FExpressionError > FormatStrict(const CharType *InExpression, const TArray< FStringFormatArg > &InArgs) const
Definition StringFormatter.h:70
TString< CharType > Format(const CharType *InExpression, const TMap< TString< CharType >, FStringFormatArg > &InArgs) const
Definition StringFormatter.h:25
Definition ExpressionParserTypes.h:499
Definition ValueOrError.h:58
Definition ExpressionParserTypes.h:27
Definition StringFormatArg.h:11