package alba

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Fmlib_node.Io_bufferSource

An IO buffer is an array of bytes

   b0 b1 b2 ...   br  ...   bw ...  bn-1
                  ^         ^            ^
                  rp        wp           n

   rp: read pointer
   wp: write pointer
   n:  size of the buffer

   Invariant: 0 <= rp <= wp <= n

   rp = wp:  no more to read
   wp = n:   buffer is full
Sourcetype t

The type of the buffer.

Sourceval alloc : int -> t

alloc size allocates an io buffer of size and set its read pointer and write pointer to 0.

Sourceval getc : t -> char option

getc b reads the character at the read pointer of the buffer b, advances the read pointer and returns the character. If the read pointer is at the position of the write pointer, then None is retured.

Sourceval putc : t -> char -> unit option

putc b ch appends the character c at the position of the write pointer and advances the write pointer. If the write pointer is already at the end None is returned.

Sourcetype js_buffer

The javascript buffer object.

Sourceval js_buffer : t -> js_buffer

The javascript buffer object.

Sourceval capacity : t -> int

The capacity of the buffer.

Sourceval length : t -> int

The length of the content of the buffer.

Sourceval read_pointer : t -> int

Position of the next character to read.

Sourceval write_pointer : t -> int

Position of the next character to write.

Sourceval is_empty : t -> bool

Is the buffer empty? read_pointer = write_pointer

Sourceval is_full : t -> bool

Is the buffer full?

Sourceval reset : t -> unit

Set the read and the write pointer to zero.

Sourceval set_read_pointer : t -> int -> unit

Set the read pointer.

Sourceval set_write_pointer : t -> int -> unit

Set the write pointer.

Sourceval copy : t -> int -> int -> t -> int -> unit

copy src s0 s1 dst d0 copies the data from the buffer src between position s0 and s1 (excluding s1 to the buffer dst starting at position d0. Overlapping is handled properly.

Sourcemodule Read (W : Fmlib.Module_types.WRITABLE) : sig ... end
Sourcemodule Write (R : Fmlib.Module_types.READABLE) : sig ... end
OCaml

Innovation. Community. Security.