Add std::string format functions

This commit is contained in:
Jonathan G Rennison
2019-05-22 19:56:19 +01:00
parent b8820ded59
commit 68dbbf5945
2 changed files with 24 additions and 0 deletions

View File

@@ -167,6 +167,28 @@ char *CDECL str_fmt(const char *str, ...)
return output;
}
std::string stdstr_vfmt(const char *str, va_list va)
{
char buf[4096];
int len = vseprintf(buf, lastof(buf), str, va);
return std::string(buf, len);
}
/**
* Format, "printf", into a std::string.
* @param str The formatting string.
* @return The formatted string.
*/
std::string CDECL stdstr_fmt(const char *str, ...)
{
va_list va;
va_start(va, str);
std::string output = stdstr_vfmt(str, va);
va_end(va);
return output;
}
/**
* Scan the string for old values of SCC_ENCODED and fix it to
* it's new, static value.