# automatically generated by the FlatBuffers compiler, do not modify

# namespace:

import flatbuffers
from flatbuffers.compat import import_numpy

np = import_numpy()


class ScalarData(object):
    __slots__ = ["_tab"]

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = ScalarData()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsScalarData(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)

    @classmethod
    def ScalarDataBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
        return flatbuffers.util.BufferHasIdentifier(
            buf, offset, b"\x73\x63\x61\x6C", size_prefixed=size_prefixed
        )

    # ScalarData
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # ScalarData
    def SourceName(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # ScalarData
    def Timestamp(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int64Flags, o + self._tab.Pos)
        return 0

    # ScalarData
    def ValueType(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
        return 0

    # ScalarData
    def Value(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            from flatbuffers.table import Table

            obj = Table(bytearray(), 0)
            self._tab.Union(obj, o)
            return obj
        return None


def ScalarDataStart(builder):
    builder.StartObject(4)


def Start(builder):
    return ScalarDataStart(builder)


def ScalarDataAddSourceName(builder, sourceName):
    builder.PrependUOffsetTRelativeSlot(
        0, flatbuffers.number_types.UOffsetTFlags.py_type(sourceName), 0
    )


def AddSourceName(builder, sourceName):
    return ScalarDataAddSourceName(builder, sourceName)


def ScalarDataAddTimestamp(builder, timestamp):
    builder.PrependInt64Slot(1, timestamp, 0)


def AddTimestamp(builder, timestamp):
    return ScalarDataAddTimestamp(builder, timestamp)


def ScalarDataAddValueType(builder, valueType):
    builder.PrependUint8Slot(2, valueType, 0)


def AddValueType(builder, valueType):
    return ScalarDataAddValueType(builder, valueType)


def ScalarDataAddValue(builder, value):
    builder.PrependUOffsetTRelativeSlot(
        3, flatbuffers.number_types.UOffsetTFlags.py_type(value), 0
    )


def AddValue(builder, value):
    return ScalarDataAddValue(builder, value)


def ScalarDataEnd(builder):
    return builder.EndObject()


def End(builder):
    return ScalarDataEnd(builder)
