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();
69 static absl::Status SaveProject(
const std::string& name,
70 const std::string& json);
77 static absl::StatusOr<std::string> LoadProject(
const std::string& name);
84 static absl::Status DeleteProject(
const std::string& name);
90 static std::vector<std::string> ListProjects();
99 static absl::Status SavePreferences(
const nlohmann::json& prefs);
105 static absl::StatusOr<nlohmann::json> LoadPreferences();
111 static absl::Status ClearPreferences();
119 static absl::StatusOr<size_t> GetStorageUsage();
125 static bool IsStorageAvailable();
131 static absl::Status Initialize();
135 static constexpr const char* kDatabaseName =
"YazeStorage";
136 static constexpr int kDatabaseVersion = 1;
137 static constexpr const char* kRomStoreName =
"roms";
138 static constexpr const char* kProjectStoreName =
"projects";
139 static constexpr const char* kPreferencesStoreName =
"preferences";
140 static constexpr const char* kPreferencesKey =
"user_preferences";
144 bool completed =
false;
145 bool success =
false;
146 std::string error_message;
147 std::vector<uint8_t> binary_data;
148 std::string string_data;
149 std::vector<std::string> string_list;
153 static void EnsureInitialized();
156 static bool IsWebContext();
159 static std::atomic<bool> initialized_;