Wrap event result data in an std::variant

Gets a bit more complicated this way, but this avoids having to use
string to manually serialize and deserialize arbitrary objects.

The new options for `AEffect` and `VstTimeInfo` structs are not yet
used.
This commit is contained in:
Robbert van der Helm
2020-03-11 15:52:56 +01:00
parent aa31665666
commit 1ee0ffef8b
6 changed files with 122 additions and 55 deletions
+16 -4
View File
@@ -185,7 +185,7 @@ void Logger::log_event(bool is_dispatch,
void Logger::log_event_response(bool is_dispatch,
intptr_t return_value,
std::optional<std::string> payload) {
const EventResposnePayload& payload) {
if (BOOST_UNLIKELY(verbosity >= Verbosity::events)) {
std::ostringstream message;
if (is_dispatch) {
@@ -195,9 +195,21 @@ void Logger::log_event_response(bool is_dispatch,
}
message << return_value;
if (payload.has_value()) {
message << ", \"" << payload.value() << "\"";
}
std::visit(
overload{[&](const std::monostate&) {},
[&](const std::string& s) {
if (s.size() < 32) {
message << ", \"" << s << "\"";
} else {
// Long strings contain binary data that we
// probably don't want to print
message << ", <" << s.size() << " bytes>";
}
},
[&](const AEffect&) { message << ", <AEffect_object>"; },
[&](const VstTimeInfo&) { message << ", <time_info>"; }},
payload);
log(message.str());
}