From dcc6022f0950a31d2294228839d9bbe300b29562 Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Thu, 14 Nov 2024 16:46:00 -0600 Subject: [PATCH] feat: simplify formatter's --- include/REX/REX/INI.h | 37 +++++++------------------------------ include/REX/REX/JSON.h | 37 +++++++------------------------------ include/REX/REX/TOML.h | 37 +++++++------------------------------ 3 files changed, 21 insertions(+), 90 deletions(-) diff --git a/include/REX/REX/INI.h b/include/REX/REX/INI.h index 7db164efd..315dfb89e 100644 --- a/include/REX/REX/INI.h +++ b/include/REX/REX/INI.h @@ -88,36 +88,13 @@ namespace REX::INI using Str = Setting; } -namespace REX::INI::Impl +template +struct std::formatter, CharT> : std::formatter { -# ifdef __cpp_lib_format - template - struct formatter : std::formatter + template + auto format(const REX::INI::Setting& a_setting, FormatContext& a_ctx) const { - template - auto format(REX::INI::Setting a_setting, FormatContext& a_ctx) const - { - return std::formatter::format(a_setting.GetValue(), a_ctx); - } - }; -# endif -} - -# ifdef __cpp_lib_format -namespace std -{ - // clang-format off - template struct formatter, CharT> : REX::INI::Impl::formatter {}; - template struct formatter, CharT> : REX::INI::Impl::formatter {}; - template struct formatter, CharT> : REX::INI::Impl::formatter {}; - template struct formatter, CharT> : REX::INI::Impl::formatter {}; - template struct formatter, CharT> : REX::INI::Impl::formatter {}; - template struct formatter, CharT> : REX::INI::Impl::formatter {}; - template struct formatter, CharT> : REX::INI::Impl::formatter {}; - template struct formatter, CharT> : REX::INI::Impl::formatter {}; - template struct formatter, CharT> : REX::INI::Impl::formatter {}; - template struct formatter, CharT> : REX::INI::Impl::formatter {}; - // clang-format on -} -# endif + return std::formatter::format(a_setting.GetValue(), a_ctx); + } +}; #endif diff --git a/include/REX/REX/JSON.h b/include/REX/REX/JSON.h index d51c98267..14b2e4ae6 100644 --- a/include/REX/REX/JSON.h +++ b/include/REX/REX/JSON.h @@ -85,36 +85,13 @@ namespace REX::JSON using Str = Setting; } -namespace REX::JSON::Impl +template +struct std::formatter, CharT> : std::formatter { -# ifdef __cpp_lib_format - template - struct formatter : std::formatter + template + auto format(const REX::JSON::Setting& a_setting, FormatContext& a_ctx) const { - template - auto format(REX::JSON::Setting a_setting, FormatContext& a_ctx) const - { - return std::formatter::format(a_setting.GetValue(), a_ctx); - } - }; -# endif -} - -# ifdef __cpp_lib_format -namespace std -{ - // clang-format off - template struct formatter, CharT> : REX::JSON::Impl::formatter {}; - template struct formatter, CharT> : REX::JSON::Impl::formatter {}; - template struct formatter, CharT> : REX::JSON::Impl::formatter {}; - template struct formatter, CharT> : REX::JSON::Impl::formatter {}; - template struct formatter, CharT> : REX::JSON::Impl::formatter {}; - template struct formatter, CharT> : REX::JSON::Impl::formatter {}; - template struct formatter, CharT> : REX::JSON::Impl::formatter {}; - template struct formatter, CharT> : REX::JSON::Impl::formatter {}; - template struct formatter, CharT> : REX::JSON::Impl::formatter {}; - template struct formatter, CharT> : REX::JSON::Impl::formatter {}; - // clang-format on -} -# endif + return std::formatter::format(a_setting.GetValue(), a_ctx); + } +}; #endif diff --git a/include/REX/REX/TOML.h b/include/REX/REX/TOML.h index 21e03f47c..8516479f7 100644 --- a/include/REX/REX/TOML.h +++ b/include/REX/REX/TOML.h @@ -104,36 +104,13 @@ namespace REX::TOML using Str = Setting; } -namespace REX::TOML::Impl +template +struct std::formatter, CharT> : std::formatter { -# ifdef __cpp_lib_format - template - struct formatter : std::formatter + template + auto format(const REX::TOML::Setting& a_setting, FormatContext& a_ctx) const { - template - auto format(REX::TOML::Setting a_setting, FormatContext& a_ctx) const - { - return std::formatter::format(a_setting.GetValue(), a_ctx); - } - }; -# endif -} - -# ifdef __cpp_lib_format -namespace std -{ - // clang-format off - template struct formatter, CharT> : REX::TOML::Impl::formatter {}; - template struct formatter, CharT> : REX::TOML::Impl::formatter {}; - template struct formatter, CharT> : REX::TOML::Impl::formatter {}; - template struct formatter, CharT> : REX::TOML::Impl::formatter {}; - template struct formatter, CharT> : REX::TOML::Impl::formatter {}; - template struct formatter, CharT> : REX::TOML::Impl::formatter {}; - template struct formatter, CharT> : REX::TOML::Impl::formatter {}; - template struct formatter, CharT> : REX::TOML::Impl::formatter {}; - template struct formatter, CharT> : REX::TOML::Impl::formatter {}; - template struct formatter, CharT> : REX::TOML::Impl::formatter {}; - // clang-format on -} -# endif + return std::formatter::format(a_setting.GetValue(), a_ctx); + } +}; #endif