Module Common

module Common: sig .. end
Common definitions used by binary protocol converters


Buffers


type pos = int 
Position within buffers
type pos_ref = pos Pervasives.ref 
Reference to a position within buffers
type buf = (char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t 
Buffers
val create_buf : int -> buf
create_buf n creates a buffer of size n.
val check_pos : buf -> pos -> unit
check_pos buf pos
Raises Buffer_short if position pos exceeds the length of buffer buf.
val check_next : buf -> pos -> unit
check_next buf pos
Raises Buffer_short if the next position after pos exceeds the length of buffer buf.
val safe_get_pos : buf -> pos_ref -> pos
safe_get_pos buf pos_ref
Raises Buffer_short if the position exceeds the length of the buffer.
Returns the position referenced by pos_ref within buffer buf.
val blit_string_buf : ?src_pos:int -> string -> ?dst_pos:int -> buf -> len:int -> unit
blit_string_buf ?src_pos src ?dst_pos dst ~len blits len bytes of the source string src starting at position src_pos to buffer dst starting at position dst_pos.
Raises Invalid_argument if the designated ranges are invalid.
val blit_buf_string : ?src_pos:int -> buf -> ?dst_pos:int -> string -> len:int -> unit
blit_buf_string ?src_pos src ?dst_pos dst ~len blits len bytes of the source buffer src starting at position src_pos to string dst starting at position dst_pos.
Raises Invalid_argument if the designated ranges are invalid.
val blit_buf : ?src_pos:int ->
src:buf -> ?dst_pos:int -> dst:buf -> int -> unit
blit_buf ?src_pos ~src ?dst_pos ~dst len blits len bytes of the source buffer src starting at position src_pos to destination buffer dst starting at position dst_pos.
Raises Invalid_argument if the designated ranges are invalid.

Errors and exceptions


exception Buffer_short
Buffer too short for read/write operation
exception No_variant_match
Used internally for backtracking
module ReadError: sig .. end
exception Read_error of ReadError.t * pos
ReadError (err, err_pos)
exception Read_exc of exn * pos
ReadExc (exn, err_pos)
exception Poly_rec_write of string
PolyRecWrite type gets raised when the user attempts to write or estimate the size of a value of a type that is bound through a polymorphic record field in type definition type.
exception Empty_type of string
EmptyType gets raised when the user attempts to write or estimate the size of a value of an empty type, which would not make sense.
val raise_read_error : ReadError.t -> pos -> 'a
raise_read_error err pos
val raise_read_exc : exn -> pos -> 'a
raise_read_exc exc pos
val raise_concurrent_modification : string -> 'a
raise_concurrent_modification loc
Raises Failure if a binary writer detects a concurrent change to the underlying data structure.
val array_bound_error : unit -> 'a
array_bound_error ()

Bigarrays


type vec32 = (float, Bigarray.float32_elt, Bigarray.fortran_layout) Bigarray.Array1.t 
type vec64 = (float, Bigarray.float64_elt, Bigarray.fortran_layout) Bigarray.Array1.t 
type vec = vec64 
type mat32 = (float, Bigarray.float32_elt, Bigarray.fortran_layout) Bigarray.Array2.t 
type mat64 = (float, Bigarray.float64_elt, Bigarray.fortran_layout) Bigarray.Array2.t 
type mat = mat64 

Miscellaneous


val copy_htbl_list : ('a, 'b) Hashtbl.t -> ('a * 'b) list -> ('a, 'b) Hashtbl.t
copy_htbl_list htbl lst adds all (key, value) pairs in lst to hash table htbl.
val variant_of_int : int -> [>  ]

NOTE: unsafe functions!!!


val unsafe_blit_buf : src_pos:int ->
src:buf -> dst_pos:int -> dst:buf -> len:int -> unit
val unsafe_blit_string_buf : src_pos:int -> string -> dst_pos:int -> buf -> len:int -> unit
val unsafe_blit_buf_string : src_pos:int -> buf -> dst_pos:int -> string -> len:int -> unit