![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <StringTemplate.h>
Classes | |
| struct | FErrorInfo |
Public Member Functions | |
| FStringTemplate () | |
| bool | Load (FString TemplateString, FErrorInfo &Errorinfo) |
| const FString & | GetTemplateString () const |
| int32 | GetNumNamedParameters () const |
| void | GetParameters (TArray< FStringView > &OutParams) const |
Friends | |
| class | FStringTemplateResolver |
A string template is a utility class used to generate parameterized strings. To use it, initialize the template by loading a template string with the constructor or manually calling Load() after construction. The Load() function will parse the template string and split it into chunks, where each chunk is either a static span of text or a parameter. After a template has been loaded, resolve the full string using an instance of FStringTemplateResolver.
Parameters can be specifed named and nameless depending on your needs. A named parameter can be specified with the syntax %{parameter_name} while a nameless parameter with s (without backquotes). A string can include both type of parameters. Keep in mind that nameless parameters will be resolved in the order they appear in the template string.
Here is an example of a valid template string:
The last president of the USA is %{name_of_president}.
He was born in %s.
Finally, use may force the emission of the '' character using the "%%" escape sequence.
| FStringTemplate::FStringTemplate | ( | ) |
Constructs an empty string template.
|
inline |
Returns the number of named parameters in this template string, useful to reserve enough capacity in your parameters map.
| void FStringTemplate::GetParameters | ( | TArray< FStringView > & | OutParams | ) | const |
Returns the array of named parameters contained in this template.
|
inline |
Returns the template string.
| bool FStringTemplate::Load | ( | FString | TemplateString, |
| FErrorInfo & | Errorinfo | ||
| ) |
Loads the specified template string for future string resolutions with Resolve(). Returns: whether parsing the string was completed successfully. Note: TemplateString is passed by value as it will be stored within this instance. Consider using MoveTemp() to pass ownership of the template string if you no longer need it.
|
friend |