package zed

  1. Overview
  2. Docs
Abstract engine for text edition in OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

3.1.0.tar.gz
sha256=c387b0496c34c7eb680999e751525992e3e636a803297480ef004498887625fd
md5=51e8676ba972e5ad727633c161e404b1

doc/zed/Zed_string/index.html

Module Zed_stringSource

Sourceexception Invalid of string * string

Invalid (error, text) Exception raised when an invalid Zed_char sequence is encountered. text is the faulty text and error is a description of the first error in text.

Sourceexception Out_of_bounds

Exception raised when trying to access a character which is outside the bounds of a string.

Sourcetype seg_width = {
  1. start : int;
  2. len : int;
  3. width : int;
}

Type of the width of a segment of a Zed_string.t

Sourcetype all_width = {
  1. len : int;
  2. width : int;
}

Type of the width of a whole Zed_string.t

Type of the width of a Zed_string.t

Sourcetype t

Type of Zed_string.t

Sourceval unsafe_of_utf8 : string -> t

Create a Zed_string.t from a utf8 encoded string.

Sourceval of_utf8 : string -> t

Create a Zed_string.t from a utf8 encoded string and check whether it's well formed.

Sourceval to_utf8 : t -> string

Create a utf8 encoded string from a Zed_string.t.

Sourceval explode : t -> Zed_char.t list

explode str returns the list of all Zed_char.t of str.

Sourceval rev_explode : t -> Zed_char.t list

explode str returns the list of all Zed_char.t of str in reverse order.

Sourceval unsafe_explode : t -> Zed_char.t list

explode str returns the list of all Zed_char.t of str even if str is malformed.

Sourceval unsafe_rev_explode : t -> Zed_char.t list

explode str returns the list of all Zed_char.t of str in reverse order even if str is malformed.

Sourceval implode : Zed_char.t list -> t

implode l returns the concatenation of all Zed_char.t of l.

Sourceval aval_width : width -> int

Returns the widest available width

Sourceval init : int -> (int -> Zed_char.t) -> t

init n f returns the contenation of implode [(f 0)], implode [(f 1)], ..., implode [(f (n - 1))].

Sourceval init_from_uChars : int -> (int -> CamomileLibrary.UChar.t) -> t

init n f creates a sequence of UChar.t of f 0, f 1, ..., f (n-1) and implode the contenation of it.

Sourceval make : int -> Zed_char.t -> t

make n ch creates a Zed_string.t of length n filled with ch.

Sourceval copy : t -> t

copy s returns a copy of s, that is, a fresh Zed_string.t containing the same elements as s.

Sourceval to_raw_list : t -> CamomileLibrary.UChar.t list

Same as explode, but the elements in the list is UChar.t.

Sourceval to_raw_array : t -> CamomileLibrary.UChar.t array

Same as explode, but the elements in the array is UChar.t.

Sourcetype index = int
Sourceval get : t -> int -> Zed_char.t

get str idx returns the Zed_char.t at index idx in str.

Sourceval get_raw : t -> int -> CamomileLibrary.UChar.t

get_raw str idx returns the UChar.t at UChar.t based index idx in str.

Sourceval empty : unit -> t

empty () creates an empty Zed_string.t.

Sourceval width_ofs : ?start:index -> ?num:int -> t -> width

width_ofs ?start ?num str returns the width of a Zed_string.t that starts at offset start and has length less than num.

Sourceval width : ?start:int -> ?num:int -> t -> width

width ?start ?num str returns the width of a Zed_string.t that starts at positon start and has length less than num.

Sourceval bytes : t -> index

bytes str returns the number of bytes in str. It's also the index point to the end of str.

Sourceval size : t -> int

size str returns the number of UChar.t in str.

Sourceval length : t -> int

length str returns the number of Zed_char.t in str

Sourceval next_ofs : t -> int -> int

next_ofs str ofs returns the offset of the next zed_char in str.

Sourceval prev_ofs : t -> int -> int

prev_ofs str ofs returns the offset of the previous zed_char in str.

Sourceval extract : t -> index -> Zed_char.t

extract str ofs returns the Zed_char.t at offset ofs in str.

Sourceval extract_next : t -> index -> Zed_char.t * index

extract_next str ofs returns the Zed_char.t at offset ofs in str and the offset of the next Zed_char.t

