lore-forge/desktop/gui/uhdk_imgui/UhdkPayload.hpp

16 lines
593 B
C++

#ifndef UHDK_EXAMPLE_PAYLOAD_HPP
#define UHDK_EXAMPLE_PAYLOAD_HPP
#include "uhdk.h"
#include <cassert>
// Call only after checking the event/request discriminator. References are borrowed.
template <typename T> const T &UhdkData(const uhdk_event &event) {
assert(event.data && event.data_size >= sizeof(T));
return *static_cast<const T *>(event.data);
}
template <typename T> const T &UhdkResult(const uhdk_request_result &result) {
assert(result.status == UHDK_STATUS_OK && result.data && result.data_size >= sizeof(T));
return *static_cast<const T *>(result.data);
}
#endif