#ifndef IDBIndex_h
#define IDBIndex_h
#include "IDBCursor.h"
#include "IDBDatabase.h"
#include "IDBKeyPath.h"
#include "IDBKeyRange.h"
#include "IDBMetadata.h"
#include "IDBObjectStore.h"
#include "IDBRequest.h"
#include "ScriptWrappable.h"
#include <wtf/Forward.h>
#include <wtf/text/WTFString.h>
#if ENABLE(INDEXED_DATABASE)
namespace WebCore {
class IDBObjectStore;
class IDBIndex : public ScriptWrappable, public RefCounted<IDBIndex> {
public:
static PassRefPtr<IDBIndex> create(const IDBIndexMetadata& metadata, IDBObjectStore* objectStore, IDBTransaction* transaction)
{
return adoptRef(new IDBIndex(metadata, objectStore, transaction));
}
~IDBIndex();
const String name() const { return m_metadata.name; }
PassRefPtr<IDBObjectStore> objectStore() const { return m_objectStore; }
PassRefPtr<IDBAny> keyPathAny() const { return IDBAny::create(m_metadata.keyPath); }
const IDBKeyPath keyPath() const { return m_metadata.keyPath; }
bool unique() const { return m_metadata.unique; }
bool multiEntry() const { return m_metadata.multiEntry; }
int64_t id() const { return m_metadata.id; }
PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, ExceptionCode& ec) { return openCursor(context, static_cast<IDBKeyRange*>(0), ec); }
PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) { return openCursor(context, keyRange, IDBCursor::directionNext(), ec); }
PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext* context, const ScriptValue& key, ExceptionCode& ec) { return openCursor(context, key, IDBCursor::directionNext(), ec); }
PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, const String& direction, ExceptionCode&);
PassRefPtr<IDBRequest> openCursor(ScriptExecutionContext*, const ScriptValue& key, const String& direction, ExceptionCode&);
PassRefPtr<IDBRequest> count(ScriptExecutionContext* context, ExceptionCode& ec) { return count(context, static_cast<IDBKeyRange*>(0), ec); }
PassRefPtr<IDBRequest> count(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&);
PassRefPtr<IDBRequest> count(ScriptExecutionContext*, const ScriptValue& key, ExceptionCode&);
PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext* context, ExceptionCode& ec) { return openKeyCursor(context, static_cast<IDBKeyRange*>(0), ec); }
PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext* context, PassRefPtr<IDBKeyRange> keyRange, ExceptionCode& ec) { return openKeyCursor(context, keyRange, IDBCursor::directionNext(), ec); }
PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext* context, const ScriptValue& key, ExceptionCode& ec) { return openKeyCursor(context, key, IDBCursor::directionNext(), ec); }
PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, const String& direction, ExceptionCode&);
PassRefPtr<IDBRequest> openKeyCursor(ScriptExecutionContext*, const ScriptValue& key, const String& direction, ExceptionCode&);
PassRefPtr<IDBRequest> get(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&);
PassRefPtr<IDBRequest> get(ScriptExecutionContext*, const ScriptValue& key, ExceptionCode&);
PassRefPtr<IDBRequest> getKey(ScriptExecutionContext*, PassRefPtr<IDBKeyRange>, ExceptionCode&);
PassRefPtr<IDBRequest> getKey(ScriptExecutionContext*, const ScriptValue& key, ExceptionCode&);
void markDeleted() { m_deleted = true; }
IDBDatabaseBackendInterface* backendDB() const;
private:
IDBIndex(const IDBIndexMetadata&, IDBObjectStore*, IDBTransaction*);
IDBIndexMetadata m_metadata;
RefPtr<IDBObjectStore> m_objectStore;
RefPtr<IDBTransaction> m_transaction;
bool m_deleted;
};
}
#endif
#endif // IDBIndex_h