mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Add a string representation for universal tresult
This commit is contained in:
@@ -63,9 +63,7 @@ void Vst3Logger::log_response(
|
||||
<< ">";
|
||||
},
|
||||
[&](const UniversalTResult& code) {
|
||||
// TODO: Add a `UniversalTResult::string()` for
|
||||
// the human readable representation
|
||||
message << code.native();
|
||||
message << code.string();
|
||||
}},
|
||||
result);
|
||||
});
|
||||
|
||||
@@ -55,6 +55,39 @@ tresult UniversalTResult::native() const {
|
||||
}
|
||||
}
|
||||
|
||||
std::string UniversalTResult::string() const {
|
||||
static_assert(Steinberg::kResultOk == Steinberg::kResultTrue);
|
||||
switch (universal_result) {
|
||||
case Value::kNoInterface:
|
||||
return "kNoInterface";
|
||||
break;
|
||||
case Value::kResultOk:
|
||||
return "kResultOk";
|
||||
break;
|
||||
case Value::kResultFalse:
|
||||
return "kResultFalse";
|
||||
break;
|
||||
case Value::kInvalidArgument:
|
||||
return "kInvalidArgument";
|
||||
break;
|
||||
case Value::kNotImplemented:
|
||||
return "kNotImplemented";
|
||||
break;
|
||||
case Value::kInternalError:
|
||||
return "kInternalError";
|
||||
break;
|
||||
case Value::kNotInitialized:
|
||||
return "kNotInitialized";
|
||||
break;
|
||||
case Value::kOutOfMemory:
|
||||
return "kOutOfMemory";
|
||||
break;
|
||||
default:
|
||||
return "<invalid>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
UniversalTResult::Value UniversalTResult::to_universal_result(
|
||||
tresult native_result) {
|
||||
static_assert(Steinberg::kResultOk == Steinberg::kResultTrue);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
#include <pluginterfaces/base/ftypes.h>
|
||||
#include <pluginterfaces/base/funknown.h>
|
||||
@@ -68,6 +69,11 @@ class UniversalTResult {
|
||||
*/
|
||||
tresult native() const;
|
||||
|
||||
/**
|
||||
* Get the original name for the result, e.g. `kResultOk`.
|
||||
*/
|
||||
std::string string() const;
|
||||
|
||||
template <typename S>
|
||||
void serialize(S& s) {
|
||||
s.value4b(universal_result);
|
||||
|
||||
Reference in New Issue
Block a user