From dab2cb8fafbc57e81cbbc494bb4e98ac17b27be0 Mon Sep 17 00:00:00 2001 From: zzyyyl Date: Fri, 26 Aug 2022 21:17:40 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E6=8C=89=E7=85=A7=20review=20?= =?UTF-8?q?=E6=84=8F=E8=A7=81=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Horror Proton <107091537+horror-proton@users.noreply.github.com> --- .clang-format | 2 +- src/MeoAssistant/AsstInfrastDef.h | 3 ++- src/MeoAssistant/AsstTypes.h | 9 ++++++--- src/MeoAssistant/AsstUtils.hpp | 12 +++++++---- src/MeoAssistant/Logger.hpp | 33 ++++++++++++++++++++----------- 5 files changed, 39 insertions(+), 20 deletions(-) diff --git a/.clang-format b/.clang-format index ecf8eadc42..df3c3b9645 100644 --- a/.clang-format +++ b/.clang-format @@ -21,7 +21,7 @@ AllowShortLoopsOnASingleLine: false AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: MultiLine +AlwaysBreakTemplateDeclarations: true AttributeMacros: - __capability BinPackArguments: true diff --git a/src/MeoAssistant/AsstInfrastDef.h b/src/MeoAssistant/AsstInfrastDef.h index e34c6020ea..18cf902ad8 100644 --- a/src/MeoAssistant/AsstInfrastDef.h +++ b/src/MeoAssistant/AsstInfrastDef.h @@ -51,7 +51,8 @@ namespace asst::infrast namespace std { - template <> struct hash + template <> + struct hash { size_t operator()(const asst::infrast::Skill& skill) const noexcept { diff --git a/src/MeoAssistant/AsstTypes.h b/src/MeoAssistant/AsstTypes.h index 20cf6cdaa6..d289dc99cd 100644 --- a/src/MeoAssistant/AsstTypes.h +++ b/src/MeoAssistant/AsstTypes.h @@ -197,7 +197,8 @@ namespace asst namespace std { - template <> struct hash + template <> + struct hash { size_t operator()(const asst::Point& point) const noexcept { @@ -205,7 +206,8 @@ namespace std } }; - template <> struct hash + template <> + struct hash { size_t operator()(const asst::Rect& rect) const noexcept { @@ -213,7 +215,8 @@ namespace std std::hash()(rect.height); } }; - template <> struct hash + template <> + struct hash { size_t operator()(const asst::TextRect& tr) const noexcept { diff --git a/src/MeoAssistant/AsstUtils.hpp b/src/MeoAssistant/AsstUtils.hpp index 8df9947f96..b895d7b957 100644 --- a/src/MeoAssistant/AsstUtils.hpp +++ b/src/MeoAssistant/AsstUtils.hpp @@ -109,7 +109,8 @@ namespace asst::utils return buff; } - template inline std::string ansi_to_utf8(const std::string& ansi_str) + template + inline std::string ansi_to_utf8(const std::string& ansi_str) { #ifdef _WIN32 const char* src_str = ansi_str.c_str(); @@ -138,7 +139,8 @@ namespace asst::utils #endif } - template inline std::string utf8_to_ansi(const std::string& utf8_str) + template + inline std::string utf8_to_ansi(const std::string& utf8_str) { #ifdef _WIN32 const char* src_str = utf8_str.c_str(); @@ -167,7 +169,8 @@ namespace asst::utils #endif } - template inline std::string utf8_to_unicode_escape(const std::string& utf8_str) + template + inline std::string utf8_to_unicode_escape(const std::string& utf8_str) { #ifdef _WIN32 const char* src_str = utf8_str.c_str(); @@ -203,7 +206,8 @@ namespace asst::utils #endif } - template constexpr inline RetTy make_rect(const ArgType& rect) + template + constexpr inline RetTy make_rect(const ArgType& rect) { return RetTy { rect.x, rect.y, rect.width, rect.height }; } diff --git a/src/MeoAssistant/Logger.hpp b/src/MeoAssistant/Logger.hpp index 2b05e7e135..667cc30834 100644 --- a/src/MeoAssistant/Logger.hpp +++ b/src/MeoAssistant/Logger.hpp @@ -40,7 +40,8 @@ namespace asst return true; } - template inline void debug([[maybe_unused]] Args&&... args) + template + inline void debug([[maybe_unused]] Args&&... args) { #ifdef ASST_DEBUG std::string_view level = "DEB"; @@ -48,27 +49,32 @@ namespace asst #endif } - template inline void trace(Args&&... args) + template + inline void trace(Args&&... args) { std::string_view level = "TRC"; log(level, std::forward(args)...); } - template inline void info(Args&&... args) + template + inline void info(Args&&... args) { std::string_view level = "INF"; log(level, std::forward(args)...); } - template inline void warn(Args&&... args) + template + inline void warn(Args&&... args) { std::string_view level = "WRN"; log(level, std::forward(args)...); } - template inline void error(Args&&... args) + template + inline void error(Args&&... args) { std::string_view level = "ERR"; log(level, std::forward(args)...); } - template inline void log_with_custom_level(std::string_view level, Args&&... args) + template + inline void log_with_custom_level(std::string_view level, Args&&... args) { log(level, std::forward(args)...); } @@ -118,7 +124,8 @@ namespace asst trace("-----------------------------"); } - template void log(std::string_view level, Args&&... args) + template + void log(std::string_view level, Args&&... args) { std::unique_lock trace_lock(m_trace_mutex); @@ -161,7 +168,8 @@ namespace asst : std::true_type {}; - template static Stream& stream_put(Stream& s, T&& v) + template + static Stream& stream_put(Stream& s, T&& v) { if constexpr (std::is_constructible_v) { if constexpr (ToAnsi) @@ -195,9 +203,11 @@ namespace asst } } - template struct stream_put_line_impl; + template + struct stream_put_line_impl; - template struct stream_put_line_impl + template + struct stream_put_line_impl { static constexpr Stream& apply(Stream& s) { @@ -206,7 +216,8 @@ namespace asst } }; - template struct stream_put_line_impl + template + struct stream_put_line_impl { static constexpr Stream& apply(Stream& s, Only&& only) {