StringUtil: Purge StdStringFromFormat()

This commit is contained in:
Stenzek 2024-07-19 14:01:04 +10:00
parent 567b86ce79
commit 24ef76bfee
No known key found for this signature in database
2 changed files with 0 additions and 38 deletions

View file

@ -13,39 +13,6 @@
#include "windows_headers.h"
#endif
std::string StringUtil::StdStringFromFormat(const char* format, ...)
{
std::va_list ap;
va_start(ap, format);
std::string ret = StdStringFromFormatV(format, ap);
va_end(ap);
return ret;
}
std::string StringUtil::StdStringFromFormatV(const char* format, std::va_list ap)
{
std::va_list ap_copy;
va_copy(ap_copy, ap);
#ifdef _WIN32
int len = _vscprintf(format, ap_copy);
#else
int len = std::vsnprintf(nullptr, 0, format, ap_copy);
#endif
va_end(ap_copy);
std::string ret;
// If an encoding error occurs, len is -1. Which we definitely don't want to resize to.
if (len > 0)
{
ret.resize(len);
std::vsnprintf(ret.data(), ret.size() + 1, format, ap);
}
return ret;
}
bool StringUtil::WildcardMatch(const char* subject, const char* mask, bool case_sensitive /*= true*/)
{
if (case_sensitive)

View file

@ -4,7 +4,6 @@
#pragma once
#include "types.h"
#include <charconv>
#include <cstdarg>
#include <cstddef>
#include <cstring>
#include <iomanip>
@ -27,10 +26,6 @@
namespace StringUtil {
/// Constructs a std::string from a format string.
std::string StdStringFromFormat(const char* format, ...) printflike(1, 2);
std::string StdStringFromFormatV(const char* format, std::va_list ap);
/// Checks if a wildcard matches a search string.
bool WildcardMatch(const char* subject, const char* mask, bool case_sensitive = true);