Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 1 | // <auto-generated> |
| 2 | // automatically generated by the FlatBuffers compiler, do not modify |
| 3 | // </auto-generated> |
| 4 | |
| 5 | namespace MyGame.Example |
| 6 | { |
| 7 | |
| 8 | using global::System; |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 9 | using global::System.Collections.Generic; |
Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame] | 10 | using global::Google.FlatBuffers; |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 11 | |
| 12 | public struct Stat : IFlatbufferObject |
| 13 | { |
| 14 | private Table __p; |
| 15 | public ByteBuffer ByteBuffer { get { return __p.bb; } } |
James Kuszmaul | 3b15b0c | 2022-11-08 14:03:16 -0800 | [diff] [blame^] | 16 | public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_22_10_26(); } |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 17 | public static Stat GetRootAsStat(ByteBuffer _bb) { return GetRootAsStat(_bb, new Stat()); } |
| 18 | public static Stat GetRootAsStat(ByteBuffer _bb, Stat obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); } |
| 19 | public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); } |
| 20 | public Stat __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } |
| 21 | |
| 22 | public string Id { get { int o = __p.__offset(4); return o != 0 ? __p.__string(o + __p.bb_pos) : null; } } |
| 23 | #if ENABLE_SPAN_T |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 24 | public Span<byte> GetIdBytes() { return __p.__vector_as_span<byte>(4, 1); } |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 25 | #else |
| 26 | public ArraySegment<byte>? GetIdBytes() { return __p.__vector_as_arraysegment(4); } |
| 27 | #endif |
| 28 | public byte[] GetIdArray() { return __p.__vector_as_array<byte>(4); } |
| 29 | public long Val { get { int o = __p.__offset(6); return o != 0 ? __p.bb.GetLong(o + __p.bb_pos) : (long)0; } } |
| 30 | public bool MutateVal(long val) { int o = __p.__offset(6); if (o != 0) { __p.bb.PutLong(o + __p.bb_pos, val); return true; } else { return false; } } |
| 31 | public ushort Count { get { int o = __p.__offset(8); return o != 0 ? __p.bb.GetUshort(o + __p.bb_pos) : (ushort)0; } } |
| 32 | public bool MutateCount(ushort count) { int o = __p.__offset(8); if (o != 0) { __p.bb.PutUshort(o + __p.bb_pos, count); return true; } else { return false; } } |
| 33 | |
| 34 | public static Offset<MyGame.Example.Stat> CreateStat(FlatBufferBuilder builder, |
| 35 | StringOffset idOffset = default(StringOffset), |
| 36 | long val = 0, |
| 37 | ushort count = 0) { |
| 38 | builder.StartTable(3); |
| 39 | Stat.AddVal(builder, val); |
| 40 | Stat.AddId(builder, idOffset); |
| 41 | Stat.AddCount(builder, count); |
| 42 | return Stat.EndStat(builder); |
| 43 | } |
| 44 | |
| 45 | public static void StartStat(FlatBufferBuilder builder) { builder.StartTable(3); } |
| 46 | public static void AddId(FlatBufferBuilder builder, StringOffset idOffset) { builder.AddOffset(0, idOffset.Value, 0); } |
| 47 | public static void AddVal(FlatBufferBuilder builder, long val) { builder.AddLong(1, val, 0); } |
| 48 | public static void AddCount(FlatBufferBuilder builder, ushort count) { builder.AddUshort(2, count, 0); } |
| 49 | public static Offset<MyGame.Example.Stat> EndStat(FlatBufferBuilder builder) { |
| 50 | int o = builder.EndTable(); |
| 51 | return new Offset<MyGame.Example.Stat>(o); |
| 52 | } |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 53 | |
| 54 | public static VectorOffset CreateSortedVectorOfStat(FlatBufferBuilder builder, Offset<Stat>[] offsets) { |
Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame] | 55 | Array.Sort(offsets, |
| 56 | (Offset<Stat> o1, Offset<Stat> o2) => |
| 57 | new Stat().__assign(builder.DataBuffer.Length - o1.Value, builder.DataBuffer).Count.CompareTo(new Stat().__assign(builder.DataBuffer.Length - o2.Value, builder.DataBuffer).Count)); |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 58 | return builder.CreateVectorOfTables(offsets); |
| 59 | } |
| 60 | |
| 61 | public static Stat? __lookup_by_key(int vectorLocation, ushort key, ByteBuffer bb) { |
Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame] | 62 | Stat obj_ = new Stat(); |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 63 | int span = bb.GetInt(vectorLocation - 4); |
| 64 | int start = 0; |
| 65 | while (span != 0) { |
| 66 | int middle = span / 2; |
| 67 | int tableOffset = Table.__indirect(vectorLocation + 4 * (start + middle), bb); |
Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame] | 68 | obj_.__assign(tableOffset, bb); |
| 69 | int comp = obj_.Count.CompareTo(key); |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 70 | if (comp > 0) { |
| 71 | span = middle; |
| 72 | } else if (comp < 0) { |
| 73 | middle++; |
| 74 | start += middle; |
| 75 | span -= middle; |
| 76 | } else { |
Austin Schuh | 2dd86a9 | 2022-09-14 21:19:23 -0700 | [diff] [blame] | 77 | return obj_; |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 78 | } |
| 79 | } |
| 80 | return null; |
| 81 | } |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 82 | public StatT UnPack() { |
| 83 | var _o = new StatT(); |
| 84 | this.UnPackTo(_o); |
| 85 | return _o; |
| 86 | } |
| 87 | public void UnPackTo(StatT _o) { |
| 88 | _o.Id = this.Id; |
| 89 | _o.Val = this.Val; |
| 90 | _o.Count = this.Count; |
| 91 | } |
| 92 | public static Offset<MyGame.Example.Stat> Pack(FlatBufferBuilder builder, StatT _o) { |
| 93 | if (_o == null) return default(Offset<MyGame.Example.Stat>); |
| 94 | var _id = _o.Id == null ? default(StringOffset) : builder.CreateString(_o.Id); |
| 95 | return CreateStat( |
| 96 | builder, |
| 97 | _id, |
| 98 | _o.Val, |
| 99 | _o.Count); |
| 100 | } |
James Kuszmaul | 8e62b02 | 2022-03-22 09:33:25 -0700 | [diff] [blame] | 101 | } |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 102 | |
Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame] | 103 | public class StatT |
| 104 | { |
| 105 | [Newtonsoft.Json.JsonProperty("id")] |
| 106 | public string Id { get; set; } |
| 107 | [Newtonsoft.Json.JsonProperty("val")] |
| 108 | public long Val { get; set; } |
| 109 | [Newtonsoft.Json.JsonProperty("count")] |
| 110 | public ushort Count { get; set; } |
| 111 | |
| 112 | public StatT() { |
| 113 | this.Id = null; |
| 114 | this.Val = 0; |
| 115 | this.Count = 0; |
| 116 | } |
| 117 | } |
| 118 | |
Austin Schuh | e89fa2d | 2019-08-14 20:24:23 -0700 | [diff] [blame] | 119 | |
| 120 | } |