mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-01-05 14:08:17 +01:00
Convert formatting over to fmtlib
This commit is contained in:
parent
ee4b30eee4
commit
0102951bdd
9 changed files with 330 additions and 373 deletions
|
|
@ -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
|
||||
|
|
@ -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 ? '+' : '-';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue