StringUtil: Purge StdStringFromFormat()
This commit is contained in:
parent
567b86ce79
commit
24ef76bfee
|
@ -13,39 +13,6 @@
|
||||||
#include "windows_headers.h"
|
#include "windows_headers.h"
|
||||||
#endif
|
#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*/)
|
bool StringUtil::WildcardMatch(const char* subject, const char* mask, bool case_sensitive /*= true*/)
|
||||||
{
|
{
|
||||||
if (case_sensitive)
|
if (case_sensitive)
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
#include <cstdarg>
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
@ -27,10 +26,6 @@
|
||||||
|
|
||||||
namespace StringUtil {
|
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.
|
/// Checks if a wildcard matches a search string.
|
||||||
bool WildcardMatch(const char* subject, const char* mask, bool case_sensitive = true);
|
bool WildcardMatch(const char* subject, const char* mask, bool case_sensitive = true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue