Module Pdfio


module Pdfio: sig .. end
Generic Input/Ouput

type pos = int64 
The type of a position in a file
val pos_succ : pos -> pos
val pos_pred : pos -> pos
val pos_max : pos -> pos -> pos
val possub : pos -> pos -> pos
val posadd : pos -> pos -> pos
Arithmetic on positions
val postoi : pos -> int
val posofi : int -> pos
Convert to and from integers
val postoi64 : pos -> int64
val posofi64 : int64 -> pos
Convert to and from 64 bit integers

type input = {
   pos_in : unit -> pos;
   seek_in : pos -> unit;
   input_char : unit -> char option;
   input_byte : unit -> int;
   in_channel_length : unit -> pos;
   set_offset : pos -> unit;
}
Type for inputs.

type output = {
   pos_out : unit -> pos;
   seek_out : pos -> unit;
   output_char : char -> unit;
   output_byte : int -> unit;
   out_channel_length : unit -> pos;
}
Type for outputs
val no_more : int
A distinguished byte value indicating "no more input"
val output_of_stream : Utility.stream -> output
val output_of_channel : Pervasives.out_channel -> output
val input_of_channel : Pervasives.in_channel -> input
val input_of_stream : Utility.stream -> input
val input_of_bytestream : Utility.bytestream -> input
val input_of_string : string -> input
Convert between various input and output and data types.
val nudge : input -> unit
Move forward one character
val rewind : input -> unit
val rewind2 : input -> unit
val rewind3 : input -> unit
Move backward one, two or three positions.
val peek_char : input -> char option
Look at the next character without advancing the pointer.
val peek_byte : input -> int
Look at the next byte without advancing the pointer.
val output_string : output -> string -> unit
Output a string.
val read_char_back : input -> char option
Read the previous character, moving the pointer back one.
val read_line : input -> string
Read a line. cf Pervasives.read_line.
val bytestream_of_input_channel : Pervasives.in_channel -> Utility.bytestream
Extract a bytestream from an input or output.
val bytestream_to_output_channel : Pervasives.out_channel -> Utility.bytestream -> unit
Write a bytestream to an output channel

Read Bit streams


type bitstream 
The type of MSB-first bitstreams
val bitstream_of_input : input -> bitstream
Make a bitstream from an input.
val getbit : bitstream -> bool
Get a bit
val getbitint : bitstream -> int
Ditto but as an integer, 0 or 1.
val align : bitstream -> unit
Align on a byte boundary
val getval_32 : bitstream -> int -> int32
Get a 32-bit value

Write Bit streams


type bitstream_write 
The type of MSB-first bitstreams for writing.
val make_write_bitstream : unit -> bitstream_write
Return a new write bistream.
val print_bitstream : bitstream_write -> unit
Debug printer.
val bytestream_of_write_bitstream : bitstream_write -> Utility.bytestream
Build a bytestream from a write bitstream, padding with zeroes.
val putbit : bitstream_write -> int -> unit
Put a single bit, 0 or 1.
val putbool : bitstream_write -> bool -> unit
Same, but input is boolean
val putval : bitstream_write -> int -> int32 -> unit
Put a multi-bit value (given as an int32) containing the given number of useful bits into a bitstream
val align_write : bitstream_write -> unit
Byte-align.
val write_bitstream_append : bitstream_write -> bitstream_write -> bitstream_write
Append two write bitstreams
val write_bitstream_append_aligned : bitstream_write -> bitstream_write -> bitstream_write
Same, but align at boundary
val join_write_bitstreams : bitstream_write list -> bitstream_write
Join several write bitstreams