Fix build

This commit is contained in:
Vojtech Kral 2018-11-19 11:07:39 +01:00
parent 6629d75853
commit b950e9e575
4 changed files with 24 additions and 10 deletions

View file

@ -3,6 +3,8 @@
#include <locale>
#include <ctime>
#include <cstdarg>
#include <stdio.h>
#ifdef WIN32
#include <windows.h>
@ -297,6 +299,25 @@ namespace PerlUtils {
std::string path_to_parent_path(const char *src) { return boost::filesystem::path(src).parent_path().string(); }
};
std::string string_printf(const char *format, ...)
{
va_list args1;
va_start(args1, format);
va_list args2;
va_copy(args2, args1);
size_t needed_size = ::vsnprintf(nullptr, 0, format, args1) + 1;
va_end(args1);
std::string res(needed_size, '\0');
::vsnprintf(&res.front(), res.size(), format, args2);
va_end(args2);
return res;
}
std::string timestamp_str()
{
const auto now = boost::posix_time::second_clock::local_time();