Module Io


module Io: sig .. end
High-order abstract I/O.

IO module simply deals with abstract inputs/outputs. It provides a set of methods for working with these IO as well as several constructors that enable to write to an underlying channel, buffer, or enum.


type input 
The abstract input type.
exception No_more_input
This exception is raised when reading on an input with the read or nread functions while there is no available token to read.
exception Input_closed
This exception is raised when reading on a closed input.
val nread : input -> int -> Istring.t
Standard API

nread i n reads a string of size up to n from an input. The function will raise No_more_input if no input is available. It will raise Invalid_argument if n < 0.

val close_in : input -> unit
Close the input. It can no longer be read from.
val create_in : (unit -> char) ->
(Istring.t -> int -> int -> int) -> (unit -> unit) -> input
Creation of IO Inputs/Outputs


Fully create an input by giving all the needed functions.
val read_all : input -> Istring.t
Utilities

read all the contents of the input until No_more_input is raised.


Binary files API

Here is some API useful for working with binary files, in particular binary files generated by C applications. By default, encoding of multibyte integers is low-endian. The BigEndian module provide multibyte operations with other encoding.

exception Overflow of string
Exception raised when a read or write operation cannot be completed.
val read_byte : input -> int
Read an unsigned 8-bit integer.
val read_ui16 : input -> int
Read an unsigned 16-bit word.