Debian Codegraph @

kernel/pstring.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 (** Primitive [string] type. *)
12
13 type t = private string
14
15 type char63 = Uint63.t
16
17 val max_length_int : int
18 val max_length : Uint63.t
19
20 (** [to_string s] converts the primitive string [s] into a standard string. *)
21 val to_string : t -> string
22
23 (** [of_string s] converts string [s] into a primitive string if its size does
24 not exceed [max_length_int], and returns [None] otherwise. *)
25 val of_string : string -> t option
26
27 (** [make i c] returns a string of size [min i max_length] containing only the
28 character with code [c l_and 255]. *)
29 val make : Uint63.t -> char63 -> t
30
31 (** [length s] gives the length of string [s]. *)
32 val length : t -> Uint63.t
33
34 (** [get s i] gives the code of the character stored at index [i] in [s]. When
35 index [i] is invalid, the function returns zero. *)
36 val get : t -> Uint63.t -> char63
37
38 (** [sub s off len] returns the substring of [s] starting at offset [off], and
39 of length [len], when possible. If [off] is not a valid offset in [s], the
40 empty string is returned. If [off] is a valid offset, the function returns
41 the longest possible suffix of [s] that: (1) starts at [off], and (2) does
42 not have more than [len] characters. *)
43 val sub : t -> Uint63.t -> Uint63.t -> t
44
45 (** [cat s1 s2] returns the concatenation of [s1] and of the longest prefix of
46 [s2] such that the sum of their lengths does not exceed [max_length]. *)
47 val cat : t -> t -> t
48
49 (** [compare s1 s2] returns [0] if [s1] and [s2] are equal, a number less than
50 [0] if [s1] is smaller than [s2], and a number greater than [0] if [s1] is
51 greater than [s2]. *)
52 val compare : t -> t -> int
53
54 (** [equal s1 s2] indicates whether [s1] and [s2] are equal. *)
55 val equal : t -> t -> bool
56
57 (** [hash s] gives a hash of [s], with the same value as [Hashtbl.hash s]. *)
58 val hash : t -> int
59
60 (** [unsafe_of_string s] converts [s] into a primitive string without checking
61 whether its size satisfies the length constraint. Callers of this function
62 must ensure that [length s <= max_length_int], which is always the case if
63 [s] was obtained via [to_string]. NOTE: this function is used in generated
64 code, via [compile]. *)
65 val unsafe_of_string : string -> t
66
67 (** [compile s] outputs an OCaml expression producing primitive string [s]. *)
68 val compile : t -> string