concat ?sep list returns the concatenation of list with sep in between each.
Checking
val check_args :
loc:Base.string ->pos:Base.int ->len:Base.int ->t->Base.unit
check_args ~loc ~pos ~len bstr checks the position and length arguments pos and len for bigstrings bstr.
raises
Invalid_argument if these arguments are illegal for the given bigstring using loc to indicate the calling context.
val get_opt_len : t->pos:Base.int ->Base.int Base.option->Base.int
get_opt_len bstr ~pos opt_len
returns
the length of a subbigstring in bstr starting at position pos and given optional length opt_len. This function does not check the validity of its arguments. Use check_args for that purpose.
module From_bytes :
Base.Blit.S_distinct withtypesrc := Base.byteswithtypedst := t
val memset : t->pos:Base.int ->len:Base.int ->Base.char ->Base.unit
memset t ~pos ~len c fills t with c within the range [pos, pos + len).
val unsafe_memset : t->pos:Base.int ->len:Base.int ->Base.char ->Base.unit
unsafe_memset t ~pos ~len c fills t with c within the range [pos, pos + len), without bounds checks.
Memcmp
val memcmp :
t->pos1:Base.int ->t->pos2:Base.int ->len:Base.int ->Base.int
memcmp t1 ~pos1 t2 ~pos2 ~len is like compare t1 t2 except performs the comparison on the subregions of t1 and t2 defined by pos1, pos2, and len.
val memcmp_bytes :
t->pos1:Base.int ->Base.Bytes.t ->pos2:Base.int ->len:Base.int ->Base.int
memcmp_bytes, for efficient memcmp between Bigstring and Bytes data.
val memcmp_string :
t->pos1:Base.int ->Base.string ->pos2:Base.int ->len:Base.int ->Base.int
memcmp_string, for efficient memcmp between Bigstring and string data.
Search
val find :
?pos:Base.int ->?len:Base.int ->Base.char ->t->Base.int Base.option
find ?pos ?len char t returns Some i for the smallest i >= pos such that t.{i} = char, or None if there is no such i.
parameterpos
default = 0
parameterlen
default = length bstr - pos
val unsafe_find : t->Base.char ->pos:Base.int ->len:Base.int ->Base.int
Same as find, but does no bounds checking, and returns a negative value instead of None if char is not found.
val memmem :
haystack:t->needle:t->?haystack_pos:Base.int ->?haystack_len:Base.int ->?needle_pos:Base.int ->?needle_len:Base.int ->Base.unit ->Base.int Base.option
Search for the position of (a substring of) needle in (a substring of) haystack.
val unsafe_memmem :
haystack:t->needle:t->haystack_pos:Base.int ->haystack_len:Base.int ->needle_pos:Base.int ->needle_len:Base.int ->Base.int
As unsafe_find for memmem.
Accessors for parsing binary values, analogous to Binary_packing
These are in Bigstring rather than a separate module because:
1. Existing Binary_packing requires copies and does not work with bigstrings. 2. The accessors rely on the implementation of bigstring, and hence should change should the implementation of bigstring move away from Bigarray. 3. Bigstring already has some external C functions, so it didn't require many changes to the jbuild ^_^.
In a departure from Binary_packing, the naming conventions are chosen to be close to C99 stdint types, as it's a more standard description and it is somewhat useful in making compact macros for the implementations. The accessor names contain endian-ness to allow for branch-free implementations
val set_uint32_le_exn : t->pos:Base.int ->Base.int ->Base.unit
val set_uint32_be_exn : t->pos:Base.int ->Base.int ->Base.unit
val unsafe_get_uint32_le : t->pos:Base.int ->Base.int
val unsafe_get_uint32_be : t->pos:Base.int ->Base.int
val unsafe_set_uint32_le : t->pos:Base.int ->Base.int ->Base.unit
val unsafe_set_uint32_be : t->pos:Base.int ->Base.int ->Base.unit
Similar to the usage in binary_packing, the below methods are treating the value being read (or written), as an ocaml immediate integer, as such it is actually 63 bits. If the user is confident that the range of values used in practice will not require 64-bit precision (i.e. Less than Max_Long), then we can avoid allocation and use an immediate. If the user is wrong, an exception will be thrown (for get).