#ifndef IDBKeyRange_h
#define IDBKeyRange_h
#include "bindings/v8/Dictionary.h"
#include "bindings/v8/ScriptWrappable.h"
#include "modules/indexeddb/IDBKey.h"
#include "wtf/PassRefPtr.h"
#include "wtf/RefCounted.h"
namespace WebCore {
class ExceptionState;
class IDBKeyRange : public ScriptWrappable, public RefCounted<IDBKeyRange> {
public:
enum LowerBoundType {
LowerBoundOpen,
LowerBoundClosed
};
enum UpperBoundType {
UpperBoundOpen,
UpperBoundClosed
};
static PassRefPtr<IDBKeyRange> create(PassRefPtr<IDBKey> lower, PassRefPtr<IDBKey> upper, LowerBoundType lowerType, UpperBoundType upperType)
{
return adoptRef(new IDBKeyRange(lower, upper, lowerType, upperType));
}
static PassRefPtr<IDBKeyRange> fromScriptValue(ExecutionContext*, const ScriptValue&, ExceptionState&);
~IDBKeyRange() { }
PassRefPtr<IDBKey> lower() const { return m_lower; }
PassRefPtr<IDBKey> upper() const { return m_upper; }
ScriptValue lowerValue(ExecutionContext*) const;
ScriptValue upperValue(ExecutionContext*) const;
bool lowerOpen() const { return m_lowerType == LowerBoundOpen; }
bool upperOpen() const { return m_upperType == UpperBoundOpen; }
static PassRefPtr<IDBKeyRange> only(ExecutionContext*, const ScriptValue& key, ExceptionState&);
static PassRefPtr<IDBKeyRange> lowerBound(ExecutionContext*, const ScriptValue& bound, bool open, ExceptionState&);
static PassRefPtr<IDBKeyRange> upperBound(ExecutionContext*, const ScriptValue& bound, bool open, ExceptionState&);
static PassRefPtr<IDBKeyRange> bound(ExecutionContext*, const ScriptValue& lower, const ScriptValue& upper, bool lowerOpen, bool upperOpen, ExceptionState&);
static PassRefPtr<IDBKeyRange> only(PassRefPtr<IDBKey> value, ExceptionState&);
private:
IDBKeyRange(PassRefPtr<IDBKey> lower, PassRefPtr<IDBKey> upper, LowerBoundType lowerType, UpperBoundType upperType);
RefPtr<IDBKey> m_lower;
RefPtr<IDBKey> m_upper;
LowerBoundType m_lowerType;
UpperBoundType m_upperType;
};
}
#endif