• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# automatically generated by the FlatBuffers compiler, do not modify
2
3# namespace: Example
4
5import flatbuffers
6from flatbuffers.compat import import_numpy
7np = import_numpy()
8
9class Stat(object):
10    __slots__ = ['_tab']
11
12    @classmethod
13    def GetRootAs(cls, buf, offset=0):
14        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
15        x = Stat()
16        x.Init(buf, n + offset)
17        return x
18
19    @classmethod
20    def GetRootAsStat(cls, buf, offset=0):
21        """This method is deprecated. Please switch to GetRootAs."""
22        return cls.GetRootAs(buf, offset)
23    @classmethod
24    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 Start(builder): builder.StartObject(3)
53def StatStart(builder):
54    """This method is deprecated. Please switch to Start."""
55    return Start(builder)
56def AddId(builder, id): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(id), 0)
57def StatAddId(builder, id):
58    """This method is deprecated. Please switch to AddId."""
59    return AddId(builder, id)
60def AddVal(builder, val): builder.PrependInt64Slot(1, val, 0)
61def StatAddVal(builder, val):
62    """This method is deprecated. Please switch to AddVal."""
63    return AddVal(builder, val)
64def AddCount(builder, count): builder.PrependUint16Slot(2, count, 0)
65def StatAddCount(builder, count):
66    """This method is deprecated. Please switch to AddCount."""
67    return AddCount(builder, count)
68def End(builder): return builder.EndObject()
69def StatEnd(builder):
70    """This method is deprecated. Please switch to End."""
71    return End(builder)
72
73class StatT(object):
74
75    # StatT
76    def __init__(self):
77        self.id = None  # type: str
78        self.val = 0  # type: int
79        self.count = 0  # type: int
80
81    @classmethod
82    def InitFromBuf(cls, buf, pos):
83        stat = Stat()
84        stat.Init(buf, pos)
85        return cls.InitFromObj(stat)
86
87    @classmethod
88    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        Start(builder)
106        if self.id is not None:
107            AddId(builder, id)
108        AddVal(builder, self.val)
109        AddCount(builder, self.count)
110        stat = End(builder)
111        return stat
112