# automatically generated by the FlatBuffers compiler, do not modify

# namespace: Types

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

class ObjectLocator(object):
    __slots__ = ['_tab']

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

    @classmethod
    def GetRootAsObjectLocator(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    # ObjectLocator
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # ObjectLocator
    def By(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int16Flags, o + self._tab.Pos)
        return 0

    # ObjectLocator
    def Str(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

def ObjectLocatorStart(builder): builder.StartObject(2)
def Start(builder):
    return ObjectLocatorStart(builder)
def ObjectLocatorAddBy(builder, by): builder.PrependInt16Slot(0, by, 0)
def AddBy(builder, by):
    return ObjectLocatorAddBy(builder, by)
def ObjectLocatorAddStr(builder, str): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(str), 0)
def AddStr(builder, str):
    return ObjectLocatorAddStr(builder, str)
def ObjectLocatorEnd(builder): return builder.EndObject()
def End(builder):
    return ObjectLocatorEnd(builder)

class ObjectLocatorT(object):

    # ObjectLocatorT
    def __init__(self):
        self.by = 0  # type: int
        self.str = None  # type: str

    @classmethod
    def InitFromBuf(cls, buf, pos):
        objectLocator = ObjectLocator()
        objectLocator.Init(buf, pos)
        return cls.InitFromObj(objectLocator)

    @classmethod
    def InitFromPackedBuf(cls, buf, pos=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
        return cls.InitFromBuf(buf, pos+n)

    @classmethod
    def InitFromObj(cls, objectLocator):
        x = ObjectLocatorT()
        x._UnPack(objectLocator)
        return x

    # ObjectLocatorT
    def _UnPack(self, objectLocator):
        if objectLocator is None:
            return
        self.by = objectLocator.By()
        self.str = objectLocator.Str()

    # ObjectLocatorT
    def Pack(self, builder):
        if self.str is not None:
            str = builder.CreateString(self.str)
        ObjectLocatorStart(builder)
        ObjectLocatorAddBy(builder, self.by)
        if self.str is not None:
            ObjectLocatorAddStr(builder, str)
        objectLocator = ObjectLocatorEnd(builder)
        return objectLocator
