
    g2                     2    d dl mZ d dl mZ  G d de      Zy)   )encode)number_typesc                   \    e Zd ZdZdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zy)TablezTable wraps a byte slice and provides read access to its data.

    The variable `Pos` indicates the root of the FlatBuffers object therein.)BytesPosc                 h    t        j                  |t         j                         || _        || _        y )N)Nenforce_numberUOffsetTFlagsr   r   )selfbufposs      F/var/www/openai/venv/lib/python3.12/site-packages/flatbuffers/table.py__init__zTable.__init__   s$    	aoo.
    c                    | j                   | j                  t        j                  | j                         z
  }| j                  t        j                  |      }||k  r#| j                  t        j                  ||z         S y)zwOffset provides access into the Table's vtable.

        Deprecated fields are ignored by checking the vtable's length.    )r   Getr
   SOffsetTFlagsVOffsetTFlags)r   vtableOffsetvtable	vtableEnds       r   OffsetzTable.Offset    s^    
 DHHQ__dhh??HHQ__f5	)#88AOOVl-BCCr   c                     t        j                  |t         j                         |t        j                  t         j                  j
                  | j                  |      z   S )z:Indirect retrieves the relative offset stored at `offset`.)r
   r   r   r   r   packer_typer   )r   offs     r   IndirectzTable.Indirect+   s<    	aoo.VZZ ; ;TZZMMMr   c                    t        j                  |t         j                         |t        j                  t         j                  j
                  | j                  |      z  }|t         j                  j                  z   }t        j                  t         j                  j
                  | j                  |      }t        | j                  |||z          S )z<String gets a string from data stored inside the flatbuffer.)	r
   r   r   r   r   r   r   	bytewidthbytes)r   r   startlengths       r   StringzTable.String0   s    	aoo.vzz!//55tzz3GGaoo///AOO77SITZZeFl344r   c                 V   t        j                  |t         j                         || j                  z  }|t	        j
                  t         j                  j                  | j                  |      z  }t	        j
                  t         j                  j                  | j                  |      }|S )zgVectorLen retrieves the length of the vector whose offset is stored
           at "off" in this object.)r
   r   r   r   r   r   r   r   )r   r   rets      r   	VectorLenzTable.VectorLen8   so     	
aoo.txxvzz!//55tzz3GGjj44djj#F
r   c                     t        j                  |t         j                         || j                  z  }|| j	                  t         j                  |      z   }|t         j                  j
                  z  }|S )zkVector retrieves the start of data of the vector whose offset is
           stored at "off" in this object.)r
   r   r   r   r   r!   )r   r   xs      r   VectorzTable.VectorB   sW     	
aoo.txx$((1??C00	Q__&&&r   c                    t        |      t        u sJ t        j                  |t        j                         || j
                  z  }|| j                  t        j                  |      z   |_        | j                  |_        y)z^Union initializes any Table-derived type to point to the union at
           the given offset.N)typer   r
   r   r   r   r   r   )r   t2r   s      r   UnionzTable.UnionM   s]     Bx5   	aoo.txxtxx55::r   c                     t        j                  |t         j                         |j                  t	        j
                  |j                  | j                  |            S )zf
        Get retrieves a value of the type specified by `flags`  at the
        given offset.
        )r
   r   r   py_typer   r   r   r   )r   flagsr   s      r   r   z	Table.GetW   s>    
 	
aoo.}}VZZ(9(94::sKLLr   c                     t        j                  |t         j                         |t        j                  ||       | j                  |      }|dk(  r|S | j	                  || j
                  |z         S )Nr   )r
   r   r   r   r   r   )r   slotdvalidator_flagsr   s        r   GetSlotzTable.GetSlot_   s_    	q/&Q0kk$!8HxxC88r   c                     | j                  |      }| j                  |      }t        j                  |      }t	        j
                  || j                  ||      S )z
        GetVectorAsNumpy returns the vector that starts at `Vector(off)`
        as a numpy array with the type specified by `flags`. The array is
        a `view` into Bytes, so modifying the returned array will
        modify Bytes in place.
        )r+   r(   r
   to_numpy_typer   GetVectorAsNumpyr   )r   r2   r   offsetr$   numpy_dtypes         r   r:   zTable.GetVectorAsNumpyh   sI     S!$ooe,&&{DJJOOr   c                 p    t        j                  |      }t        j                  || j                  ||      S )a  
        GetArrayAsNumpy returns the array with fixed width that starts at `Vector(offset)`
        with length `length` as a numpy array with the type specified by `flags`. The
        array is a `view` into Bytes so modifying the returned will modify Bytes in place.
        )r
   r9   r   r:   r   )r   r2   r   r$   r<   s        r   GetArrayAsNumpyzTable.GetArrayAsNumpyt   s-     ooe,&&{DJJLLr   c                     t        j                  |t         j                         t        j                  |t         j                         | j                  |      }|dk(  r|S |S )z
        GetVOffsetTSlot retrieves the VOffsetT that the given vtable location
        points to. If the vtable value is zero, the default value `d`
        will be returned.
        r   )r
   r   r   r   )r   r4   r5   r   s       r   GetVOffsetTSlotzTable.GetVOffsetTSlot}   sK     	
q/	AOO,kk$!8H
r   N)__name__
__module____qualname____doc__	__slots__r   r   r   r%   r(   r+   r/   r   r7   r:   r>   r@    r   r   r   r      sO    P !I	N
5	M9
PMr   r   N) r   r   r
   objectr   rF   r   r   <module>rI      s     wF wr   