# automatically generated by the FlatBuffers compiler, do not modify

# namespace: Packets

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

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

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

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

    # ExecuteRpcParam
    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

    # ExecuteRpcParam
    def ClassName(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

    # ExecuteRpcParam
    def TargetName(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

    # ExecuteRpcParam
    def ParamDocuments(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.String(a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
        return ""

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

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

def ExecuteRpcParamStart(builder): builder.StartObject(4)
def Start(builder):
    return ExecuteRpcParamStart(builder)
def ExecuteRpcParamAddBy(builder, by): builder.PrependInt16Slot(0, by, 0)
def AddBy(builder, by):
    return ExecuteRpcParamAddBy(builder, by)
def ExecuteRpcParamAddClassName(builder, className): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(className), 0)
def AddClassName(builder, className):
    return ExecuteRpcParamAddClassName(builder, className)
def ExecuteRpcParamAddTargetName(builder, targetName): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(targetName), 0)
def AddTargetName(builder, targetName):
    return ExecuteRpcParamAddTargetName(builder, targetName)
def ExecuteRpcParamAddParamDocuments(builder, paramDocuments): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(paramDocuments), 0)
def AddParamDocuments(builder, paramDocuments):
    return ExecuteRpcParamAddParamDocuments(builder, paramDocuments)
def ExecuteRpcParamStartParamDocumentsVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartParamDocumentsVector(builder, numElems):
    return ExecuteRpcParamStartParamDocumentsVector(builder, numElems)
def ExecuteRpcParamEnd(builder): return builder.EndObject()
def End(builder):
    return ExecuteRpcParamEnd(builder)
try:
    from typing import List
except:
    pass

class ExecuteRpcParamT(object):

    # ExecuteRpcParamT
    def __init__(self):
        self.by = 0  # type: int
        self.className = None  # type: str
        self.targetName = None  # type: str
        self.paramDocuments = None  # type: List[str]

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

    @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, executeRpcParam):
        x = ExecuteRpcParamT()
        x._UnPack(executeRpcParam)
        return x

    # ExecuteRpcParamT
    def _UnPack(self, executeRpcParam):
        if executeRpcParam is None:
            return
        self.by = executeRpcParam.By()
        self.className = executeRpcParam.ClassName()
        self.targetName = executeRpcParam.TargetName()
        if not executeRpcParam.ParamDocumentsIsNone():
            self.paramDocuments = []
            for i in range(executeRpcParam.ParamDocumentsLength()):
                self.paramDocuments.append(executeRpcParam.ParamDocuments(i))

    # ExecuteRpcParamT
    def Pack(self, builder):
        if self.className is not None:
            className = builder.CreateString(self.className)
        if self.targetName is not None:
            targetName = builder.CreateString(self.targetName)
        if self.paramDocuments is not None:
            paramDocumentslist = []
            for i in range(len(self.paramDocuments)):
                paramDocumentslist.append(builder.CreateString(self.paramDocuments[i]))
            ExecuteRpcParamStartParamDocumentsVector(builder, len(self.paramDocuments))
            for i in reversed(range(len(self.paramDocuments))):
                builder.PrependUOffsetTRelative(paramDocumentslist[i])
            paramDocuments = builder.EndVector()
        ExecuteRpcParamStart(builder)
        ExecuteRpcParamAddBy(builder, self.by)
        if self.className is not None:
            ExecuteRpcParamAddClassName(builder, className)
        if self.targetName is not None:
            ExecuteRpcParamAddTargetName(builder, targetName)
        if self.paramDocuments is not None:
            ExecuteRpcParamAddParamDocuments(builder, paramDocuments)
        executeRpcParam = ExecuteRpcParamEnd(builder)
        return executeRpcParam
