Source

ocaml-core / base / core / lib / binary_packing.mli

The branch 'bash' does not exist.
(* Packs and unpacks various types of integers into and from strings.

   Functions ending in _int should not be used on 32 bit programs because native ocaml
   ints will not be big enough.

   [pos] arguments refer to the location in the buf string.

   We support big and little endian ints.  Note that for an 8 bit (1 byte) integer, there
   is no difference because endian-ness only changes the order of bytes, not bits.
*)

type endian = [ `Big_endian | `Little_endian ]

val unpack_signed_8      :                      buf:string -> pos:int -> int
val   pack_signed_8      :                      buf:string -> pos:int -> int -> unit

val unpack_unsigned_8    :                      buf:string -> pos:int -> int
val   pack_unsigned_8    :                      buf:string -> pos:int -> int -> unit

val unpack_signed_16     : byte_order:endian -> buf:string -> pos:int -> int
val   pack_signed_16     : byte_order:endian -> buf:string -> pos:int -> int -> unit

val unpack_signed_32     : byte_order:endian -> buf:string -> pos:int -> int32
val unpack_signed_32_int : byte_order:endian -> buf:string -> pos:int -> int
val   pack_signed_32     : byte_order:endian -> buf:string -> pos:int -> Int32.t -> unit
val   pack_signed_32_int : byte_order:endian -> buf:string -> pos:int -> int -> unit

val unpack_signed_64     : byte_order:endian -> buf:string -> pos:int -> int64
val unpack_signed_64_int : byte_order:endian -> buf:string -> pos:int -> int
val   pack_signed_64     : byte_order:endian -> buf:string -> pos:int -> Int64.t -> unit
val   pack_signed_64_int : byte_order:endian -> buf:string -> pos:int -> int -> unit

val unpack_float         : byte_order:endian -> buf:string -> pos:int -> float
val pack_float           : byte_order:endian -> buf:string -> pos:int -> float -> unit

val test : unit -> unit
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.