...
1// automatically generated by the FlatBuffers compiler, do not modify
2
3package MyGame.Example
4
5import com.google.flatbuffers.BaseVector
6import com.google.flatbuffers.BooleanVector
7import com.google.flatbuffers.ByteVector
8import com.google.flatbuffers.Constants
9import com.google.flatbuffers.DoubleVector
10import com.google.flatbuffers.FlatBufferBuilder
11import com.google.flatbuffers.FloatVector
12import com.google.flatbuffers.LongVector
13import com.google.flatbuffers.StringVector
14import com.google.flatbuffers.Struct
15import com.google.flatbuffers.Table
16import com.google.flatbuffers.UnionVector
17import java.nio.ByteBuffer
18import java.nio.ByteOrder
19import kotlin.math.sign
20
21@Suppress("unused")
22class Stat : Table() {
23
24 fun __init(_i: Int, _bb: ByteBuffer) {
25 __reset(_i, _bb)
26 }
27 fun __assign(_i: Int, _bb: ByteBuffer) : Stat {
28 __init(_i, _bb)
29 return this
30 }
31 val id : String?
32 get() {
33 val o = __offset(4)
34 return if (o != 0) {
35 __string(o + bb_pos)
36 } else {
37 null
38 }
39 }
40 val idAsByteBuffer : ByteBuffer get() = __vector_as_bytebuffer(4, 1)
41 fun idInByteBuffer(_bb: ByteBuffer) : ByteBuffer = __vector_in_bytebuffer(_bb, 4, 1)
42 val val_ : Long
43 get() {
44 val o = __offset(6)
45 return if(o != 0) bb.getLong(o + bb_pos) else 0L
46 }
47 fun mutateVal_(val_: Long) : Boolean {
48 val o = __offset(6)
49 return if (o != 0) {
50 bb.putLong(o + bb_pos, val_)
51 true
52 } else {
53 false
54 }
55 }
56 val count : UShort
57 get() {
58 val o = __offset(8)
59 return if(o != 0) bb.getShort(o + bb_pos).toUShort() else 0u
60 }
61 fun mutateCount(count: UShort) : Boolean {
62 val o = __offset(8)
63 return if (o != 0) {
64 bb.putShort(o + bb_pos, count.toShort())
65 true
66 } else {
67 false
68 }
69 }
70 override fun keysCompare(o1: Int, o2: Int, _bb: ByteBuffer) : Int {
71 val val_1 = _bb.getShort(__offset(8, o1, _bb))
72 val val_2 = _bb.getShort(__offset(8, o2, _bb))
73 return (val_1 - val_2).sign
74 }
75 companion object {
76 fun validateVersion() = Constants.FLATBUFFERS_23_5_26()
77 fun getRootAsStat(_bb: ByteBuffer): Stat = getRootAsStat(_bb, Stat())
78 fun getRootAsStat(_bb: ByteBuffer, obj: Stat): Stat {
79 _bb.order(ByteOrder.LITTLE_ENDIAN)
80 return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb))
81 }
82 fun createStat(builder: FlatBufferBuilder, idOffset: Int, val_: Long, count: UShort) : Int {
83 builder.startTable(3)
84 addVal_(builder, val_)
85 addId(builder, idOffset)
86 addCount(builder, count)
87 return endStat(builder)
88 }
89 fun startStat(builder: FlatBufferBuilder) = builder.startTable(3)
90 fun addId(builder: FlatBufferBuilder, id: Int) = builder.addOffset(0, id, 0)
91 fun addVal_(builder: FlatBufferBuilder, val_: Long) = builder.addLong(1, val_, 0L)
92 fun addCount(builder: FlatBufferBuilder, count: UShort) {
93 builder.addShort(count.toShort())
94 builder.slot(2)
95 }
96 fun endStat(builder: FlatBufferBuilder) : Int {
97 val o = builder.endTable()
98 return o
99 }
100 fun __lookup_by_key(obj: Stat?, vectorLocation: Int, key: UShort, bb: ByteBuffer) : Stat? {
101 var span = bb.getInt(vectorLocation - 4)
102 var start = 0
103 while (span != 0) {
104 var middle = span / 2
105 val tableOffset = __indirect(vectorLocation + 4 * (start + middle), bb)
106 val value = bb.getShort(__offset(8, bb.capacity() - tableOffset, bb)).toUShort()
107 val comp = value.compareTo(key)
108 when {
109 comp > 0 -> span = middle
110 comp < 0 -> {
111 middle++
112 start += middle
113 span -= middle
114 }
115 else -> {
116 return (obj ?: Stat()).__assign(tableOffset, bb)
117 }
118 }
119 }
120 return null
121 }
122 }
123}
View as plain text