Sourceval extract_prev : t -> index -> Zed_char.t * index

extract_prev str ofs returns the Zed_char.t at the previous offset ofs in str and this offset.

Sourceval unsafe_of_uChars : CamomileLibrary.UChar.t list -> t

unsafe_of_uChars l returns the concatenation of all UChar.t of l.

Sourceval of_uChars : CamomileLibrary.UChar.t list -> t * CamomileLibrary.UChar.t list

of_uChars l returns a tuple of which the first element is a well formed Zed_string.t concatenating of all UChar.t of l and the second element is a list of the remaining UChar.t.

Sourceval for_all : (Zed_char.t -> bool) -> t -> bool

for_all p zStr checks if all Zed_char.t in zStr satisfy the predicate p.

Sourceval iter : (Zed_char.t -> unit) -> t -> unit

iter f str applies f an all characters of str starting from the left.

Sourceval rev_iter : (Zed_char.t -> unit) -> t -> unit

iter f str applies f an all characters of str starting from the right.

Sourceval fold : (Zed_char.t -> 'a -> 'a) -> t -> 'a -> 'a

fold f str acc applies f on all characters of str starting from the left, accumulating a value.

Sourceval rev_fold : (Zed_char.t -> 'a -> 'a) -> t -> 'a -> 'a

fold f str acc applies f on all characters of str starting from the right, accumulating a value.

Sourceval map : (Zed_char.t -> Zed_char.t) -> t -> t

map f str maps all characters of str with f.

Sourceval rev_map : (Zed_char.t -> Zed_char.t) -> t -> t

map f str maps all characters of str with f in reverse order.

Sourceval check_range : t -> int -> bool
Sourceval look : t -> index -> CamomileLibrary.UChar.t

look str idx returns the character in the location idx of str.

Sourceval nth : t -> int -> index

nth str n returns the location of the n-th character in str.

next str i, prev str i The operation is valid if i points the valid element, i.e. the returned value may point the location beyond valid elements by one. If i does not point a valid element, the results are unspecified.

Sourceval next : t -> index -> index

next str idx returns the index of the next zed_char in str.

Sourceval prev : t -> index -> index

prev str idx returns the index of the previous zed_char in str.

Sourceval out_of_range : t -> index -> bool
Sourceval compare : t -> t -> int

Compares two strings by Zed_char.compare.

Sourceval first : t -> index

first str returns the location of the first character in str.

Sourceval last : t -> index

last str returns the location of the last character in str.

Sourceval move : t -> index -> int -> index

move str i n if n >= 0, then returns n-th character after i and otherwise returns -n-th character before i. If there is no such character, or i does not point a valid character, the result is unspecified.

Sourceval move_raw : t -> index -> int -> index

move_raw str i n if n >= 0, then returns n-th UChar.t after i and otherwise returns -n-th UChar.t before i. If there is no such UChar.t, or i does not point a valid UChar.t, the result is unspecified.

Sourceval compare_index : t -> index -> index -> int

compare_index str i j returns a positive integer if i is the location placed after j in str, 0 if i and j point the same location, and a negative integer if i is the location placed before j in str.

Sourceval sub_ofs : ofs:index -> len:int -> t -> t

sub_ofs ofs len str returns the sub-string of str starting at byte-offset ofs and of byte-length len.

Sourceval sub : pos:int -> len:int -> t -> t

sub ~pos ~len str returns the sub-string of str starting at position pos and of length len.

Sourceval after : t -> int -> t

after str pos returns the sub-string after pos in str

Sourceval unsafe_sub_equal : t -> int -> t -> int -> bool
Sourceval starts_with : prefix:t -> t -> bool

starts_with ~prefix str returns true if str starts with prefix.

Sourceval ends_with : suffix:t -> t -> bool

ends_with ~suffix str returns true if str ends with suffix.

Sourceval unsafe_append : t -> t -> t

unsafe_append str1 str2 returns the concatenation of str1 and str2 without sequence validation.

Sourceval append : t -> t -> t

append str1 str2 returns the concatenation of str1 and str2.

Sourcemodule US (US : CamomileLibrary.UnicodeString.Type) : sig ... end
Sourcemodule Buf : sig ... end
Sourcemodule US_Core : sig ... end
Sourcemodule US_Raw : sig ... end
OCaml

Innovation. Community. Security.