Page
Library
Module
Module type
Parameter
Class
Class type
Source
PdfioGeneric Input/Ouput from/to channels, strings, files etc.
type input = {pos_in : unit -> int;seek_in : int -> unit;input_char : unit -> char option;input_byte : unit -> int;in_channel_length : int;set_offset : int -> unit;caml_channel : in_channel option;source : string;}An input.
pos_in () will give the current position (i.e the index of the next byte to be read) in the range zero to the length of the channel minus one.seek_in x moves to a given position.input_char () returns None if end of input, or the next byte of the input as a character.input_byte () returns the next byte as an integer, or Pdfio.no_more in case of end of input.in_channel_length is the length of the channel.set_offset shifts the channel so positions run from offset to channel_length + offset - 1 instead of 0 to channel_length - 1.caml_channel is the underlying OCaml channel (if any) of the input.source is a string used to inficate the original source of the data, for debugging purposes.type output = {pos_out : unit -> int;seek_out : int -> unit;output_char : char -> unit;output_byte : int -> unit;output_string : string -> unit;out_caml_channel : out_channel option;out_channel_length : unit -> int;}An output.
pos_out () gives the position of the next byte to be writtenseek_out x moves to a a given position in the outputoutput_char writes a given character as the next byteoutput_byte writes an integer between 0 and 255 as the next byteoutput_string writes a string as a sequence of bytesout_caml_channel holds the OCaml channel this output is based on, if anyout_channel_length () gives the current length of the output channelval input_of_channel : ?source:string -> in_channel -> inputMake an input from an OCaml input channel.
val input_of_string : ?source:string -> string -> inputMake an input from a string.
val output_of_channel : out_channel -> outputMake an output from an OCaml channel
An input-output in this context is an output of a bytes, whose content can be extracted to another bytes having been written. For example, one might use a write bitstream (see below), and then extract the result into a bytes
Build an input-ouput, with an initial buffer size.
Extract the contents of an input-output in bytes
val nudge : input -> unitMove forward one byte
val rewind : input -> unitMove backward one byte
val peek_char : input -> char optionLook at the next character without advancing the pointer.
val peek_byte : input -> intLook at the next byte without advancing the pointer. Returns Pdfio.no_more for end of file.
val read_char_back : input -> char optionRead the previous character (if there is one), moving the pointer back one.
val read_line : input -> stringRead a line from an input in the manner of Stdlib.read_line.
val read_lines : input -> string listRead all the lines in an input, in the manner of Stdlib.read_line.
val mkbytes : int -> bytesMake bytes from a given size. Contents not initialized.
val bytes_size : bytes -> intSize of bytes.
val fillbytes : int -> bytes -> unitFill bytes with a value
val print_bytes : bytes -> unitPrint bytes to standard output. Format undefined: for debug only.
val bget : bytes -> int -> intGet the value at a position in a bytes
val bget_unsafe : bytes -> int -> intLike bget, but with no range checking
getinit f s o l calls f on each s within o...l - 1
val bset : bytes -> int -> int -> unitbset s n v sets the value n at position v in bytes
val bset_unsafe : bytes -> int -> int -> unitLike bset but with no range checking
setinit i s o l sets s o...o + l - 1 from the input
val setinit_string : input -> caml_bytes -> int -> int -> unitsetinit_string i s o l sets s o...o + l - 1 from the input
bytes_of_input i o l gives a bytes with s o...o + l - 1 from the input
val string_of_input : input -> stringstring_of_input i gives a string with the contents of i
val bytes_of_string : string -> bytesMake bytes from a string.
val bytes_of_caml_bytes : caml_bytes -> bytesMake bytes from ocaml bytes.
val bytes_of_list : int list -> bytesMake bytes from a list of integers, each between 0 and 255.
val bytes_of_charlist : char list -> bytesMake bytes from a character list.
val bytes_of_arraylist : int array list -> bytesMake bytes from a list of integer arrays.
val bytes_of_int_array : int array -> bytesMake bytes from an integer array
val int_array_of_bytes : bytes -> int arrayAn integer array of bytes from bytes
val bytes_selfmap : (int -> int) -> bytes -> unitMap bytes onto itself using a function on each byte
val string_of_bytes : bytes -> stringMake a string from a bytes. Fails if array is longer than String.max_length.
val charlist_of_bytes : bytes -> char listMake a character list from a bytes
val bytes_to_output_channel : out_channel -> bytes -> unitWrite a bytes to an output channel
val bytes_of_input_channel : in_channel -> bytesExtract a bytes from an input or output.
The type of most-significant-bit-first bitstreams over inputs.
val bitstream_pos : bitstream -> bitstream_positionGet the current position. It's abstract, so can't be manipulated, but it can be used to return to a previous point
val bitstream_seek : bitstream -> bitstream_position -> unitSeek to a position within a bitstream
val getbit : bitstream -> boolGet a bit
val getbitint : bitstream -> intGet a bit, but as an integer, 0 or 1.
val align : bitstream -> unitAlign the bitstream on a byte boundary
val getval_32 : bitstream -> int -> int32Get up to 32 bits as a 32 bit value
val getval_31 : bitstream -> int -> intGet up to 31 bits as a native integer
val make_write_bitstream : unit -> bitstream_writeReturn a new write bistream.
val putbit : bitstream_write -> int -> unitPut a single bit, 0 or 1.
val putval : bitstream_write -> int -> int32 -> unitPut a multi-bit value (given as an int32) containing the given number of useful bits into a bitstream
val align_write : bitstream_write -> unitByte-align.
val write_bitstream_append_aligned :
bitstream_write ->
bitstream_write ->
bitstream_writeAppend two write bitstreams, aligning at boundary
val bytes_of_write_bitstream : bitstream_write -> bytesBuild bytes from a write bitstream, padding the with zero-valued bits.
val debug_next_n_chars : int -> input -> unitDebug the next n chars to standard output and then rewind back