Skip to content

Commit

Permalink
feat: add version formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
qudix committed Oct 1, 2023
1 parent 0c58531 commit 3dd761a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions CommonLibSF/include/REL/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -147,3 +147,18 @@ namespace REL

[[nodiscard]] std::optional<Version> get_file_version(stl::zwstring a_filename);
}

#ifdef __cpp_lib_format
namespace std
{
template<class CharT>
struct formatter<REL::Version, CharT> : formatter<std::string, CharT>
{
template<class FormatContext>
auto format(const REL::Version &a_version, FormatContext &a_ctx)
{
return formatter<std::string, CharT>::format(a_version.string(), a_ctx);
}
};
}
#endif

0 comments on commit 3dd761a

Please sign in to comment.