U
    dª/e  ã                   @   sˆ   d dl Z ddlm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d„ ZdS ) é    Né   )Úwrite_varintl   ÿÿÿÿ l   ÿÿÿÿ c                 C   s
   t | fƒS ©N)Úbytes)Úb© r   ú</tmp/pip-unpacked-wheel-mds_o03w/clickhouse_driver/writer.pyÚ_byte
   s    r	   c                 C   s   |   d¡} t| |ƒ d S )Nzutf-8)ÚencodeÚwrite_binary_bytes©ÚtextÚbufr   r   r   Úwrite_binary_str   s    
r   c                 C   s   t t| ƒ|ƒ | | ¡ d S r   )r   ÚlenÚwriter   r   r   r   r      s    r   c                 C   s   d| }|  t || ¡¡ dS )z6
    Writes int from buffer with provided format.
    ú<N)r   ÚstructÚpack)Únumberr   Úfmtr   r   r   Úwrite_binary_int   s    r   c                 C   s   t | |dƒ d S )Nr   ©r   ©r   r   r   r   r   Úwrite_binary_int8    s    r   c                 C   s   t | |dƒ d S )NÚhr   r   r   r   r   Úwrite_binary_int16$   s    r   c                 C   s   t | |dƒ d S )NÚir   r   r   r   r   Úwrite_binary_int32(   s    r   c                 C   s   t | |dƒ d S )NÚqr   r   r   r   r   Úwrite_binary_int64,   s    r    c                 C   s   t | |dƒ d S )NÚBr   r   r   r   r   Úwrite_binary_uint80   s    r"   c                 C   s   t | |dƒ d S )NÚHr   r   r   r   r   Úwrite_binary_uint164   s    r$   c                 C   s   t | |dƒ d S )NÚIr   r   r   r   r   Úwrite_binary_uint328   s    r&   c                 C   s   t | |dƒ d S )NÚQr   r   r   r   r   Úwrite_binary_uint64<   s    r(   c                 C   s,   d}t  || d? t@ | t@ ¡}| |¡ d S )Nz<QQé@   )r   r   Ú
MAX_UINT64r   )r   r   r   Úpackedr   r   r   Úwrite_binary_uint128@   s    r,   )r   Zvarintr   r*   Z	MAX_INT64r	   r   r   r   r   r   r   r    r"   r$   r&   r(   r,   r   r   r   r   Ú<module>   s    