# automatically generated by the FlatBuffers compiler, do not modify

# namespace: meta

import flatbuffers
from flatbuffers.compat import import_numpy

np = import_numpy()


# Tag definitions are created independent of objects tagged with tags. Primary key of this table is ``oid``.
class TagDefinition(object):
    __slots__ = ["_tab"]

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

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

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

    # OID of the tag definition within the database.
    # TagDefinition
    def Oid(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(
                flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)
            )
        return 0

    # TagDefinition
    def OidAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # TagDefinition
    def OidLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # TagDefinition
    def OidIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        return o == 0

    # Timestamp when the attribute was last modified (or first created).
    # TagDefinition
    def Modified(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Uint64Flags, o + self._tab.Pos)
        return 0

    # Tag name (or URI in general). This is must be globally unique and represents the semantic identifier of the tag.
    # TagDefinition
    def Tag(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # CBOR-serialized, object-valued extra data stored along with this tag definition.
    # TagDefinition
    def Extra(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(
                flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)
            )
        return 0

    # TagDefinition
    def ExtraAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

    # TagDefinition
    def ExtraLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # TagDefinition
    def ExtraIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        return o == 0


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


def Start(builder):
    TagDefinitionStart(builder)


def TagDefinitionAddOid(builder, oid):
    builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(oid), 0)


def AddOid(builder, oid):
    TagDefinitionAddOid(builder, oid)


def TagDefinitionStartOidVector(builder, numElems):
    return builder.StartVector(1, numElems, 1)


def StartOidVector(builder, numElems: int) -> int:
    return TagDefinitionStartOidVector(builder, numElems)


def TagDefinitionAddModified(builder, modified):
    builder.PrependUint64Slot(1, modified, 0)


def AddModified(builder, modified):
    TagDefinitionAddModified(builder, modified)


def TagDefinitionAddTag(builder, tag):
    builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(tag), 0)


def AddTag(builder, tag):
    TagDefinitionAddTag(builder, tag)


def TagDefinitionAddExtra(builder, extra):
    builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(extra), 0)


def AddExtra(builder, extra):
    TagDefinitionAddExtra(builder, extra)


def TagDefinitionStartExtraVector(builder, numElems):
    return builder.StartVector(1, numElems, 1)


def StartExtraVector(builder, numElems: int) -> int:
    return TagDefinitionStartExtraVector(builder, numElems)


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


def End(builder):
    return TagDefinitionEnd(builder)
