39 lines
610 B
C++
39 lines
610 B
C++
|
#include <std_include.hpp>
|
||
|
#include "string.hpp"
|
||
|
|
||
|
namespace utils
|
||
|
{
|
||
|
namespace string
|
||
|
{
|
||
|
const char* va(const char* fmt, ...)
|
||
|
{
|
||
|
static thread_local va_provider<8, 256> provider;
|
||
|
|
||
|
va_list ap;
|
||
|
va_start(ap, fmt);
|
||
|
|
||
|
const char* result = provider.get(fmt, ap);
|
||
|
|
||
|
va_end(ap);
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
std::string dump_hex(const std::string& data, const std::string& separator)
|
||
|
{
|
||
|
std::string result;
|
||
|
|
||
|
for (unsigned int i = 0; i < data.size(); ++i)
|
||
|
{
|
||
|
if (i > 0)
|
||
|
{
|
||
|
result.append(separator);
|
||
|
}
|
||
|
|
||
|
result.append(va("%02X", data[i] & 0xFF));
|
||
|
}
|
||
|
|
||
|
return result;
|
||
|
}
|
||
|
}
|
||
|
}
|