From 154ebea202d64669143ee6bb33f6327d141343c3 Mon Sep 17 00:00:00 2001 From: saturneric Date: Sun, 3 Mar 2024 02:48:44 +0800 Subject: refactor: reduce core prebuild headers and isolate core to modules --- .../version_checking_module/SoftwareVersion.cpp | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/module/integrated/version_checking_module/SoftwareVersion.cpp') diff --git a/src/module/integrated/version_checking_module/SoftwareVersion.cpp b/src/module/integrated/version_checking_module/SoftwareVersion.cpp index 4e1c2dfa..cd864195 100644 --- a/src/module/integrated/version_checking_module/SoftwareVersion.cpp +++ b/src/module/integrated/version_checking_module/SoftwareVersion.cpp @@ -31,6 +31,44 @@ #include #include #include +#include + +#include + +template <> +struct fmt::formatter { + // Parses format specifications. + constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + return ctx.begin(); + } + + // Formats the QString qstr and writes it to the output. + template + auto format(const QString& qstr, FormatContext& ctx) const + -> decltype(ctx.out()) { + // Convert QString to UTF-8 QString (to handle Unicode characters + // correctly) + QByteArray utf8_array = qstr.toUtf8(); + return fmt::format_to(ctx.out(), "{}", utf8_array.constData()); + } +}; + +template <> +struct fmt::formatter { + // Parses format specifications. + constexpr auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { + return ctx.begin(); + } + + // Formats the QString qstr and writes it to the output. + template + auto format(const QByteArray& qarray, FormatContext& ctx) const + -> decltype(ctx.out()) { + // Convert QString to UTF-8 QString (to handle Unicode characters + // correctly) + return fmt::format_to(ctx.out(), "{}", qarray.constData()); + } +}; auto SoftwareVersion::NeedUpgrade() const -> bool { GFModuleLogDebug( -- cgit v1.2.3