dep/fmt: Bump to v11.0.2
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: CC-BY-NC-ND-4.0
|
||||
|
||||
#include "error.h"
|
||||
#include "small_string.h"
|
||||
#include "string_util.h"
|
||||
|
||||
#include <cstdlib>
|
||||
@ -255,6 +256,26 @@ void Error::AddSuffix(std::string_view suffix)
|
||||
m_description.append(suffix);
|
||||
}
|
||||
|
||||
void Error::SetStringFmtArgs(fmt::string_view fmt, fmt::format_args args)
|
||||
{
|
||||
m_type = Type::User;
|
||||
m_description = fmt::vformat(fmt, std::move(args));
|
||||
}
|
||||
|
||||
void Error::AddPrefixFmtArgs(fmt::string_view fmt, fmt::format_args args)
|
||||
{
|
||||
SmallString str;
|
||||
str.vformat(fmt, std::move(args));
|
||||
AddPrefix(str.view());
|
||||
}
|
||||
|
||||
void Error::AddSuffixFmtArgs(fmt::string_view fmt, fmt::format_args args)
|
||||
{
|
||||
SmallString str;
|
||||
str.vformat(fmt, std::move(args));
|
||||
AddSuffix(str.view());
|
||||
}
|
||||
|
||||
void Error::AddPrefix(Error* errptr, std::string_view prefix)
|
||||
{
|
||||
if (errptr)
|
||||
|
||||
@ -3,10 +3,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "small_string.h"
|
||||
#include "types.h"
|
||||
|
||||
#include "fmt/core.h"
|
||||
#include "fmt/base.h"
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@ -84,54 +83,52 @@ public:
|
||||
static void SetHResult(Error* errptr, std::string_view prefix, long err);
|
||||
#endif
|
||||
|
||||
template<typename... T>
|
||||
void SetStringFmt(fmt::format_string<T...> fmt, T&&... args)
|
||||
{
|
||||
SetStringFmtArgs(fmt, fmt::make_format_args(args...));
|
||||
}
|
||||
|
||||
void AddPrefix(std::string_view prefix);
|
||||
|
||||
template<typename... T>
|
||||
void AddPrefixFmt(fmt::format_string<T...> fmt, T&&... args)
|
||||
{
|
||||
AddPrefixFmtArgs(fmt, fmt::make_format_args(args...));
|
||||
}
|
||||
|
||||
void AddSuffix(std::string_view suffix);
|
||||
|
||||
template<typename... T>
|
||||
void AddSuffixFmt(fmt::format_string<T...> fmt, T&&... args)
|
||||
{
|
||||
AddSuffixFmtArgs(fmt, fmt::make_format_args(args...));
|
||||
}
|
||||
|
||||
/// Sets a formatted message.
|
||||
template<typename... T>
|
||||
static void SetStringFmt(Error* errptr, fmt::format_string<T...> fmt, T&&... args)
|
||||
{
|
||||
if (errptr)
|
||||
Error::SetString(errptr, fmt::vformat(fmt, fmt::make_format_args(args...)));
|
||||
errptr->SetStringFmtArgs(fmt, fmt::make_format_args(args...));
|
||||
}
|
||||
|
||||
void AddPrefix(std::string_view prefix);
|
||||
void AddSuffix(std::string_view suffix);
|
||||
static void AddPrefix(Error* errptr, std::string_view prefix);
|
||||
static void AddSuffix(Error* errptr, std::string_view prefix);
|
||||
|
||||
template<typename... T>
|
||||
void AddPrefixFmt(fmt::format_string<T...> fmt, T&&... args)
|
||||
{
|
||||
TinyString str;
|
||||
fmt::vformat_to(std::back_inserter(str), fmt, fmt::make_format_args(args...));
|
||||
AddPrefix(str.view());
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
void AddSuffixFmt(fmt::format_string<T...> fmt, T&&... args)
|
||||
{
|
||||
TinyString str;
|
||||
fmt::vformat_to(std::back_inserter(str), fmt, fmt::make_format_args(args...));
|
||||
AddSuffix(str.view());
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
static void AddPrefixFmt(Error* errptr, fmt::format_string<T...> fmt, T&&... args)
|
||||
{
|
||||
if (errptr)
|
||||
{
|
||||
TinyString str;
|
||||
fmt::vformat_to(std::back_inserter(str), fmt, fmt::make_format_args(args...));
|
||||
errptr->AddPrefix(str.view());
|
||||
}
|
||||
errptr->AddPrefixFmtArgs(fmt, fmt::make_format_args(args...));
|
||||
}
|
||||
|
||||
static void AddSuffix(Error* errptr, std::string_view prefix);
|
||||
|
||||
template<typename... T>
|
||||
static void AddSuffixFmt(Error* errptr, fmt::format_string<T...> fmt, T&&... args)
|
||||
{
|
||||
if (errptr)
|
||||
{
|
||||
TinyString str;
|
||||
fmt::vformat_to(std::back_inserter(str), fmt, fmt::make_format_args(args...));
|
||||
errptr->AddSuffix(str.view());
|
||||
}
|
||||
errptr->AddSuffixFmtArgs(fmt, fmt::make_format_args(args...));
|
||||
}
|
||||
|
||||
Error& operator=(const Error& e);
|
||||
@ -140,6 +137,10 @@ public:
|
||||
bool operator!=(const Error& e) const;
|
||||
|
||||
private:
|
||||
void SetStringFmtArgs(fmt::string_view fmt, fmt::format_args args);
|
||||
void AddPrefixFmtArgs(fmt::string_view fmt, fmt::format_args args);
|
||||
void AddSuffixFmtArgs(fmt::string_view fmt, fmt::format_args args);
|
||||
|
||||
Type m_type = Type::None;
|
||||
std::string m_description;
|
||||
};
|
||||
|
||||
@ -9,6 +9,8 @@
|
||||
#include "string_util.h"
|
||||
#include "timer.h"
|
||||
|
||||
#include "fmt/format.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "fmt/core.h"
|
||||
#include "fmt/base.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstdarg>
|
||||
|
||||
@ -6,8 +6,9 @@
|
||||
#include "small_string.h"
|
||||
#include "types.h"
|
||||
|
||||
#include "fmt/core.h"
|
||||
#include "fmt/base.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
class ProgressCallback
|
||||
|
||||
@ -5,11 +5,12 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "fmt/core.h"
|
||||
#include "fmt/base.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdarg>
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
@ -184,7 +185,7 @@ public:
|
||||
ALWAYS_INLINE const char& front() const { return m_buffer[0]; }
|
||||
ALWAYS_INLINE char& back() { return m_buffer[m_length - 1]; }
|
||||
ALWAYS_INLINE const char& back() const { return m_buffer[m_length - 1]; }
|
||||
ALWAYS_INLINE void push_back(value_type&& val) { append(val); }
|
||||
ALWAYS_INLINE void push_back(value_type val) { append(val); }
|
||||
ALWAYS_INLINE void pop_back() { erase(-1); }
|
||||
|
||||
// returns a string view for this string
|
||||
@ -422,13 +423,13 @@ ALWAYS_INLINE void SmallStringBase::format(fmt::format_string<T...> fmt, T&&...
|
||||
struct fmt::formatter<type> \
|
||||
{ \
|
||||
template<typename ParseContext> \
|
||||
constexpr auto parse(ParseContext& ctx) \
|
||||
constexpr auto parse(ParseContext& ctx) const \
|
||||
{ \
|
||||
return ctx.begin(); \
|
||||
} \
|
||||
\
|
||||
template<typename FormatContext> \
|
||||
auto format(const type& str, FormatContext& ctx) \
|
||||
auto format(const type& str, FormatContext& ctx) const \
|
||||
{ \
|
||||
return fmt::format_to(ctx.out(), "{}", str.view()); \
|
||||
} \
|
||||
|
||||
Reference in New Issue
Block a user