Clang format

This commit is contained in:
gabime
2023-09-24 20:43:14 +03:00
parent 5654205d6b
commit e28eadcd52
38 changed files with 326 additions and 356 deletions

View File

@@ -68,7 +68,7 @@ namespace spdlog {
namespace details {
namespace os {
spdlog::log_clock::time_point now() noexcept
spdlog::log_clock::time_point now() noexcept
{
#if defined __linux__ && defined SPDLOG_CLOCK_COARSE
@@ -81,7 +81,7 @@ namespace os {
return log_clock::now();
#endif
}
std::tm localtime(const std::time_t &time_tt) noexcept
std::tm localtime(const std::time_t &time_tt) noexcept
{
#ifdef _WIN32
@@ -94,13 +94,13 @@ namespace os {
return tm;
}
std::tm localtime() noexcept
std::tm localtime() noexcept
{
std::time_t now_t = ::time(nullptr);
return localtime(now_t);
}
std::tm gmtime(const std::time_t &time_tt) noexcept
std::tm gmtime(const std::time_t &time_tt) noexcept
{
#ifdef _WIN32
@@ -113,14 +113,14 @@ namespace os {
return tm;
}
std::tm gmtime() noexcept
std::tm gmtime() noexcept
{
std::time_t now_t = ::time(nullptr);
return gmtime(now_t);
}
// fopen_s on non windows for writing
bool fopen_s(FILE **fp, const filename_t &filename, const filename_t &mode)
bool fopen_s(FILE **fp, const filename_t &filename, const filename_t &mode)
{
#ifdef _WIN32
# ifdef SPDLOG_WCHAR_FILENAMES
@@ -160,7 +160,7 @@ namespace os {
return *fp == nullptr;
}
int remove(const filename_t &filename) noexcept
int remove(const filename_t &filename) noexcept
{
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
return ::_wremove(filename.c_str());
@@ -169,12 +169,12 @@ namespace os {
#endif
}
int remove_if_exists(const filename_t &filename) noexcept
int remove_if_exists(const filename_t &filename) noexcept
{
return path_exists(filename) ? remove(filename) : 0;
}
int rename(const filename_t &filename1, const filename_t &filename2) noexcept
int rename(const filename_t &filename1, const filename_t &filename2) noexcept
{
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
return ::_wrename(filename1.c_str(), filename2.c_str());
@@ -184,7 +184,7 @@ namespace os {
}
// Return true if path exists (file or directory)
bool path_exists(const filename_t &filename) noexcept
bool path_exists(const filename_t &filename) noexcept
{
#ifdef _WIN32
# ifdef SPDLOG_WCHAR_FILENAMES
@@ -206,7 +206,7 @@ namespace os {
#endif
// Return file size according to open FILE* object
size_t filesize(FILE *f)
size_t filesize(FILE *f)
{
if (f == nullptr)
{
@@ -260,7 +260,7 @@ namespace os {
#endif
// Return utc offset in minutes or throw spdlog_ex on failure
int utc_minutes_offset(const std::tm &tm)
int utc_minutes_offset(const std::tm &tm)
{
#ifdef _WIN32
@@ -328,7 +328,7 @@ namespace os {
// Return current thread id as size_t
// It exists because the std::this_thread::get_id() is much slower(especially
// under VS 2013)
size_t _thread_id() noexcept
size_t _thread_id() noexcept
{
#ifdef _WIN32
return static_cast<size_t>(::GetCurrentThreadId());
@@ -377,7 +377,7 @@ namespace os {
}
// Return current thread id as size_t (from thread local storage)
size_t thread_id() noexcept
size_t thread_id() noexcept
{
// cache thread id in tls
static thread_local const size_t tid = _thread_id();
@@ -386,7 +386,7 @@ namespace os {
// This is avoid msvc issue in sleep_for that happens if the clock changes.
// See https://github.com/gabime/spdlog/issues/609
void sleep_for_millis(unsigned int milliseconds) noexcept
void sleep_for_millis(unsigned int milliseconds) noexcept
{
#if defined(_WIN32)
::Sleep(milliseconds);
@@ -397,20 +397,20 @@ namespace os {
// wchar support for windows file names (SPDLOG_WCHAR_FILENAMES must be defined)
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
std::string filename_to_str(const filename_t &filename)
std::string filename_to_str(const filename_t &filename)
{
memory_buf_t buf;
wstr_to_utf8buf(filename, buf);
return SPDLOG_BUF_TO_STRING(buf);
}
#else
std::string filename_to_str(const filename_t &filename)
std::string filename_to_str(const filename_t &filename)
{
return filename;
}
#endif
int pid() noexcept
int pid() noexcept
{
#ifdef _WIN32
@@ -422,7 +422,7 @@ namespace os {
// Determine if the terminal supports colors
// Based on: https://github.com/agauniyal/rang/
bool is_color_terminal() noexcept
bool is_color_terminal() noexcept
{
#ifdef _WIN32
return true;
@@ -453,7 +453,7 @@ namespace os {
// Determine if the terminal attached
// Source: https://github.com/agauniyal/rang/
bool in_terminal(FILE *file) noexcept
bool in_terminal(FILE *file) noexcept
{
#ifdef _WIN32
@@ -464,7 +464,7 @@ namespace os {
}
#if defined(SPDLOG_WCHAR_FILENAMES) && defined(_WIN32)
void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target)
void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target)
{
if (wstr.size() > static_cast<size_t>((std::numeric_limits<int>::max)()) / 2 - 1)
{
@@ -499,7 +499,7 @@ namespace os {
throw_spdlog_ex(fmt_lib::format("WideCharToMultiByte failed. Last error: {}", ::GetLastError()));
}
void utf8_to_wstrbuf(string_view_t str, wmemory_buf_t &target)
void utf8_to_wstrbuf(string_view_t str, wmemory_buf_t &target)
{
if (str.size() > static_cast<size_t>((std::numeric_limits<int>::max)()) - 1)
{
@@ -532,7 +532,7 @@ namespace os {
#endif // defined(SPDLOG_WCHAR_FILENAMES) && defined(_WIN32)
// return true on success
static bool mkdir_(const filename_t &path)
static bool mkdir_(const filename_t &path)
{
#ifdef _WIN32
# ifdef SPDLOG_WCHAR_FILENAMES
@@ -547,7 +547,7 @@ static bool mkdir_(const filename_t &path)
// create the given directory - and all directories leading to it
// return true on success or if the directory already exists
bool create_dir(const filename_t &path)
bool create_dir(const filename_t &path)
{
if (path_exists(path))
{
@@ -586,13 +586,13 @@ static bool mkdir_(const filename_t &path)
// "abc/" => "abc"
// "abc" => ""
// "abc///" => "abc//"
filename_t dir_name(const filename_t &path)
filename_t dir_name(const filename_t &path)
{
auto pos = path.find_last_of(folder_seps_filename);
return pos != filename_t::npos ? path.substr(0, pos) : filename_t{};
}
std::string getenv(const char *field)
std::string getenv(const char *field)
{
#if defined(_MSC_VER)
@@ -612,7 +612,7 @@ std::string getenv(const char *field)
// Do fsync by FILE handlerpointer
// Return true on success
bool fsync(FILE *fp)
bool fsync(FILE *fp)
{
#ifdef _WIN32
return FlushFileBuffers(reinterpret_cast<HANDLE>(_get_osfhandle(_fileno(fp)))) != 0;