2016-07-11 11:14:58 -04:00
|
|
|
namespace Utils
|
|
|
|
{
|
|
|
|
namespace String
|
|
|
|
{
|
|
|
|
template <typename ...Args>
|
|
|
|
const char* VA(std::string message, Args && ...args)
|
|
|
|
{
|
|
|
|
#define VA_BUFFER_COUNT 4
|
|
|
|
#define VA_BUFFER_SIZE 65536
|
|
|
|
|
|
|
|
static char g_vaBuffer[VA_BUFFER_COUNT][VA_BUFFER_SIZE];
|
|
|
|
static int g_vaNextBufferIndex = 0;
|
|
|
|
|
|
|
|
char* buffer = g_vaBuffer[g_vaNextBufferIndex];
|
|
|
|
g_vaNextBufferIndex = (g_vaNextBufferIndex + 1) % VA_BUFFER_COUNT;
|
|
|
|
|
2016-08-25 07:25:23 -04:00
|
|
|
std::string str = fmt::sprintf(message, std::forward<Args>(args)...);
|
|
|
|
|
|
|
|
if (memmove_s(buffer, VA_BUFFER_SIZE, str.data(), str.size() + 1))
|
|
|
|
{
|
|
|
|
*buffer = 0; // Error
|
|
|
|
}
|
|
|
|
|
2016-07-11 11:14:58 -04:00
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2016-07-22 06:12:11 -04:00
|
|
|
std::string ToLower(std::string input);
|
|
|
|
std::string ToUpper(std::string input);
|
2016-07-11 11:14:58 -04:00
|
|
|
bool EndsWith(std::string haystack, std::string needle);
|
|
|
|
std::vector<std::string> Explode(const std::string& str, char delim);
|
|
|
|
void Replace(std::string &string, std::string find, std::string replace);
|
|
|
|
bool StartsWith(std::string haystack, std::string needle);
|
|
|
|
std::string <rim(std::string &s);
|
|
|
|
std::string &RTrim(std::string &s);
|
|
|
|
std::string &Trim(std::string &s);
|
|
|
|
|
|
|
|
std::string FormatTimeSpan(int milliseconds);
|
|
|
|
|
|
|
|
std::string DumpHex(std::string data, std::string separator = " ");
|
|
|
|
|
2016-07-22 06:12:11 -04:00
|
|
|
std::string XOR(std::string str, char value);
|
2016-07-11 11:14:58 -04:00
|
|
|
}
|
|
|
|
}
|