WiiUPluginLoaderBackend/source/utils/storage/StorageSubItem.h

47 lines
1.2 KiB
C
Raw Permalink Normal View History

2023-10-07 22:38:27 +02:00
#pragma once
#include "StorageItem.h"
#include "utils/utils.h"
#include <map>
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include <wups/storage.h>
class StorageSubItem : public StorageItem {
public:
enum StorageSubItemError {
STORAGE_SUB_ITEM_ERROR_NONE = 0,
STORAGE_SUB_ITEM_ERROR_MALLOC_FAILED = 1,
STORAGE_SUB_ITEM_KEY_ALREADY_IN_USE = 2,
};
2023-12-16 12:44:20 +01:00
explicit StorageSubItem(std::string_view key) : StorageItem(key) {
2023-10-07 22:38:27 +02:00
}
2023-12-16 12:44:20 +01:00
StorageSubItem *getSubItem(wups_storage_item item);
2023-10-07 22:38:27 +02:00
const StorageSubItem *getSubItem(const char *key) const;
bool deleteItem(const char *key);
StorageItem *createItem(const char *key, StorageSubItem::StorageSubItemError &error);
StorageSubItem *createSubItem(const char *key, StorageSubItem::StorageSubItemError &error);
StorageItem *getItem(const char *name);
2023-12-16 12:44:20 +01:00
[[nodiscard]] const std::forward_list<StorageSubItem> &getSubItems() const {
2023-10-07 22:38:27 +02:00
return mSubCategories;
}
2023-12-16 12:44:20 +01:00
[[nodiscard]] const std::map<std::string, StorageItem> &getItems() const {
2023-10-07 22:38:27 +02:00
return mItems;
}
2023-12-16 12:44:20 +01:00
protected:
std::forward_list<StorageSubItem> mSubCategories;
std::map<std::string, StorageItem> mItems;
2023-10-07 22:38:27 +02:00
};