@@ -38,10 +38,11 @@ import mysql.protocol.packet_helpers;
38
38
import mysql.protocol.packets;
39
39
import mysql.protocol.sockets;
40
40
41
- /* * Gets the value stored in an algebraic type based on its data type.
42
- */
43
41
import taggedalgebraic.taggedalgebraic;
44
- auto ref get (alias K, U)(auto ref TaggedAlgebraic! U ta) if (is (typeof (K) == TaggedAlgebraic! U.Kind))
42
+
43
+ // Trick tagged algebraic into getting the value based on the kind enum. Much
44
+ // easier than dealing with types when I already have the kind.
45
+ auto kget (alias K, U)(auto ref TaggedAlgebraic! U ta) if (is (typeof (K) == TaggedAlgebraic! U.Kind))
45
46
{
46
47
import taggedalgebraic.taggedunion;
47
48
return (cast (TaggedUnion! U)ta).value! K;
@@ -142,7 +143,7 @@ package struct ProtocolPrepared
142
143
types[ct++ ] = cast (ubyte ) ext;
143
144
types[ct++ ] = SIGNED ;
144
145
reAlloc(2 );
145
- bool bv = isRef? * v.get ! BitRef : v.get ! Bit;
146
+ bool bv = isRef? * v.kget ! BitRef : v.kget ! Bit;
146
147
vals[vcl++ ] = 1 ;
147
148
vals[vcl++ ] = bv? 0x31 : 0x30 ;
148
149
break ;
@@ -152,23 +153,23 @@ package struct ProtocolPrepared
152
153
types[ct++ ] = SQLType.TINY ;
153
154
types[ct++ ] = SIGNED ;
154
155
reAlloc(1 );
155
- vals[vcl++ ] = isRef? * v.get ! ByteRef : v.get ! Byte;
156
+ vals[vcl++ ] = isRef? * v.kget ! ByteRef : v.kget ! Byte;
156
157
break ;
157
158
case UByteRef:
158
159
isRef = true ; goto case ;
159
160
case UByte:
160
161
types[ct++ ] = SQLType.TINY ;
161
162
types[ct++ ] = UNSIGNED ;
162
163
reAlloc(1 );
163
- vals[vcl++ ] = isRef? * v.get ! UByteRef : v.get ! UByte;
164
+ vals[vcl++ ] = isRef? * v.kget ! UByteRef : v.kget ! UByte;
164
165
break ;
165
166
case ShortRef:
166
167
isRef = true ; goto case ;
167
168
case Short:
168
169
types[ct++ ] = SQLType.SHORT ;
169
170
types[ct++ ] = SIGNED ;
170
171
reAlloc(2 );
171
- short si = isRef? * v.get ! ShortRef : v.get ! Short;
172
+ short si = isRef? * v.kget ! ShortRef : v.kget ! Short;
172
173
vals[vcl++ ] = cast (ubyte ) (si & 0xff );
173
174
vals[vcl++ ] = cast (ubyte ) ((si >> 8 ) & 0xff );
174
175
break ;
@@ -178,7 +179,7 @@ package struct ProtocolPrepared
178
179
types[ct++ ] = SQLType.SHORT ;
179
180
types[ct++ ] = UNSIGNED ;
180
181
reAlloc(2 );
181
- ushort us = isRef? * v.get ! UShortRef : v.get ! UShort;
182
+ ushort us = isRef? * v.kget ! UShortRef : v.kget ! UShort;
182
183
vals[vcl++ ] = cast (ubyte ) (us & 0xff );
183
184
vals[vcl++ ] = cast (ubyte ) ((us >> 8 ) & 0xff );
184
185
break ;
@@ -188,7 +189,7 @@ package struct ProtocolPrepared
188
189
types[ct++ ] = SQLType.INT ;
189
190
types[ct++ ] = SIGNED ;
190
191
reAlloc(4 );
191
- int ii = isRef? * v.get ! IntRef : v.get ! Int;
192
+ int ii = isRef? * v.kget ! IntRef : v.kget ! Int;
192
193
vals[vcl++ ] = cast (ubyte ) (ii & 0xff );
193
194
vals[vcl++ ] = cast (ubyte ) ((ii >> 8 ) & 0xff );
194
195
vals[vcl++ ] = cast (ubyte ) ((ii >> 16 ) & 0xff );
@@ -200,7 +201,7 @@ package struct ProtocolPrepared
200
201
types[ct++ ] = SQLType.INT ;
201
202
types[ct++ ] = UNSIGNED ;
202
203
reAlloc(4 );
203
- uint ui = isRef? * v.get ! UIntRef : v.get ! UInt;
204
+ uint ui = isRef? * v.kget ! UIntRef : v.kget ! UInt;
204
205
vals[vcl++ ] = cast (ubyte ) (ui & 0xff );
205
206
vals[vcl++ ] = cast (ubyte ) ((ui >> 8 ) & 0xff );
206
207
vals[vcl++ ] = cast (ubyte ) ((ui >> 16 ) & 0xff );
@@ -212,7 +213,7 @@ package struct ProtocolPrepared
212
213
types[ct++ ] = SQLType.LONGLONG ;
213
214
types[ct++ ] = SIGNED ;
214
215
reAlloc(8 );
215
- long li = isRef? * v.get ! LongRef : v.get ! Long;
216
+ long li = isRef? * v.kget ! LongRef : v.kget ! Long;
216
217
vals[vcl++ ] = cast (ubyte ) (li & 0xff );
217
218
vals[vcl++ ] = cast (ubyte ) ((li >> 8 ) & 0xff );
218
219
vals[vcl++ ] = cast (ubyte ) ((li >> 16 ) & 0xff );
@@ -228,7 +229,7 @@ package struct ProtocolPrepared
228
229
types[ct++ ] = SQLType.LONGLONG ;
229
230
types[ct++ ] = UNSIGNED ;
230
231
reAlloc(8 );
231
- ulong ul = isRef? * v.get ! ULongRef : v.get ! ULong;
232
+ ulong ul = isRef? * v.kget ! ULongRef : v.kget ! ULong;
232
233
vals[vcl++ ] = cast (ubyte ) (ul & 0xff );
233
234
vals[vcl++ ] = cast (ubyte ) ((ul >> 8 ) & 0xff );
234
235
vals[vcl++ ] = cast (ubyte ) ((ul >> 16 ) & 0xff );
@@ -244,7 +245,7 @@ package struct ProtocolPrepared
244
245
types[ct++ ] = SQLType.FLOAT ;
245
246
types[ct++ ] = SIGNED ;
246
247
reAlloc(4 );
247
- float [1 ] f = [isRef? * v.get ! FloatRef : v.get ! Float];
248
+ float [1 ] f = [isRef? * v.kget ! FloatRef : v.kget ! Float];
248
249
ubyte [] uba = cast (ubyte []) f[];
249
250
vals[vcl .. vcl + uba.length] = uba[];
250
251
vcl += uba.length;
@@ -255,7 +256,7 @@ package struct ProtocolPrepared
255
256
types[ct++ ] = SQLType.DOUBLE ;
256
257
types[ct++ ] = SIGNED ;
257
258
reAlloc(8 );
258
- double [1 ] d = [isRef? * v.get ! DoubleRef : v.get ! Double];
259
+ double [1 ] d = [isRef? * v.kget ! DoubleRef : v.kget ! Double];
259
260
ubyte [] uba = cast (ubyte []) d[];
260
261
vals[vcl .. uba.length] = uba[];
261
262
vcl += uba.length;
@@ -265,7 +266,7 @@ package struct ProtocolPrepared
265
266
case Date :
266
267
types[ct++ ] = SQLType.DATE ;
267
268
types[ct++ ] = SIGNED ;
268
- auto date = isRef? * v.get ! DateRef : v.get ! Date ;
269
+ auto date = isRef? * v.kget ! DateRef : v.kget ! Date ;
269
270
ubyte [] da = pack(date);
270
271
size_t l = da.length;
271
272
reAlloc(l);
@@ -277,7 +278,7 @@ package struct ProtocolPrepared
277
278
case Time :
278
279
types[ct++ ] = SQLType.TIME ;
279
280
types[ct++ ] = SIGNED ;
280
- auto time = isRef? * v.get ! TimeRef : v.get ! Time ;
281
+ auto time = isRef? * v.kget ! TimeRef : v.kget ! Time ;
281
282
ubyte [] ta = pack(time);
282
283
size_t l = ta.length;
283
284
reAlloc(l);
@@ -289,7 +290,7 @@ package struct ProtocolPrepared
289
290
case DateTime :
290
291
types[ct++ ] = SQLType.DATETIME ;
291
292
types[ct++ ] = SIGNED ;
292
- auto dt = isRef? * v.get ! DateTimeRef : v.get ! DateTime ;
293
+ auto dt = isRef? * v.kget ! DateTimeRef : v.kget ! DateTime ;
293
294
ubyte [] da = pack(dt);
294
295
size_t l = da.length;
295
296
reAlloc(l);
@@ -301,7 +302,7 @@ package struct ProtocolPrepared
301
302
case Timestamp:
302
303
types[ct++ ] = SQLType.TIMESTAMP ;
303
304
types[ct++ ] = SIGNED ;
304
- auto tms = isRef? * v.get ! TimestampRef : v.get ! Timestamp;
305
+ auto tms = isRef? * v.kget ! TimestampRef : v.kget ! Timestamp;
305
306
auto dt = mysql.protocol.packet_helpers.toDateTime(tms.rep);
306
307
ubyte [] da = pack(dt);
307
308
size_t l = da.length;
@@ -317,7 +318,7 @@ package struct ProtocolPrepared
317
318
else
318
319
types[ct++ ] = cast (ubyte ) ext;
319
320
types[ct++ ] = SIGNED ;
320
- const char [] ca = isRef? * v.get ! TextRef : v.get ! Text ;
321
+ const char [] ca = isRef? * v.kget ! TextRef : v.kget ! Text ;
321
322
ubyte [] packed = packLCS(ca);
322
323
reAlloc(packed.length);
323
324
vals[vcl.. vcl+ packed.length] = packed[];
@@ -331,7 +332,7 @@ package struct ProtocolPrepared
331
332
else
332
333
types[ct++ ] = cast (ubyte ) ext;
333
334
types[ct++ ] = SIGNED ;
334
- const ubyte [] uba = isRef? * v.get ! BlobRef : v.get ! Blob;
335
+ const ubyte [] uba = isRef? * v.kget ! BlobRef : v.kget ! Blob;
335
336
ubyte [] packed = packLCS(uba);
336
337
reAlloc(packed.length);
337
338
vals[vcl.. vcl+ packed.length] = packed[];
0 commit comments