ionPutUIntFieldR

  1. size_t ionPutUIntFieldR(ubyte* ptr, T num)
  2. size_t ionPutUIntFieldR(ubyte* ptr, T num)
  3. size_t ionPutUIntFieldR(ubyte* ptr, T num)
    size_t
    ionPutUIntFieldR
    (
    T
    )
    (
    scope ubyte* ptr
    ,
    const T num
    )
    if (
    is(T == ushort)
    )

Examples

1 ubyte[8] data;
2 
3 alias AliasSeq(T...) = T;
4 
5 foreach(T; AliasSeq!(ubyte, ushort, uint, ulong))
6 {
7     data[] = 0;
8     assert(ionPutUIntFieldR!T(data.ptr + data.length, 0) == 0);
9 
10     data[] = 0;
11     assert(ionPutUIntFieldR!T(data.ptr + data.length, 1) == 1);
12     assert(data[$ - 1] == 0x01);
13 
14     data[] = 0;
15     assert(ionPutUIntFieldR!T(data.ptr + data.length, 0x3F) == 1);
16     assert(data[$ - 1] == 0x3F);
17 
18     data[] = 0;
19     assert(ionPutUIntFieldR!T(data.ptr + data.length, 0xFF) == 1);
20     assert(data[$ - 1] == 0xFF);
21 
22     data[] = 0;
23     assert(ionPutUIntFieldR!T(data.ptr + data.length, 0x80) == 1);
24     assert(data[$ - 1] == 0x80);
25 }
26 
27 data[] = 0;
28 assert(ionPutUIntFieldR!uint(data.ptr + data.length, int.max) == 4);
29 assert(data[4 + 0] == 0x7F);
30 assert(data[4 + 1] == 0xFF);
31 assert(data[4 + 2] == 0xFF);
32 assert(data[4 + 3] == 0xFF);
33 
34 data[] = 0;
35 assert(ionPutUIntFieldR!uint(data.ptr + data.length, int.max + 1) == 4);
36 assert(data[4 + 0] == 0x80);
37 assert(data[4 + 1] == 0x00);
38 assert(data[4 + 2] == 0x00);
39 assert(data[4 + 3] == 0x00);
40 
41 data[] = 0;
42 assert(ionPutUIntFieldR!ulong(data.ptr + data.length, long.max >> 1) == 8);
43 assert(data[0] == 0x3F);
44 assert(data[1] == 0xFF);
45 assert(data[2] == 0xFF);
46 assert(data[3] == 0xFF);
47 assert(data[4] == 0xFF);
48 assert(data[5] == 0xFF);
49 assert(data[6] == 0xFF);
50 assert(data[7] == 0xFF);
51 
52 data[] = 0;
53 assert(ionPutUIntFieldR!ulong(data.ptr + data.length, long.max) == 8);
54 assert(data[0] == 0x7F);
55 assert(data[1] == 0xFF);
56 assert(data[2] == 0xFF);
57 assert(data[3] == 0xFF);
58 assert(data[4] == 0xFF);
59 assert(data[5] == 0xFF);
60 assert(data[6] == 0xFF);
61 assert(data[7] == 0xFF);
62 
63 data[] = 0;
64 assert(ionPutUIntFieldR!ulong(data.ptr + data.length, long.max + 1) == 8);
65 assert(data[0] == 0x80);
66 assert(data[1] == 0x00);
67 assert(data[2] == 0x00);
68 assert(data[3] == 0x00);
69 assert(data[4] == 0x00);
70 assert(data[5] == 0x00);
71 assert(data[6] == 0x00);
72 assert(data[7] == 0x00);
73 
74 data[] = 0;
75 assert(ionPutUIntFieldR(data.ptr + data.length, ulong.max) == 8);
76 assert(data[0] == 0xFF);
77 assert(data[1] == 0xFF);
78 assert(data[2] == 0xFF);
79 assert(data[3] == 0xFF);
80 assert(data[4] == 0xFF);
81 assert(data[5] == 0xFF);
82 assert(data[6] == 0xFF);
83 assert(data[7] == 0xFF);

Meta