mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-17 01:12:39 +01:00
Add: AppendStringInPlace() to append translated string ID into an existing string. (#12969)
This allows avoiding a string copy when building strings.
This commit is contained in:
@@ -322,6 +322,19 @@ std::string GetString(StringID string)
|
||||
return GetStringWithArgs(string, _global_string_params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the given StringID and append in place into an existing std::string with all the associated
|
||||
* DParam lookups and formatting.
|
||||
* @param result The std::string to place the translated string.
|
||||
* @param string The unique identifier of the translatable string.
|
||||
*/
|
||||
void AppendStringInPlace(std::string &result, StringID string)
|
||||
{
|
||||
_global_string_params.PrepareForNextRun();
|
||||
StringBuilder builder(result);
|
||||
GetStringWithArgs(builder, string, _global_string_params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a parsed string with most special stringcodes replaced by the string parameters.
|
||||
* @param string The ID of the string to parse.
|
||||
|
||||
Reference in New Issue
Block a user