package mopsa

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

Buffers backed by byte sequences that grow automatically. Support insertion and deletion at any position within the buffer. Include some support for UTF-8 encoding.

type t = {
  1. mutable buf : Stdlib.Bytes.t;
  2. mutable len : int;
}
val ensure : t -> int -> unit
val create : unit -> t

Create an empty buffer.

val copy : t -> t

Creates a copy of a buffer.

val contents : t -> string

Buffer contents, as a string.

val byte_length : t -> int

Buffer size in bytes.

val uchar_length : t -> int

Buffer size in utf-8 chars.

val index_of_uchar : t -> int -> int

Byte index of the nb-th utf-8 char.

val nth : t -> int -> char

Get the byte at the specified byte index.

val sub : t -> int -> int -> string

Get the substring from the specified byte index.

val add_char : t -> char -> unit

Append a byte at the end of the buffer.

val add_substring : t -> string -> int -> int -> unit

Append a part of a string at the end of the buffer.

val add_string : t -> string -> unit

Append a string at the end of the buffer.

val insert_char : t -> int -> char -> unit

Insert a byte at the specified byte index.

val insert_substring : t -> int -> string -> int -> int -> unit

Insert a substring at the specified byte index.

val insert_string : t -> int -> string -> unit

Insert a string at the specified byte index.

val delete : t -> int -> int -> unit

Delete some bytes at the specified byte index.

val clear : t -> unit

Reset the buffer to 0 length.

val output : Stdlib.out_channel -> t -> unit

Print to buffer.

OCaml

Innovation. Community. Security.