patch #7303
[mldonkey.git] / src / utils / cdk / string2.mli
blobbccb58063c32e4257f2154123d72c29ab77bb648
1 (* Copyright 2001, 2002 b8_bavard, b8_fee_carabine, INRIA *)
2 (*
3 This file is part of mldonkey.
5 mldonkey is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 mldonkey is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mldonkey; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 val string_ncmp : string -> string -> int -> bool
21 (*d compare two strings, looking just the first n characters *)
23 val search_from : string -> int -> string -> int
24 (*d [search_from doc pos str] search the first occurence of the string
25 [str] in [doc], starting at index [pos] *)
27 val replace : string -> char -> string -> string
28 (*d [replace doc c str] replace all the occurences of the char [c] in
29 [doc] by the string [str] *)
31 val split : string -> char -> string list
32 val splitn : string -> char -> int -> string list
33 (*d [split str c] split the string [str] in substrings separated by
34 the character [c] *)
36 val split_simplify : string -> char -> string list
37 (*d [split_simplify str c] split the string [str] in substrings separated by
38 the character [c], removing empty sub-strings. *)
40 val unsplit : string list -> char -> string
41 (*d [unsplit str c] reverse operation of [split] *)
43 val convert : 'a -> (Buffer.t -> 'a -> char -> 'a) -> string -> string
45 (*d [convert init f s] iterates on all characters of [s], calling [f] to
46 fill a generated buffer using a status value, [init] being the initial
47 status for the first call to [f]. It returns the content of the buffer. *)
49 val before : string -> int -> string
50 (*d [before s pos] returns the substring of [s] starting at pos 0 and
51 of length [pos]. *)
53 val after : string -> int -> string
54 (*d [after s pos] returns the end substring of [s] starting at [pos]. *)
56 val cut_at : string -> char -> string * string
57 (*d [cut_at s c] returns the substrings of [s] before and after the first [c]
58 in [s]. The second substring is empty if [s] doesn't contain [c].
59 The first [c] of [s] is not contained in the two substrings.
62 val check_prefix : string -> string -> bool
63 (*d [check_prefix s prefix] checks whether [prefix] is a prefix of [s]. *)
65 val check_suffix : string -> string -> bool
66 (*d [check_suffix s suffix] checks whether [suffix] is a suffix of [s]. *)
68 val upp_initial : string -> string
69 (*d [upp_initial s] returns a copy of [s] with uppercase first character. *)
71 val subequal : string -> int -> string -> int -> int -> bool
72 (*d [subequal s1 pos1 s2 pos2 len] checks without allocation whether
73 the sub-strings of [s1] at [pos1] of [len] and of [s2] at [pos2] of [len]
74 are equals. *)
76 val subcontains : string -> string -> bool
77 (*d [subcontains s sub] checks whether [sub] appears in [s]. *)
79 val of_char : char -> string
80 (*d [of_char c] returns the string containing one [c]. *)
82 val resize : string -> int -> string
83 (*d [resize s len] returns a string of length [len] starting with [s]. *)
85 val init : int -> (int -> char) -> string
87 val tokens: string -> string list
89 (* [contains s sub] checks whether [s] contains [sub] *)
90 external contains : string -> string -> bool = "ml_strstr"
92 (* [starts_with s prefix] checks whether [s] starts with [prefix] *)
93 val starts_with : (* string *) string -> (* start *) string -> bool
95 (* [replace_char s c1 c2] replaces char [c1] by char [c2] in [s] *)
96 val replace_char : string -> char -> char -> unit
98 (* [stem s] cuts the string [s] in small words, for indexation eg *)
99 val stem : string -> string list
101 val map : (char -> 'a) -> string -> 'a array
102 val iteri: (int -> char -> unit) -> string -> unit
103 val exists: (char -> bool) -> string -> bool
104 val existsi: (int -> char -> bool) -> string -> bool
105 val for_all: (char -> bool) -> string -> bool
106 val hex_string_of_string : string -> string
108 (* [dehtmlize s] replace all <br> with \n and remove all remaining html tags from string [s] *)
109 val dehtmlize: string -> string