iw4x-client/iw4/Utils/Utils.cpp

32 lines
774 B
C++
Raw Normal View History

2015-12-23 08:45:53 -05:00
#include "..\STDInclude.hpp"
#define VA_BUFFER_COUNT 4
#define VA_BUFFER_SIZE 4096
namespace Utils
{
const char *VA(const char *fmt, ...)
{
static char g_vaBuffer[VA_BUFFER_COUNT][VA_BUFFER_SIZE];
static int g_vaNextBufferIndex = 0;
va_list ap;
va_start(ap, fmt);
char* dest = g_vaBuffer[g_vaNextBufferIndex];
vsprintf_s(g_vaBuffer[g_vaNextBufferIndex], fmt, ap);
g_vaNextBufferIndex = (g_vaNextBufferIndex + 1) % VA_BUFFER_COUNT;
va_end(ap);
return dest;
}
std::string StrToLower(std::string input)
{
std::transform(input.begin(), input.end(), input.begin(), ::tolower);
return input;
}
2015-12-24 08:28:08 -05:00
bool EndsWith(const char* heystack, const char* needle)
{
return (strstr(heystack, needle) == (heystack + strlen(heystack) - strlen(needle)));
}
2015-12-23 08:45:53 -05:00
}