Convert formatting over to fmtlib

This commit is contained in:
Lioncash 2016-08-25 18:41:31 -04:00 committed by MerryMage
parent ee4b30eee4
commit 0102951bdd
9 changed files with 330 additions and 373 deletions

View file

@ -1,36 +0,0 @@
/* This file is part of the dynarmic project.
* Copyright (c) 2016 MerryMage
* This software may be used and distributed according to the terms of the GNU
* General Public License version 2 or any later version.
*/
#include <cstdio>
#include <cstdarg>
#include <string>
#include "common/string_util.h"
namespace Dynarmic {
namespace Common {
std::string StringFromFormat(const char* format, ...) {
va_list args;
va_start(args, format);
int size = std::vsnprintf(nullptr, 0, format, args);
va_end(args);
std::string str;
str.resize(size+1);
va_start(args, format);
std::vsnprintf(&str[0], str.size(), format, args);
va_end(args);
str.resize(size);
return str;
}
} // namespace Common
} // namespace Dynarmic

View file

@ -6,22 +6,9 @@
#pragma once
#include <string>
namespace Dynarmic {
namespace Common {
#ifdef __MINGW32__
[[gnu::format(gnu_printf, 1, 2)]]
#elif !defined(_MSC_VER)
[[gnu::format(printf, 1, 2)]]
#endif
std::string StringFromFormat(
#ifdef _MSC_VER
_Printf_format_string_
#endif
const char* format, ...);
template <typename T>
constexpr char SignToChar(T value) {
return value >= 0 ? '+' : '-';