a
    Sic2  ã                   @   s,   d dl mZ d dl mZ G dd„ deƒZdS )é   )Úencode)Únumber_typesc                   @   st   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚTablezŒTable wraps a byte slice and provides read access to its data.

    The variable `Pos` indicates the root of the FlatBuffers object therein.)ÚBytesÚPosc                 C   s   t  |t j¡ || _|| _d S )N)ÚNÚenforce_numberÚUOffsetTFlagsr   r   )ÚselfÚbufÚpos© r   úM/var/www/html/django/DPS/env/lib/python3.9/site-packages/flatbuffers/table.pyÚ__init__   s    zTable.__init__c                 C   sB   | j |  tj| j ¡ }|  tj|¡}||k r>|  tj|| ¡S dS )zwOffset provides access into the Table's vtable.

        Deprecated fields are ignored by checking the vtable's length.é    )r   ÚGetr   ÚSOffsetTFlagsÚVOffsetTFlags)r
   ZvtableOffsetZvtableZ	vtableEndr   r   r   ÚOffset    s
    zTable.Offsetc                 C   s&   t  |t j¡ |t t jj| j|¡ S )z:Indirect retrieves the relative offset stored at `offset`.)r   r   r	   r   r   Úpacker_typer   )r
   Úoffr   r   r   ÚIndirect+   s    zTable.Indirectc                 C   s\   t  |t j¡ |t t jj| j|¡7 }|t jj }t t jj| j|¡}t| j||| … ƒS )z<String gets a string from data stored inside the flatbuffer.)	r   r   r	   r   r   r   r   Ú	bytewidthÚbytes)r
   r   ÚstartÚlengthr   r   r   ÚString0   s
    zTable.Stringc                 C   sH   t  |t j¡ || j7 }|t t jj| j|¡7 }t 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   Úretr   r   r   Ú	VectorLen8   s
    
zTable.VectorLenc                 C   s:   t  |t j¡ || j7 }||  t j|¡ }|t jj7 }|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   Úxr   r   r   ÚVectorB   s
    
zTable.Vectorc                 C   sH   t |ƒtu sJ ‚t |tj¡ || j7 }||  tj|¡ |_| j|_dS )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   r   r   r   ÚUnionM   s
    
zTable.Unionc                 C   s&   t  |t j¡ | t |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   r   r   r   r   W   s    z	Table.Getc                 C   sJ   t  |t j¡ |d ur"t  ||¡ |  |¡}|dkr8|S |  || j| ¡S )Nr   )r   r   r   r   r   r   )r
   ÚslotÚdZvalidator_flagsr   r   r   r   ÚGetSlot_   s    
zTable.GetSlotc                 C   s0   |   |¡}|  |¡}t |¡}t || 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
   r%   r   Úoffsetr   Únumpy_dtyper   r   r   r*   h   s    


zTable.GetVectorAsNumpyc                 C   s   t  |¡}t || 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   r)   r   r*   r   )r
   r%   r   r   r,   r   r   r   ÚGetArrayAsNumpyt   s    
zTable.GetArrayAsNumpyc                 C   s6   t  |t j¡ t  |t j¡ |  |¡}|dkr2|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
   r&   r'   r   r   r   r   ÚGetVOffsetTSlot}   s    
zTable.GetVOffsetTSlotN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r   r   r   r    r#   r   r(   r*   r-   r.   r   r   r   r   r      s   

		r   N)Ú r   r   r   Úobjectr   r   r   r   r   Ú<module>   s   