#ifndef SRC_NODE_WEBSTORAGE_H_ #define SRC_NODE_WEBSTORAGE_H_ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "base_object.h" #include "node_mem.h" #include "sqlite3.h" #include "util.h" namespace node { namespace webstorage { struct conn_deleter { void operator()(sqlite3* conn) const noexcept { CHECK_EQ(sqlite3_close(conn), SQLITE_OK); } }; using conn_unique_ptr = std::unique_ptr; struct stmt_deleter { void operator()(sqlite3_stmt* stmt) const noexcept { sqlite3_finalize(stmt); } }; using stmt_unique_ptr = std::unique_ptr; static constexpr std::string_view kInMemoryPath = ":memory:"; class Storage : public BaseObject { public: Storage(Environment* env, v8::Local object, std::string_view location); void MemoryInfo(MemoryTracker* tracker) const override; static void New(const v8::FunctionCallbackInfo& args); v8::Maybe Clear(); v8::MaybeLocal Enumerate(); v8::MaybeLocal Length(); v8::MaybeLocal Load(v8::Local key); v8::MaybeLocal LoadKey(const int index); v8::Maybe Remove(v8::Local key); v8::Maybe Store(v8::Local key, v8::Local value); SET_MEMORY_INFO_NAME(Storage) SET_SELF_SIZE(Storage) private: v8::Maybe Open(); ~Storage() override; std::string location_; conn_unique_ptr db_; v8::Global symbols_; }; } // namespace webstorage } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #endif // SRC_NODE_WEBSTORAGE_H_