# automatically generated by the FlatBuffers compiler, do not modify

# namespace: openmeteo_sdk

import flatbuffers
from flatbuffers.compat import import_numpy
from typing import Any
from openmeteo_sdk.ValuesAndLevel import ValuesAndLevel
from typing import Optional
np = import_numpy()

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

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

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

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

    # ValuesUnitPressureLevel
    def Values(self, j: int) -> Optional[ValuesAndLevel]:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            x = self._tab.Vector(o)
            x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
            x = self._tab.Indirect(x)
            obj = ValuesAndLevel()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # ValuesUnitPressureLevel
    def ValuesLength(self) -> int:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # ValuesUnitPressureLevel
    def ValuesIsNone(self) -> bool:
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        return o == 0

def ValuesUnitPressureLevelStart(builder: flatbuffers.Builder):
    builder.StartObject(2)

def Start(builder: flatbuffers.Builder):
    ValuesUnitPressureLevelStart(builder)

def ValuesUnitPressureLevelAddUnit(builder: flatbuffers.Builder, unit: int):
    builder.PrependInt8Slot(0, unit, 0)

def AddUnit(builder: flatbuffers.Builder, unit: int):
    ValuesUnitPressureLevelAddUnit(builder, unit)

def ValuesUnitPressureLevelAddValues(builder: flatbuffers.Builder, values: int):
    builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(values), 0)

def AddValues(builder: flatbuffers.Builder, values: int):
    ValuesUnitPressureLevelAddValues(builder, values)

def ValuesUnitPressureLevelStartValuesVector(builder, numElems: int) -> int:
    return builder.StartVector(4, numElems, 4)

def StartValuesVector(builder, numElems: int) -> int:
    return ValuesUnitPressureLevelStartValuesVector(builder, numElems)

def ValuesUnitPressureLevelEnd(builder: flatbuffers.Builder) -> int:
    return builder.EndObject()

def End(builder: flatbuffers.Builder) -> int:
    return ValuesUnitPressureLevelEnd(builder)
