type t = (char, Bigarray_compat.int8_unsigned_elt, Bigarray_compat.c_layout) Bigarray_compat.Array1.t
Constructors
val create : int -> t
create n
returns a bigstring of length n
val empty : t
empty
is the empty bigstring. It has length 0
and you can't really do much with it, but it's a good placeholder that only needs to be allocated once.
val of_string : off:int -> len:int -> string -> t
of_string ~off ~len s
returns a bigstring of length len
that contains the contents of string from the range [off, len)
.
copy t ~off ~len
allocates a new bigstring of length len
and copies the bytes from t
copied into it starting from off
.
sub t ~off ~len
does not allocate a bigstring, but instead returns a new view into t
starting at off
, and with length len
.
Note that this does not allocate a new buffer, but instead shares the buffer of t
with the newly-returned bigstring.
Memory-safe Operations
val length : t -> int
length t
is the length of the bigstring, in bytes.
val substring : t -> off:int -> len:int -> string
substring t ~off ~len
returns a string of length len
containing the bytes of t
starting at off
.
val to_string : t -> string
to_string t
is equivalent to substring t ~off:0 ~len:(length t)
val get : t -> int -> char
get t i
returns the character at offset i
in t
.
val set : t -> int -> char -> unit
set t i c
sets the character at offset i
in t
to be c
Little-endian Byte Order
val get_int16_le : t -> int -> int
get_int16_le t i
returns the two bytes in t
starting at offset i
, interpreted as an unsigned integer.
val get_int16_sign_extended_le : t -> int -> int
get_int16_sign_extended_le t i
returns the two bytes in t
starting at offset i
, interpreted as a signed integer and performing sign extension to the native word size before returning the result.
val set_int16_le : t -> int -> int -> unit
set_int16_le t i v
sets the two bytes in t
starting at offset i
to the value v
.
val get_int32_le : t -> int -> int32
get_int32_le t i
returns the four bytes in t
starting at offset i
.
val set_int32_le : t -> int -> int32 -> unit
set_int32_le t i v
sets the four bytes in t
starting at offset i
to the value v
.
val get_int64_le : t -> int -> int64
get_int64_le t i
returns the eight bytes in t
starting at offset i
.
val set_int64_le : t -> int -> int64 -> unit
set_int64_le t i v
sets the eight bytes in t
starting at offset i
to the value v
.
Big-endian Byte Order
val get_int16_be : t -> int -> int
get_int16_be t i
returns the two bytes in t
starting at offset i
, interpreted as an unsigned integer.
val get_int16_sign_extended_be : t -> int -> int
get_int16_sign_extended_be t i
returns the two bytes in t
starting at offset i
, interpreted as a signed integer and performing sign extension to the native word size before returning the result.
val set_int16_be : t -> int -> int -> unit
set_int16_be t i v
sets the two bytes in t
starting at offset off
to the value v
.
val get_int32_be : t -> int -> int32
get_int32_be t i
returns the four bytes in t
starting at offset i
.
val set_int32_be : t -> int -> int32 -> unit
set_int32_be t i v
sets the four bytes in t
starting at offset i
to the value v
.
val get_int64_be : t -> int -> int64
get_int64_be t i
returns the eight bytes in t
starting at offset i
.
val set_int64_be : t -> int -> int64 -> unit
set_int64_be t i v
sets the eight bytes in t
starting at offset i
to the value v
.
Blits
val blit_from_string : string -> src_off:int -> t -> dst_off:int -> len:int -> unit
val blit_from_bytes : Stdlib.Bytes.t -> src_off:int -> t -> dst_off:int -> len:int -> unit
val blit_to_bytes : t -> src_off:int -> Stdlib.Bytes.t -> dst_off:int -> len:int -> unit
memcmp
val memcmp_string : t -> int -> string -> int -> int -> int
Memory-unsafe Operations
val unsafe_set : t -> int -> char -> unit
unsafe_set t i c
is like set
except no bounds checking is performed.
val unsafe_get_int16_le : t -> int -> int
unsafe_get_int16_le t i
is like get_int16_le
except no bounds checking is performed.
val unsafe_get_int16_be : t -> int -> int
unsafe_get_int16_be t i
is like get_int16_be
except no bounds checking is performed.
val unsafe_get_int16_sign_extended_le : t -> int -> int
unsafe_get_int16_sign_extended_le t i
is like get_int16_sign_extended_le
except no bounds checking is performed.
val unsafe_get_int16_sign_extended_be : t -> int -> int
unsafe_get_int16_sign_extended_be t i
is like get_int16_sign_extended_be
except no bounds checking is performed.
val unsafe_set_int16_le : t -> int -> int -> unit
unsafe_set_int16_le t i v
is like set_int16_le
except no bounds checking is performed.
val unsafe_set_int16_be : t -> int -> int -> unit
unsafe_set_int16_be t i v
is like set_int16_be
except no bounds checking is performed.
val unsafe_get_int32_le : t -> int -> int32
unsafe_get_int32_le t i
is like get_int32_le
except no bounds checking is performed.
val unsafe_get_int32_be : t -> int -> int32
unsafe_get_int32_be t i
is like get_int32_be
except no bounds checking is performed.
val unsafe_set_int32_le : t -> int -> int32 -> unit
unsafe_set_int32_le t i v
is like set_int32_le
except no bounds checking is performed.
val unsafe_set_int32_be : t -> int -> int32 -> unit
unsafe_set_int32_be t i v
is like set_int32_be
except no bounds checking is performed.
val unsafe_get_int64_le : t -> int -> int64
unsafe_get_int64_le t i
is like get_int64_le
except no bounds checking is performed.
val unsafe_get_int64_be : t -> int -> int64
unsafe_get_int64_be t i
is like get_int64_be
except no bounds checking is performed.
val unsafe_set_int64_le : t -> int -> int64 -> unit
unsafe_set_int64_le t i v
is like set_int64_le
except no bounds checking is performed.
val unsafe_set_int64_be : t -> int -> int64 -> unit
unsafe_set_int64_be t i v
is like set_int64_be
except no bounds checking is performed.
Blits
val unsafe_blit_from_string : string -> src_off:int -> t -> dst_off:int -> len:int -> unit
val unsafe_blit_from_bytes : Stdlib.Bytes.t -> src_off:int -> t -> dst_off:int -> len:int -> unit
val unsafe_blit_to_bytes : t -> src_off:int -> Stdlib.Bytes.t -> dst_off:int -> len:int -> unit
memcmp
val unsafe_memcmp_string : t -> int -> string -> int -> int -> int