Module Bin_prot.Common
Buffers
type pos_ref
= pos Stdlib.ref
Reference to a position within buffers
val create_buf : int -> buf
create_buf n
creates a buffer of sizen
.
val buf_len : buf -> int
buf_len buf
returns the length ofbuf
.
val assert_pos : pos -> unit
assert_pos pos
- raises Invalid_argument
if position
pos
is negative.
val check_pos : buf -> pos -> unit
check_pos buf pos
- raises Buffer_short
if position
pos
exceeds the length of bufferbuf
.
val check_next : buf -> pos -> unit
check_next buf pos
- raises Buffer_short
if the next position after
pos
exceeds the length of bufferbuf
.
val safe_get_pos : buf -> pos_ref -> pos
safe_get_pos buf pos_ref
- returns
the position referenced by
pos_ref
within bufferbuf
.@raise Buffer_short
if the position exceeds the length of the buffer.
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
blitslen
bytes of the source stringsrc
starting at positionsrc_pos
to bufferdst
starting at positiondst_pos
.- raises Invalid_argument
if the designated ranges are invalid.
val blit_bytes_buf : ?src_pos:int -> bytes -> ?dst_pos:int -> buf -> len:int -> unit
blit_bytes_buf ?src_pos src ?dst_pos dst ~len
blitslen
bytes of the source byte sequencesrc
starting at positionsrc_pos
to bufferdst
starting at positiondst_pos
.- raises Invalid_argument
if the designated ranges are invalid.
val blit_buf_string : ?src_pos:int -> buf -> ?dst_pos:int -> bytes -> len:int -> unit
blit_buf_string ?src_pos src ?dst_pos dst ~len
blitslen
bytes of the source buffersrc
starting at positionsrc_pos
to stringdst
starting at positiondst_pos
.- raises Invalid_argument
if the designated ranges are invalid.
val blit_buf_bytes : ?src_pos:int -> buf -> ?dst_pos:int -> bytes -> len:int -> unit
blit_buf_bytes ?src_pos src ?dst_pos dst ~len
blitslen
bytes of the source buffersrc
starting at positionsrc_pos
to byte sequencedst
starting at positiondst_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
blitslen
bytes of the source buffersrc
starting at positionsrc_pos
to destination bufferdst
starting at positiondst_pos
.- raises Invalid_argument
if the designated ranges are invalid.
Errors and exceptions
module ReadError : sig ... end
exception
Read_error of ReadError.t * pos
ReadError (err, 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 definitiontype
.
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_variant_wrong_type : string -> pos -> 'a
raise_variant_wrong_type name pos
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
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_bytes_buf : src_pos:int -> bytes -> dst_pos:int -> buf -> len:int -> unit
val unsafe_blit_buf_string : src_pos:int -> buf -> dst_pos:int -> bytes -> len:int -> unit
val unsafe_blit_buf_bytes : src_pos:int -> buf -> dst_pos:int -> bytes -> len:int -> unit
val unsafe_blit_float_array_buf : src_pos:int -> float array -> dst_pos:int -> buf -> len:int -> unit
val unsafe_blit_buf_float_array : src_pos:int -> buf -> dst_pos:int -> float array -> len:int -> unit