/* * Copyright (c) 2024, stelar7 * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace Web::IndexedDB { // https://w3c.github.io/IndexedDB/#index-interface class IDBIndex : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(IDBIndex, Bindings::PlatformObject); GC_DECLARE_ALLOCATOR(IDBIndex); public: virtual ~IDBIndex() override; [[nodiscard]] static GC::Ref create(JS::Realm&, GC::Ref, GC::Ref); WebIDL::ExceptionOr set_name(String const& value); String name() const { return m_name; } GC::Ref object_store() { return m_object_store_handle; } JS::Value key_path() const; bool multi_entry() const { return m_index->multi_entry(); } bool unique() const { return m_index->unique(); } // The transaction of an index handle is the transaction of its associated object store handle. GC::Ref transaction() { return m_object_store_handle->transaction(); } GC::Ref index() { return m_index; } HTML::SerializationRecord get_referenced_value(IndexRecord const& index_record) const; protected: explicit IDBIndex(JS::Realm&, GC::Ref, GC::Ref); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Visitor& visitor) override; private: // An index handle has an associated index and an associated object store handle. GC::Ref m_index; GC::Ref m_object_store_handle; // An index handle has a name, which is initialized to the name of the associated index when the index handle is created. String m_name; }; }