blob: 471bc36ff0682789bece5a311be83c7b793aa37c [file] [log] [blame]
Austin Schuhe89fa2d2019-08-14 20:24:23 -07001# automatically generated by the FlatBuffers compiler, do not modify
2
3# namespace: Example
4
5import flatbuffers
Austin Schuh272c6132020-11-14 16:37:52 -08006from flatbuffers.compat import import_numpy
7np = import_numpy()
Austin Schuhe89fa2d2019-08-14 20:24:23 -07008
9class Stat(object):
10 __slots__ = ['_tab']
11
12 @classmethod
James Kuszmaul8e62b022022-03-22 09:33:25 -070013 def GetRootAs(cls, buf, offset=0):
Austin Schuhe89fa2d2019-08-14 20:24:23 -070014 n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
15 x = Stat()
16 x.Init(buf, n + offset)
17 return x
18
19 @classmethod
James Kuszmaul8e62b022022-03-22 09:33:25 -070020 def GetRootAsStat(cls, buf, offset=0):
21 """This method is deprecated. Please switch to GetRootAs."""
22 return cls.GetRootAs(buf, offset)
23 @classmethod
Austin Schuhe89fa2d2019-08-14 20:24:23 -070024 def StatBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
25 return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x4F\x4E\x53", size_prefixed=size_prefixed)
26
27 # Stat
28 def Init(self, buf, pos):
29 self._tab = flatbuffers.table.Table(buf, pos)
30
31 # Stat
32 def Id(self):
33 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
34 if o != 0:
35 return self._tab.String(o + self._tab.Pos)
36 return None
37
38 # Stat
39 def Val(self):
40 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
41 if o != 0:
42 return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
43 return 0
44
45 # Stat
46 def Count(self):
47 o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
48 if o != 0:
49 return self._tab.Get(flatbuffers.number_types.Uint16Flags, o + self._tab.Pos)
50 return 0
51
52def StatStart(builder): builder.StartObject(3)
James Kuszmaul8e62b022022-03-22 09:33:25 -070053def Start(builder):
54 return StatStart(builder)
Austin Schuhe89fa2d2019-08-14 20:24:23 -070055def StatAddId(builder, id): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(id), 0)
James Kuszmaul8e62b022022-03-22 09:33:25 -070056def AddId(builder, id):
57 return StatAddId(builder, id)
Austin Schuhe89fa2d2019-08-14 20:24:23 -070058def StatAddVal(builder, val): builder.PrependInt64Slot(1, val, 0)
James Kuszmaul8e62b022022-03-22 09:33:25 -070059def AddVal(builder, val):
60 return StatAddVal(builder, val)
Austin Schuhe89fa2d2019-08-14 20:24:23 -070061def StatAddCount(builder, count): builder.PrependUint16Slot(2, count, 0)
James Kuszmaul8e62b022022-03-22 09:33:25 -070062def AddCount(builder, count):
63 return StatAddCount(builder, count)
Austin Schuhe89fa2d2019-08-14 20:24:23 -070064def StatEnd(builder): return builder.EndObject()
James Kuszmaul8e62b022022-03-22 09:33:25 -070065def End(builder):
66 return StatEnd(builder)
Austin Schuh272c6132020-11-14 16:37:52 -080067
68class StatT(object):
69
70 # StatT
71 def __init__(self):
72 self.id = None # type: str
73 self.val = 0 # type: int
74 self.count = 0 # type: int
75
76 @classmethod
77 def InitFromBuf(cls, buf, pos):
78 stat = Stat()
79 stat.Init(buf, pos)
80 return cls.InitFromObj(stat)
81
82 @classmethod
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080083 def InitFromPackedBuf(cls, buf, pos=0):
84 n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
85 return cls.InitFromBuf(buf, pos+n)
86
87 @classmethod
Austin Schuh272c6132020-11-14 16:37:52 -080088 def InitFromObj(cls, stat):
89 x = StatT()
90 x._UnPack(stat)
91 return x
92
93 # StatT
94 def _UnPack(self, stat):
95 if stat is None:
96 return
97 self.id = stat.Id()
98 self.val = stat.Val()
99 self.count = stat.Count()
100
101 # StatT
102 def Pack(self, builder):
103 if self.id is not None:
104 id = builder.CreateString(self.id)
105 StatStart(builder)
106 if self.id is not None:
107 StatAddId(builder, id)
108 StatAddVal(builder, self.val)
109 StatAddCount(builder, self.count)
110 stat = StatEnd(builder)
111 return stat