From 3dd761a5ec933d313ba83a5100293ca75f0dcc76 Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Sat, 30 Sep 2023 21:33:08 -0500 Subject: [PATCH] feat: add version formatter --- CommonLibSF/include/REL/Version.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/CommonLibSF/include/REL/Version.h b/CommonLibSF/include/REL/Version.h index 7c945a7a..b32a828a 100644 --- a/CommonLibSF/include/REL/Version.h +++ b/CommonLibSF/include/REL/Version.h @@ -55,7 +55,7 @@ namespace REL [[nodiscard]] constexpr value_type patch() const noexcept { return _impl[2]; } [[nodiscard]] constexpr value_type build() const noexcept { return _impl[3]; } - [[nodiscard]] std::string string(std::string_view a_separator = "-"sv) const + [[nodiscard]] std::string string(std::string_view a_separator = "."sv) const { std::string result; for (auto&& ver : _impl) { @@ -66,7 +66,7 @@ namespace REL return result; } - [[nodiscard]] std::wstring wstring(std::wstring_view a_separator = L"-"sv) const + [[nodiscard]] std::wstring wstring(std::wstring_view a_separator = L"."sv) const { std::wstring result; for (auto&& ver : _impl) { @@ -147,3 +147,18 @@ namespace REL [[nodiscard]] std::optional get_file_version(stl::zwstring a_filename); } + +#ifdef __cpp_lib_format +namespace std +{ + template + struct formatter : formatter + { + template + auto format(const REL::Version &a_version, FormatContext &a_ctx) + { + return formatter::format(a_version.string(), a_ctx); + } + }; +} +#endif