Updated clang-format

Merged with origin
This commit is contained in:
gabime
2023-09-25 16:05:07 +03:00
parent 218e859867
commit dcd5904bdc
94 changed files with 1505 additions and 1445 deletions

View File

@@ -53,7 +53,8 @@
#include <spdlog/fmt/fmt.h>
#if !defined(SPDLOG_USE_STD_FORMAT) && FMT_VERSION >= 80000 // backward compatibility with fmt versions older than 8
#if !defined(SPDLOG_USE_STD_FORMAT) && \
FMT_VERSION >= 80000 // backward compatibility with fmt versions older than 8
#define SPDLOG_FMT_RUNTIME(format_string) fmt::runtime(format_string)
#if defined(SPDLOG_WCHAR_FILENAMES)
#include <spdlog/fmt/xchar.h>
@@ -176,7 +177,9 @@ using atomic_level_t = std::atomic<level>;
{ "T", "D", "I", "W", "E", "C", "O" }
#endif
[[nodiscard]] constexpr size_t level_to_number(level lvl) noexcept { return static_cast<size_t>(lvl); }
[[nodiscard]] constexpr size_t level_to_number(level lvl) noexcept {
return static_cast<size_t>(lvl);
}
constexpr auto levels_count = level_to_number(level::n_levels);
constexpr std::array<string_view_t, levels_count> level_string_views SPDLOG_LEVEL_NAMES;
constexpr std::array<const char *, levels_count> short_level_names SPDLOG_SHORT_LEVEL_NAMES;
@@ -223,19 +226,24 @@ private:
struct source_loc {
constexpr source_loc() = default;
constexpr source_loc(const char *filename_in, std::uint_least32_t line_in, const char *funcname_in)
: filename{filename_in},
line{line_in},
funcname{funcname_in} {}
constexpr source_loc(const char *filename_in,
std::uint_least32_t line_in,
const char *funcname_in)
: filename{filename_in}
, line{line_in}
, funcname{funcname_in} {}
#ifdef SPDLOG_HAVE_STD_SOURCE_LOCATION
static constexpr source_loc current(const std::source_location source_location = std::source_location::current()) {
return source_loc{source_location.file_name(), source_location.line(), source_location.function_name()};
static constexpr source_loc
current(const std::source_location source_location = std::source_location::current()) {
return source_loc{source_location.file_name(), source_location.line(),
source_location.function_name()};
}
#elif defined(SPDLOG_HAVE_EXPERIMENTAL_SOURCE_LOCATION)
static constexpr source_loc
current(const std::experimental::source_location source_location = std::experimental::source_location::current()) {
return source_loc{source_location.file_name(), source_location.line(), source_location.function_name()};
static constexpr source_loc current(const std::experimental::source_location source_location =
std::experimental::source_location::current()) {
return source_loc{source_location.file_name(), source_location.line(),
source_location.function_name()};
}
#else // no source location support
static constexpr source_loc current() { return source_loc{}; }
@@ -254,22 +262,23 @@ struct loc_with_fmt {
string_view_t fmt_string;
template <typename S, typename = is_convertible_to_sv<S>>
constexpr loc_with_fmt(S fmt_str, source_loc loc = source_loc::current()) noexcept
: loc(loc),
fmt_string(fmt_str) {}
: loc(loc)
, fmt_string(fmt_str) {}
#ifndef SPDLOG_USE_STD_FORMAT
constexpr loc_with_fmt(fmt::runtime_format_string<char> fmt_str, source_loc loc = source_loc::current()) noexcept
: loc(loc),
fmt_string(fmt_str.str) {}
constexpr loc_with_fmt(fmt::runtime_format_string<char> fmt_str,
source_loc loc = source_loc::current()) noexcept
: loc(loc)
, fmt_string(fmt_str.str) {}
#endif
};
struct file_event_handlers {
file_event_handlers()
: before_open(nullptr),
after_open(nullptr),
before_close(nullptr),
after_close(nullptr) {}
: before_open(nullptr)
, after_open(nullptr)
, before_close(nullptr)
, after_close(nullptr) {}
std::function<void(const filename_t &filename)> before_open;
std::function<void(const filename_t &filename, std::FILE *file_stream)> after_open;
@@ -285,32 +294,39 @@ namespace details {
return spdlog::string_view_t{buf.data(), buf.size()};
}
[[nodiscard]] constexpr spdlog::string_view_t to_string_view(spdlog::string_view_t str) noexcept { return str; }
[[nodiscard]] constexpr spdlog::string_view_t to_string_view(spdlog::string_view_t str) noexcept {
return str;
}
#if defined(SPDLOG_WCHAR_FILENAMES)
[[nodiscard]] constexpr spdlog::wstring_view_t to_string_view(const wmemory_buf_t &buf) noexcept {
return spdlog::wstring_view_t{buf.data(), buf.size()};
}
[[nodiscard]] constexpr spdlog::wstring_view_t to_string_view(spdlog::wstring_view_t str) noexcept { return str; }
[[nodiscard]] constexpr spdlog::wstring_view_t to_string_view(spdlog::wstring_view_t str) noexcept {
return str;
}
#endif
// convert format_string<...> to string_view depending on format lib versions
#if defined(SPDLOG_USE_STD_FORMAT)
#if __cpp_lib_format >= 202207L // std::format and __cpp_lib_format >= 202207L
template <typename T, typename... Args>
[[nodiscard]] constexpr std::basic_string_view<T> to_string_view(std::basic_format_string<T, Args...> fmt) noexcept {
[[nodiscard]] constexpr std::basic_string_view<T>
to_string_view(std::basic_format_string<T, Args...> fmt) noexcept {
return fmt.get();
}
#else // std::format and __cpp_lib_format < 202207L
template <typename T, typename... Args>
[[nodiscard]] constexpr std::basic_string_view<T> to_string_view(std::basic_format_string<T, Args...> fmt) noexcept {
[[nodiscard]] constexpr std::basic_string_view<T>
to_string_view(std::basic_format_string<T, Args...> fmt) noexcept {
return fmt;
}
#endif
#else // {fmt} version
template <typename T, typename... Args>
[[nodiscard]] constexpr fmt::basic_string_view<T> to_string_view(fmt::basic_format_string<T, Args...> fmt) noexcept {
[[nodiscard]] constexpr fmt::basic_string_view<T>
to_string_view(fmt::basic_format_string<T, Args...> fmt) noexcept {
return fmt;
}
#endif