WiiUPluginLoaderBackend/source/plugin/PluginDataPersistence.cpp

35 lines
1.3 KiB
C++
Raw Normal View History

2021-12-15 17:09:30 +01:00
#include <memory>
2020-12-26 14:17:50 +01:00
#include "../common/plugin_defines.h"
2020-05-17 20:45:10 +02:00
#include "PluginDataPersistence.h"
2021-12-15 17:09:30 +01:00
bool PluginDataPersistence::save(plugin_data_t *pluginDataStruct, const std::shared_ptr<PluginData> &plugin) {
2020-12-26 14:17:50 +01:00
if (pluginDataStruct == nullptr) {
2020-05-17 20:45:10 +02:00
return false;
}
2021-12-15 17:09:30 +01:00
pluginDataStruct->buffer = (char *) plugin->buffer;
pluginDataStruct->bufferLength = plugin->length;
pluginDataStruct->memoryType = plugin->memoryType;
pluginDataStruct->heapHandle = (int) plugin->heapHandle;
2020-05-17 20:45:10 +02:00
return true;
}
2021-12-15 17:09:30 +01:00
bool PluginDataPersistence::save(plugin_data_t *pluginDataStruct, PluginData* plugin) {
if (pluginDataStruct == nullptr) {
return false;
}
pluginDataStruct->buffer = (char *) plugin->buffer;
pluginDataStruct->bufferLength = plugin->length;
pluginDataStruct->memoryType = plugin->memoryType;
pluginDataStruct->heapHandle = (int) plugin->heapHandle;
return true;
}
std::shared_ptr<PluginData> PluginDataPersistence::load(plugin_data_t *pluginDataStruct) {
auto pluginData = std::make_shared<PluginData>();
2020-05-17 20:45:10 +02:00
2021-12-15 17:09:30 +01:00
pluginData->buffer = pluginDataStruct->buffer;
pluginData->length = pluginDataStruct->bufferLength;
pluginData->memoryType = (eMemoryTypes) pluginDataStruct->memoryType;
pluginData->heapHandle = (MEMHeapHandle) pluginDataStruct->heapHandle;
2020-05-17 20:45:10 +02:00
return pluginData;
}