From fe20afac1740ce9d42b3fd648acc25b3452e2082 Mon Sep 17 00:00:00 2001 From: gabime Date: Sat, 21 Sep 2019 18:16:38 +0300 Subject: [PATCH] clang-format --- include/spdlog/details/circular_q.h | 6 +- include/spdlog/details/log_msg_buffer-inl.h | 82 +++++++++---------- include/spdlog/details/log_msg_buffer.h | 13 ++- include/spdlog/details/mpmc_blocking_q.h | 3 +- include/spdlog/details/os-inl.h | 12 +-- .../spdlog/details/pattern_formatter-inl.h | 4 +- include/spdlog/sinks/base_sink.h | 1 - tests/utils.cpp | 6 +- 8 files changed, 62 insertions(+), 65 deletions(-) diff --git a/include/spdlog/details/circular_q.h b/include/spdlog/details/circular_q.h index d937b4f5..fee3a3bf 100644 --- a/include/spdlog/details/circular_q.h +++ b/include/spdlog/details/circular_q.h @@ -62,12 +62,12 @@ public: // Return reference to the front item. // If there are no elements in the container, the behavior is undefined. - const T& front() const + const T &front() const { return v_[head_]; } - T& front() + T &front() { return v_[head_]; } @@ -87,7 +87,7 @@ public: bool full() const { // head is ahead of the tail by 1 - if(max_items_ > 0) + if (max_items_ > 0) { return ((tail_ + 1) % max_items_) == head_; } diff --git a/include/spdlog/details/log_msg_buffer-inl.h b/include/spdlog/details/log_msg_buffer-inl.h index 0b1bc958..c8b9e5ef 100644 --- a/include/spdlog/details/log_msg_buffer-inl.h +++ b/include/spdlog/details/log_msg_buffer-inl.h @@ -10,51 +10,51 @@ namespace spdlog { namespace details { - SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg &orig_msg) - : log_msg{orig_msg} - { - buffer.append(logger_name.begin(), logger_name.end()); - buffer.append(payload.begin(), payload.end()); - update_string_views(); - } - - SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg_buffer &other) - : log_msg{other} - { - buffer.append(logger_name.begin(), logger_name.end()); - buffer.append(payload.begin(), payload.end()); - update_string_views(); - } +SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg &orig_msg) + : log_msg{orig_msg} +{ + buffer.append(logger_name.begin(), logger_name.end()); + buffer.append(payload.begin(), payload.end()); + update_string_views(); +} - SPDLOG_INLINE log_msg_buffer:: log_msg_buffer(log_msg_buffer &&other) - : log_msg{std::move(other)} - , buffer{std::move(other.buffer)} - { - update_string_views(); - } +SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg_buffer &other) + : log_msg{other} +{ + buffer.append(logger_name.begin(), logger_name.end()); + buffer.append(payload.begin(), payload.end()); + update_string_views(); +} - SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(const log_msg_buffer &other) - { - log_msg::operator=(other); - buffer.clear(); - buffer.append(other.buffer.data(), other.buffer.data() + other.buffer.size()); - update_string_views(); - return *this; - } +SPDLOG_INLINE log_msg_buffer::log_msg_buffer(log_msg_buffer &&other) + : log_msg{std::move(other)} + , buffer{std::move(other.buffer)} +{ + update_string_views(); +} - SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(log_msg_buffer &&other) - { - log_msg::operator=(std::move(other)); - buffer = std::move(other.buffer); - update_string_views(); - return *this; - } +SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(const log_msg_buffer &other) +{ + log_msg::operator=(other); + buffer.clear(); + buffer.append(other.buffer.data(), other.buffer.data() + other.buffer.size()); + update_string_views(); + return *this; +} - SPDLOG_INLINE void log_msg_buffer::update_string_views() - { - logger_name = string_view_t{buffer.data(), logger_name.size()}; - payload = string_view_t{buffer.data()+logger_name.size(), payload.size()}; - } +SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(log_msg_buffer &&other) +{ + log_msg::operator=(std::move(other)); + buffer = std::move(other.buffer); + update_string_views(); + return *this; +} + +SPDLOG_INLINE void log_msg_buffer::update_string_views() +{ + logger_name = string_view_t{buffer.data(), logger_name.size()}; + payload = string_view_t{buffer.data() + logger_name.size(), payload.size()}; +} } // namespace details } // namespace spdlog diff --git a/include/spdlog/details/log_msg_buffer.h b/include/spdlog/details/log_msg_buffer.h index 8f74af25..5ddcbc10 100644 --- a/include/spdlog/details/log_msg_buffer.h +++ b/include/spdlog/details/log_msg_buffer.h @@ -14,15 +14,15 @@ namespace details { class log_msg_buffer : public log_msg { memory_buf_t buffer; - void update_string_views(); + void update_string_views(); + public: log_msg_buffer() = default; - explicit log_msg_buffer(const log_msg &orig_msg); - log_msg_buffer(const log_msg_buffer &other); - log_msg_buffer(log_msg_buffer &&other); - log_msg_buffer &operator=(const log_msg_buffer &other); + explicit log_msg_buffer(const log_msg &orig_msg); + log_msg_buffer(const log_msg_buffer &other); + log_msg_buffer(log_msg_buffer &&other); + log_msg_buffer &operator=(const log_msg_buffer &other); log_msg_buffer &operator=(log_msg_buffer &&other); - }; } // namespace details @@ -31,4 +31,3 @@ public: #ifdef SPDLOG_HEADER_ONLY #include "log_msg_buffer-inl.h" #endif - diff --git a/include/spdlog/details/mpmc_blocking_q.h b/include/spdlog/details/mpmc_blocking_q.h index 06b53738..397cd56c 100644 --- a/include/spdlog/details/mpmc_blocking_q.h +++ b/include/spdlog/details/mpmc_blocking_q.h @@ -70,7 +70,7 @@ public: // apparently mingw deadlocks if the mutex is released before cv.notify_one(), // so release the mutex at the very end each function. - // try to enqueue and block if no room left + // try to enqueue and block if no room left void enqueue(T &&item) { std::unique_lock lock(queue_mutex_); @@ -85,7 +85,6 @@ public: std::unique_lock lock(queue_mutex_); q_.push_back(std::move(item)); push_cv_.notify_one(); - } // try to dequeue item. if no item found. wait upto timeout and try again diff --git a/include/spdlog/details/os-inl.h b/include/spdlog/details/os-inl.h index d510d2ac..01a8afd7 100644 --- a/include/spdlog/details/os-inl.h +++ b/include/spdlog/details/os-inl.h @@ -51,16 +51,16 @@ #include //Use gettid() syscall under linux to get thread id #elif defined(_AIX) -#include // for pthread_getthreadid_np +#include // for pthread_getthreadid_np #elif defined(__DragonFly__) || defined(__FreeBSD__) -#include // for pthread_getthreadid_np +#include // for pthread_getthreadid_np #elif defined(__NetBSD__) -#include // for _lwp_self +#include // for _lwp_self #elif defined(__sun) -#include // for thr_self +#include // for thr_self #endif #endif // unix @@ -396,8 +396,8 @@ SPDLOG_INLINE bool is_color_terminal() SPDLOG_NOEXCEPT #ifdef _WIN32 return true; #else - static constexpr std::array Terms = {{ - "ansi", "color", "console", "cygwin", "gnome", "konsole", "kterm", "linux", "msys", "putty", "rxvt", "screen", "vt100", "xterm"}}; + static constexpr std::array Terms = { + {"ansi", "color", "console", "cygwin", "gnome", "konsole", "kterm", "linux", "msys", "putty", "rxvt", "screen", "vt100", "xterm"}}; const char *env_p = std::getenv("TERM"); if (env_p == nullptr) diff --git a/include/spdlog/details/pattern_formatter-inl.h b/include/spdlog/details/pattern_formatter-inl.h index 4b9c0ce3..06a3dcd1 100644 --- a/include/spdlog/details/pattern_formatter-inl.h +++ b/include/spdlog/details/pattern_formatter-inl.h @@ -209,8 +209,8 @@ public: }; // Full month name -static const std::array full_months{{ - "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}}; +static const std::array full_months{ + {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}}; template class B_formatter : public flag_formatter diff --git a/include/spdlog/sinks/base_sink.h b/include/spdlog/sinks/base_sink.h index 33223a57..be3956a7 100644 --- a/include/spdlog/sinks/base_sink.h +++ b/include/spdlog/sinks/base_sink.h @@ -13,7 +13,6 @@ #include "spdlog/details/log_msg.h" #include "spdlog/sinks/sink.h" - namespace spdlog { namespace sinks { template diff --git a/tests/utils.cpp b/tests/utils.cpp index fdb098b7..6c7f3662 100644 --- a/tests/utils.cpp +++ b/tests/utils.cpp @@ -77,15 +77,15 @@ std::size_t count_files(const std::string &folder) { size_t counter = 0; WIN32_FIND_DATA ffd; - + // Start iterating over the files in the folder directory. HANDLE hFind = ::FindFirstFileA((folder + "\\*").c_str(), &ffd); if (hFind != INVALID_HANDLE_VALUE) { do // Managed to locate and create an handle to that folder. { - if (ffd.cFileName[0] != '.') - counter++; + if (ffd.cFileName[0] != '.') + counter++; } while (::FindNextFile(hFind, &ffd) != 0); ::FindClose(hFind); }