2023-10-07 22:38:27 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "StorageItem.h"
|
2024-11-27 20:44:36 +01:00
|
|
|
|
|
|
|
#include <forward_list>
|
2023-10-07 22:38:27 +02:00
|
|
|
#include <map>
|
2024-11-27 20:44:36 +01:00
|
|
|
#include <string>
|
2023-10-07 22:38:27 +02:00
|
|
|
#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,
|
|
|
|
};
|
|
|
|
|
2024-11-27 20:44:36 +01:00
|
|
|
explicit StorageSubItem(std::string_view 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);
|
|
|
|
|
2024-11-27 20:44:36 +01:00
|
|
|
StorageItem *createItem(const char *key, StorageSubItemError &error);
|
2023-10-07 22:38:27 +02:00
|
|
|
|
2024-11-27 20:44:36 +01:00
|
|
|
StorageSubItem *createSubItem(const char *key, StorageSubItemError &error);
|
2023-10-07 22:38:27 +02:00
|
|
|
|
|
|
|
StorageItem *getItem(const char *name);
|
|
|
|
|
2024-11-27 20:44:36 +01:00
|
|
|
[[nodiscard]] const std::forward_list<StorageSubItem> &getSubItems() const;
|
2023-10-07 22:38:27 +02:00
|
|
|
|
2024-11-27 20:44:36 +01:00
|
|
|
[[nodiscard]] const std::map<std::string, StorageItem> &getItems() const;
|
2023-10-07 22:38:27 +02:00
|
|
|
|
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
|
|
|
};
|