From 78f9203378fc2c7beb3e600064f99a8cd7bd6f2a Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 17 Dec 2020 14:20:49 +0100 Subject: [PATCH] Implement a UID formatting function --- src/common/logging/vst3.cpp | 5 +---- src/common/serialization/vst3/base.cpp | 17 +++++++++++++++++ src/common/serialization/vst3/base.h | 5 +++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/common/logging/vst3.cpp b/src/common/logging/vst3.cpp index 6d285400..7e02385a 100644 --- a/src/common/logging/vst3.cpp +++ b/src/common/logging/vst3.cpp @@ -24,10 +24,7 @@ void Vst3Logger::log_unknown_interface( const std::string& where, const std::optional& uid) { if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) { - char uid_string[128] = ""; - if (uid) { - uid->print(uid_string, Steinberg::FUID::UIDPrintStyle::kCLASS_UID); - } + std::string uid_string = uid ? format_uid(*uid) : ""; std::ostringstream message; message << "[unknown interface] " << where << ": " << uid_string; diff --git a/src/common/serialization/vst3/base.cpp b/src/common/serialization/vst3/base.cpp index d8f21041..a44c1719 100644 --- a/src/common/serialization/vst3/base.cpp +++ b/src/common/serialization/vst3/base.cpp @@ -15,10 +15,27 @@ // along with this program. If not, see . #include +#include +#include #include #include "base.h" +std::string format_uid(const Steinberg::FUID& uid) { + // This is the same as `FUID::print`, but without any macro prefixes + uint32 l1, l2, l3, l4; + uid.to4Int(l1, l2, l3, l4); + + std::ostringstream formatted_uid; + formatted_uid << std::hex << std::uppercase << "(0x" << std::setfill('0') + << std::setw(8) << l1 << ", 0x" << std::setfill('0') + << std::setw(8) << l2 << ", 0x" << std::setfill('0') + << std::setw(8) << l3 << ", 0x" << std::setfill('0') + << std::setw(8) << l4 << ")"; + + return formatted_uid.str(); +} + std::u16string tchar_pointer_to_u16string(const Steinberg::Vst::TChar* string) { #ifdef __WINE__ // This is great, thanks Steinberg diff --git a/src/common/serialization/vst3/base.h b/src/common/serialization/vst3/base.h index 97504639..8ee5c8b5 100644 --- a/src/common/serialization/vst3/base.h +++ b/src/common/serialization/vst3/base.h @@ -53,6 +53,11 @@ constexpr size_t max_num_speakers = 16384; */ constexpr size_t max_vector_stream_size = 50 << 20; +/** + * Format a FUID as a simple hexadecimal four-tuple. + */ +std::string format_uid(const Steinberg::FUID& uid); + /** * Convert a UTF-16 C-style string to an `std::u16string`. Who event invented * UTF-16?