1#ifndef YAZE_APP_PLATFORM_WASM_WASM_STORAGE_H_
2#define YAZE_APP_PLATFORM_WASM_WASM_STORAGE_H_
11#include "absl/status/status.h"
12#include "absl/status/statusor.h"
13#include "nlohmann/json.hpp"
38 static absl::Status SaveRom(
const std::string& name,
39 const std::vector<uint8_t>& data);
46 static absl::StatusOr<std::vector<uint8_t>> LoadRom(
const std::string& name);
53 static absl::Status DeleteRom(
const std::string& name);
59 static std::vector<std::string> ListRoms();
70 static absl::Status SaveProject(
const std::string& name,
71 const std::string& json,
72 bool replace_existing =
true);
79 static absl::StatusOr<std::string> LoadProject(
const std::string& name);
86 static absl::Status DeleteProject(
const std::string& name);
92 static std::vector<std::string> ListProjects();
101 static absl::Status SavePreferences(
const nlohmann::json& prefs);
107 static absl::StatusOr<nlohmann::json> LoadPreferences();
113 static absl::Status ClearPreferences();
121 static absl::StatusOr<size_t> GetStorageUsage();
127 static bool IsStorageAvailable();
133 static absl::Status Initialize();
137 static constexpr const char* kDatabaseName =
"YazeStorage";
138 static constexpr int kDatabaseVersion = 1;
139 static constexpr const char* kRomStoreName =
"roms";
140 static constexpr const char* kProjectStoreName =
"projects";
141 static constexpr const char* kPreferencesStoreName =
"preferences";
142 static constexpr const char* kPreferencesKey =
"user_preferences";
146 bool completed =
false;
147 bool success =
false;
148 std::string error_message;
149 std::vector<uint8_t> binary_data;
150 std::string string_data;
151 std::vector<std::string> string_list;
155 static void EnsureInitialized();
158 static bool IsWebContext();
161 static std::atomic<bool> initialized_;