~ubuntu-branches/ubuntu/lucid/camomile/lucid

« back to all changes in this revision

Viewing changes to public/unicodeString.mli

  • Committer: Bazaar Package Importer
  • Author(s): Sylvain Le Gall
  • Date: 2005-12-03 01:18:55 UTC
  • Revision ID: james.westby@ubuntu.com-20051203011855-qzvwlld1xyqnl62t
Tags: upstream-0.6.3
ImportĀ upstreamĀ versionĀ 0.6.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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. *)
 
9
 
 
10
module type Type = sig
 
11
(** The type of string. *)
 
12
  type t
 
13
 
 
14
(** [get t i] : [i]-th character of the storage.*)
 
15
  val get : t -> int -> UChar.t
 
16
 
 
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
 
22
 
 
23
(** The number of Unicode characters in the storage *)
 
24
  val length : t -> int
 
25
 
 
26
(** locations in storages.*)
 
27
  type index
 
28
 
 
29
(** [look t i] : The character in the location [i] of [t].*)
 
30
  val look : t -> index -> UChar.t
 
31
 
 
32
(** [nth t n] : the location of the [n]-th character in [t].*)
 
33
  val nth : t -> int -> index
 
34
 
 
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. *)
 
39
 
 
40
  val next : t -> index -> index
 
41
  val prev : t -> index -> index
 
42
 
 
43
(* [out_of_range t i] tests whether [i] is inside of [t]. *)
 
44
  val out_of_range : t -> index -> bool
 
45
      
 
46
  val iter : (UChar.t -> unit) -> t -> unit
 
47
 
 
48
(* Code point comparison *)
 
49
  val compare : t -> t -> int
 
50
 
 
51
(** The location of the first character in the storage. *)
 
52
  val first : t -> index
 
53
 
 
54
(** The location of the last character in the storage. *)
 
55
  val last : t -> index
 
56
 
 
57
(** [move t i n] :
 
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
 
63
 
 
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
 
69
 
 
70
(** Character buffers.  Similar to Buffer. *)
 
71
  module Buf : sig
 
72
    type buf
 
73
 
 
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
 
78
 
 
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
 
85
  end
 
86
end
 
87