Implement a UID formatting function

This commit is contained in:
Robbert van der Helm
2020-12-17 14:20:49 +01:00
parent f71c7a3895
commit 78f9203378
3 changed files with 23 additions and 4 deletions
+17
View File
@@ -15,10 +15,27 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <cassert>
#include <iomanip>
#include <sstream>
#include <stdexcept>
#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
+5
View File
@@ -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?