36 lines
1.1 KiB
C++
Raw Normal View History

#include "PluginData.h"
2024-11-27 20:44:36 +01:00
PluginData::PluginData(std::vector<uint8_t> &&buffer, const std::string_view source) : mBuffer(std::move(buffer)), mSource(source) {
2024-12-18 16:11:14 +01:00
// Abuse this as a stable handle that references itself and survives std::move
*mHandle = reinterpret_cast<uint32_t>(mHandle.get());
2024-11-27 20:44:36 +01:00
}
2024-12-18 16:11:14 +01:00
PluginData::PluginData(std::span<uint8_t> buffer, const std::string_view source) : PluginData(std::vector(buffer.begin(), buffer.end()), source) {
2024-11-27 20:44:36 +01:00
}
PluginData::PluginData(PluginData &&src) : mBuffer(std::move(src.mBuffer)),
2024-12-18 16:11:14 +01:00
mSource(std::move(src.mSource)),
mHandle(std::move(src.mHandle)) {
2024-11-27 20:44:36 +01:00
}
PluginData &PluginData::operator=(PluginData &&src) noexcept {
if (this != &src) {
this->mBuffer = std::move(src.mBuffer);
this->mSource = std::move(src.mSource);
2024-12-18 16:11:14 +01:00
this->mHandle = std::move(src.mHandle);
2024-11-27 20:44:36 +01:00
}
return *this;
}
uint32_t PluginData::getHandle() const {
2024-12-18 16:11:14 +01:00
return *mHandle;
}
std::span<const uint8_t> PluginData::getBuffer() const {
return mBuffer;
}
const std::string &PluginData::getSource() const {
return mSource;
}