1
(* $Id: unicodeString.mli,v 1.3 2004/06/05 16:42:07 yori Exp $ *)
2
(* Copyright 2002, 2003 Yamagata Yoriyuki. distributed with LGPL *)
3
(** Signature for Unicode strings.
4
{!UText}, {!XString}, {!UTF8}, {!UTF16}, {!UCS4}
5
have matched signatures to UStorage
6
and satisfy the semantics described below. If users want to supply
7
their own Unicode strings, please design the module with the
8
following signature and properties. *)
10
module type Type = sig
11
(** The type of string. *)
14
(** [get t i] : [i]-th character of the storage.*)
15
val get : t -> int -> UChar.t
17
(** [init len f] creates a new storage.
18
the returned storage has length [len], its nth-element is [f n].
19
[f] is called with integers [0 ... len - 1], only once for each integer.
20
The call is in the increasing order f 0, f 1, f 2, ... *)
21
val init : int -> (int -> UChar.t) -> t
23
(** The number of Unicode characters in the storage *)
26
(** locations in storages.*)
29
(** [look t i] : The character in the location [i] of [t].*)
30
val look : t -> index -> UChar.t
32
(** [nth t n] : the location of the [n]-th character in [t].*)
33
val nth : t -> int -> index
35
(** [next x i, prev x i] :
36
The operation is valid if [i] points the valid element, i.e. the
37
returned value may point the location beyond valid elements by one.
38
If [i] does not point a valid element, the results are unspecified. *)
40
val next : t -> index -> index
41
val prev : t -> index -> index
43
(* [out_of_range t i] tests whether [i] is inside of [t]. *)
44
val out_of_range : t -> index -> bool
46
val iter : (UChar.t -> unit) -> t -> unit
48
(* Code point comparison *)
49
val compare : t -> t -> int
51
(** The location of the first character in the storage. *)
52
val first : t -> index
54
(** The location of the last character in the storage. *)
58
if [n] >= 0, then returns [n]-th character after [i] and
59
otherwise returns -[n]-th character before [i].
60
If there is no such character, or [i] does not point
61
a valid character, the result is unspecified. *)
62
val move : t -> index -> int -> index
64
(** [compare_index t i j] returns
65
a positive integer if [i] is the location placed after [j] in [t],
66
0 if [i] and [j] point the same location, and
67
a negative integer if [i] is the location placed before [j] in [t]. *)
68
val compare_index : t -> index -> index -> int
70
(** Character buffers. Similar to Buffer. *)
74
(** [create n] creates the buffer. [n] is used to determine
75
the initial size of the buffer. The meaning of [n] differs from
76
modules to modules. *)
77
val create : int -> buf
79
val contents : buf -> t
80
val clear : buf -> unit
81
val reset : buf -> unit
82
val add_char : buf -> UChar.t -> unit
83
val add_string : buf -> t -> unit
84
val add_buffer : buf -> buf -> unit