mirror of
https://github.com/yuzu-mirror/dynarmic.git
synced 2026-04-06 06:43:47 +00:00
First Commit
This commit is contained in:
commit
65df15633d
55 changed files with 18405 additions and 0 deletions
36
src/common/string_util.cpp
Normal file
36
src/common/string_util.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue