Win32: Added @uptime template token and MS_UPTIME stringid to goldlang.cfg
This commit is contained in:
@@ -151,6 +151,10 @@ char* strcvtc(char* s);
|
||||
#define PRINTF_DECLARE_BUFFER(b) b, ARRAYSIZE(b), __FILE__, __LINE__
|
||||
int gsprintf(TCHAR* buffer, size_t sizeOfBuffer, const TCHAR* __file, int __line, const TCHAR* format, ...);
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
std::string &FormatString(std::string &format, const char *token, const char *replace);
|
||||
std::string &FormatString(std::string &format, const char *token, size_t replace);
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// String tokenizer class
|
||||
|
@@ -771,4 +771,30 @@ void tokenize(gstrarray &array, const TCHAR* str, const TCHAR *delim)
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
std::string &FormatString(std::string &format, const char *token, const char *replace)
|
||||
{
|
||||
size_t tokenLen = strlen(token);
|
||||
size_t pos = format.find(token);
|
||||
|
||||
for (; pos != std::string::npos; pos = format.find(token))
|
||||
{
|
||||
format.replace(pos, tokenLen, replace);
|
||||
}
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
std::string &FormatString(std::string &format, const char *token, size_t replace)
|
||||
{
|
||||
char buff[128];
|
||||
gsprintf(PRINTF_DECLARE_BUFFER(buff), "%u", replace);
|
||||
return FormatString(format, token, buff);
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user