1 module libwasm.bindings.IDBCursor;
2 
3 import libwasm.types;
4 
5 import memutils.ct: tuple;
6 import libwasm.bindings.IDBIndex;
7 import libwasm.bindings.IDBObjectStore;
8 import libwasm.bindings.IDBRequest;
9 
10 @safe:
11 nothrow:
12 
13 struct IDBCursor {
14   nothrow:
15   JsHandle handle;
16   alias handle this;
17   this(Handle h) {
18     this.handle = JsHandle(h);
19   }
20   auto source()() {
21     return Object_Getter__Handle(this.handle, "source");
22   }
23   IDBCursorDirection direction()() {
24     return Object_Getter__int(this.handle, "direction");
25   }
26   auto key()() {
27     return Any(Object_Getter__Handle(this.handle, "key"));
28   }
29   auto primaryKey()() {
30     return Any(Object_Getter__Handle(this.handle, "primaryKey"));
31   }
32   auto update(T0)(scope auto ref T0 value) {
33     // Any
34     Handle _handle_value = getOrCreateHandle(value);
35     auto result = IDBRequest(Object_Call_Handle__Handle(this.handle, "update", _handle_value));
36     dropHandle!(T0)(_handle_value);
37     return result;
38   }
39   void advance()(uint count) {
40     Object_Call_uint__void(this.handle, "advance", count);
41   }
42   void continue_(T0)(scope auto ref T0 key) {
43     import std.traits : isNumeric, isFloatingPoint, isSomeString;
44     if (isSomeString!T0) {
45       Object_Call_string__void(this.handle, "continue", cast(string) key);
46       return;
47     } else if (isNumeric!T0 && !isFloatingPoint!T0) {
48       Object_Call_long__void(this.handle, "continue", cast(long) key);
49       return;
50     } else if (isFloatingPoint!T0) {
51       Object_Call_double__void(this.handle, "continue", cast(double) key);
52       return;
53     }
54     // Any
55     Handle _handle_key = getOrCreateHandle(key);
56     Object_Call_Handle__void(this.handle, "continue", _handle_key);
57     dropHandle!(T0)(_handle_key);
58   }
59   void continue_()() {
60     Object_Call__void(this.handle, "continue");
61   }
62   void continuePrimaryKey(T0, T1)(scope auto ref T0 key, scope auto ref T1 primaryKey) {
63     // Any
64     Handle _handle_key = getOrCreateHandle(key);
65     // Any
66     Handle _handle_primaryKey = getOrCreateHandle(primaryKey);
67     Serialize_Object_VarArgCall!void(this.handle, "continuePrimaryKey", "Handle;Handle", tuple(_handle_key, _handle_primaryKey));
68     dropHandle!(T0)(_handle_key);
69     dropHandle!(T1)(_handle_primaryKey);
70   }
71   auto delete_()() {
72     return IDBRequest(Object_Getter__Handle(this.handle, "delete"));
73   }
74 }
75 enum IDBCursorDirection {
76   next,
77   nextunique,
78   prev,
79   prevunique
80 }
81 struct IDBCursorWithValue {
82   nothrow:
83   libwasm.bindings.IDBCursor.IDBCursor _parent;
84   alias _parent this;
85   this(Handle h) {
86     _parent = .IDBCursor(h);
87   }
88   auto value()() {
89     return Any(Object_Getter__Handle(this._parent, "value"));
90   }
91 }
92 
93