Package index
slice
Library slice.bstr
Slice_bstr
Module
Module Slice_bstr Source Slices on a bigstring (Bstr.t ).
This module implements Slice.S : it offers exactly the same API as Slice_bytes (and mirrors Bstr ), so that the same code can be used regardless of the underlying byte sequence.
sub and shift are O(1): they share the underlying bigstring with the given slice instead of calling Bstr.sub (which is about 8 times slower).
This module is the result of a poor man 's functor designed to avoid the inherent overhead that can arise from using functors in OCaml. In other words, the implementation is the same as that of Slice_bytes.
include Slice.S with type buf = Bstr.t include Slice.R with type buf := buf and type t := t create len is a fresh t of length len. Its contents are reset to zero (bytes are set to '\000').
make ~off ~len buf is the view of buf which starts at off (defaults to 0) and which is len bytes long (defaults to length buf - off). The buffer is not copied.
Source val init : int -> (int -> char) -> t init len fn is t of length len with index idx holding the character fn idx (called in increasing index order).
length t is the length (number of bytes/characters) of t.
is_empty t is length t = 0.
Source val chop : ?rev :bool -> t -> char option chop t is Some (get t idx) with idx = 0 if rev = false (default) or idx = length t - 1 if rev = true. None is returned if t is empty.
Source val constant_equal : t -> t -> boolget t i is the byte of t at index i.
Bounds are the ones of the slice , not the ones of the underlying buffer: a slice never gives access to a byte which is outside of its own range.
Source val unsafe_get : t -> int -> charunsafe_get t i is get without any bound checking.
Source val get_int8 : t -> int -> intget_int8 bstr i is bstr's signed 8-bit integer starting at byte index i.
Source val get_uint8 : t -> int -> intget_uint8 bstr i is bstr's unsigned 8-bit integer starting at byte index i.
Source val get_uint16_ne : t -> int -> intget_uint16_ne slice i is slice's native-endian unsigned 16-bit integer starting at byte index i.
Source val get_uint16_le : t -> int -> intget_uint16_le slice i is slice's little-endian unsigned 16-bit integer starting at byte index i.
Source val get_uint16_be : t -> int -> intget_uint16_be slice i is slice's big-endian unsigned 16-bit integer starting at byte index i.
Source val get_int16_ne : t -> int -> intget_int16_ne slice i is slice's native-endian signed 16-bit integer starting at byte index i.
Source val get_int16_le : t -> int -> intget_int16_le slice i is slice's little-endian signed 16-bit integer starting at byte index i.
Source val get_int16_be : t -> int -> intget_int16_be slice i is slice's big-endian signed 16-bit integer starting at byte index i.
Source val get_int32_ne : t -> int -> int32get_int32_ne slice i is slice's native-endian 32-bit integer starting at byte index i.
Source val get_int32_le : t -> int -> int32get_int32_le slice i is slice's little-endian 32-bit integer starting at byte index i.
Source val get_int32_be : t -> int -> int32get_int32_be slice i is slice's big-endian 32-bit integer starting at byte index i.
Source val get_int64_ne : t -> int -> int64get_int64_ne slice i is slice's native-endian 64-bit integer starting at byte index i.
Source val get_int64_le : t -> int -> int64get_int64_le slice i is slice's little-endian 64-bit integer starting at byte index i.
Source val get_int64_be : t -> int -> int64get_int64_be slice i is slice's big-endian 64-bit integer starting at byte index i.
Source val filter : (char -> bool) -> t -> t filter sat slice is a fresh slice made of the bytes of slice that satisfy sat, in the same order.
Source val filter_map : (char -> char option ) -> t -> t filter_map fn t is a fresh slice made of the bytes of t as mapped by fn, in the same order.
Source val map : (char -> char) -> t -> t Source val mapi : (int -> char -> char) -> t -> t Source val fold_left : ('a -> char -> 'a ) -> 'a -> t -> 'a Source val fold_right : (char -> 'a -> 'a ) -> t -> 'a -> 'a Source val iter : (char -> unit) -> t -> unitSource val iteri : (int -> char -> unit) -> t -> unitSource val overlap : t -> t -> (int * int * int) optionSource val starts_with : prefix :string -> t -> boolSource val is_prefix : affix :string -> t -> boolis_prefix ~affix slice is true iff affix.[idx] = get slice idx for all indices idx of affix.
Source val ends_with : suffix :string -> t -> boolSource val is_suffix : affix :string -> t -> boolis_suffix ~affix slice is true iff affix.[n - idx] = get slice (m - idx) for all indices idx of affix with n = String.length affix - 1 and m = length slice - 1.
Source val is_infix : affix :string -> t -> boolis_infix ~affix slice is true iff there exists an index j in slice such that for all indices i of affix we have affix.[i] = get t (j + i).
Source val for_all : (char -> bool) -> t -> boolSource val exists : (char -> bool) -> t -> boolSource val trim : ?drop :(char -> bool) -> t -> t Source val span :
?rev :bool ->
?min :int ->
?max :int ->
?sat :(char -> bool) ->
t ->
t * t Source val take : ?rev :bool -> ?min :int -> ?max :int -> ?sat :(char -> bool) -> t -> t Source val drop : ?rev :bool -> ?min :int -> ?max :int -> ?sat :(char -> bool) -> t -> t Source val sub : t -> off :int -> len :int -> t Source val split_on_char : char -> t -> t listSource val cut : ?rev :bool -> sep :string -> t -> (t * t ) optionSource val cuts : ?rev :bool -> ?empty :bool -> sep :string -> t -> t listSource val index : t -> ?off :int -> ?len :int -> char -> int option Source val contains : t -> ?off :int -> ?len :int -> char -> boolSource val concat : string -> t list -> t Source val sub_string : t -> off :int -> len :int -> stringSource val string : ?off :int -> ?len :int -> string -> t Source val blit_to_bytes :
t ->
?src_off :int ->
bytes ->
dst_off :int ->
len :int ->
unitSource val with_range : ?first :int -> ?len :int -> t -> t Source val with_index_range : ?first :int -> ?last :int -> t -> t include Slice.W with type t := t Source val set : t -> int -> char -> unitSource val unsafe_set : t -> int -> char -> unitSource val set_int8 : t -> int -> int -> unitSource val set_uint8 : t -> int -> int -> unitSource val set_uint16_ne : t -> int -> int -> unitSource val set_uint16_le : t -> int -> int -> unitSource val set_uint16_be : t -> int -> int -> unitSource val set_int16_ne : t -> int -> int -> unitSource val set_int16_le : t -> int -> int -> unitSource val set_int16_be : t -> int -> int -> unitSource val set_int32_ne : t -> int -> int32 -> unitSource val set_int32_le : t -> int -> int32 -> unitSource val set_int32_be : t -> int -> int32 -> unitSource val set_int64_ne : t -> int -> int64 -> unitSource val set_int64_le : t -> int -> int64 -> unitSource val set_int64_be : t -> int -> int64 -> unitSource val fill : t -> ?off :int -> ?len :int -> char -> unitSource val blit_from_bytes : bytes -> src_off :int -> t -> ?dst_off :int -> int -> unitSource val blit_from_string :
string ->
src_off :int ->
t ->
?dst_off :int ->
int ->
unit