2022-02-04 16:25:44 +01:00
|
|
|
#include "WUPSConfigItem.h"
|
2021-04-07 00:23:23 +02:00
|
|
|
#include <wums.h>
|
|
|
|
#include <wups/config.h>
|
|
|
|
|
|
|
|
typedef uint32_t WUPSConfigItemHandle;
|
|
|
|
|
2021-09-25 14:26:18 +02:00
|
|
|
int32_t WUPSConfigItem_Create(WUPSConfigItemHandle *out, const char *configID, const char *displayName, WUPSConfigCallbacks_t callbacks, void *context) {
|
2022-09-18 21:59:07 +02:00
|
|
|
if (out == nullptr || configID == nullptr || displayName == nullptr) {
|
2021-04-07 00:23:23 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
*out = (WUPSConfigItemHandle) new WUPSConfigItem(configID, displayName, callbacks, context);
|
|
|
|
if (*out != 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -2;
|
2021-09-25 14:26:18 +02:00
|
|
|
}
|
2021-04-07 00:23:23 +02:00
|
|
|
|
|
|
|
int32_t WUPSConfigItem_Destroy(WUPSConfigItemHandle handle) {
|
|
|
|
if (handle == 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto *config = reinterpret_cast<WUPSConfigItem *>(handle);
|
|
|
|
delete config;
|
|
|
|
return 0;
|
2021-09-25 14:26:18 +02:00
|
|
|
}
|
2021-04-07 00:23:23 +02:00
|
|
|
|
|
|
|
int32_t WUPSConfigItem_SetDisplayName(WUPSConfigItemHandle handle, const char *displayName) {
|
2022-09-18 21:59:07 +02:00
|
|
|
if (displayName == nullptr || handle == 0) {
|
2021-04-07 00:23:23 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto *config = reinterpret_cast<WUPSConfigItem *>(handle);
|
|
|
|
config->setDisplayName(displayName);
|
|
|
|
return 0;
|
2021-09-25 14:26:18 +02:00
|
|
|
}
|
2021-04-07 00:23:23 +02:00
|
|
|
|
|
|
|
int32_t WUPSConfigItem_GetDisplayName(WUPSConfigItemHandle handle, char *out_buf, int32_t out_len) {
|
2022-09-18 21:59:07 +02:00
|
|
|
if (out_buf == nullptr || handle == 0) {
|
2021-04-07 00:23:23 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
auto *config = reinterpret_cast<WUPSConfigItem *>(handle);
|
|
|
|
snprintf(out_buf, out_len, "%s", config->getDisplayName().c_str());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t WUPSConfigItem_SetConfigID(WUPSConfigItemHandle handle, const char *configID) {
|
2022-09-18 21:59:07 +02:00
|
|
|
if (configID == nullptr || handle == 0) {
|
2021-04-07 00:23:23 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto *config = reinterpret_cast<WUPSConfigItem *>(handle);
|
|
|
|
config->setConfigID(configID);
|
|
|
|
return 0;
|
2021-09-25 14:26:18 +02:00
|
|
|
}
|
2021-04-07 00:23:23 +02:00
|
|
|
|
|
|
|
int32_t WUPSConfigItem_GetConfigID(WUPSConfigItemHandle handle, char *out_buf, int32_t out_len) {
|
2022-09-18 21:59:07 +02:00
|
|
|
if (out_buf == nullptr || handle == 0) {
|
2021-04-07 00:23:23 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
auto *config = reinterpret_cast<WUPSConfigItem *>(handle);
|
|
|
|
snprintf(out_buf, out_len, "%s", config->getConfigID().c_str());
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSConfigItem_Create);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSConfigItem_Destroy);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSConfigItem_SetDisplayName);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSConfigItem_GetDisplayName);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSConfigItem_SetConfigID);
|
|
|
|
WUMS_EXPORT_FUNCTION(WUPSConfigItem_GetConfigID);
|