forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathext_string.mli
226 lines (163 loc) · 5.43 KB
/
ext_string.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
(* Copyright (C) 2015 - 2016 Bloomberg Finance L.P.
* Copyright (C) 2017 - Hongbo Zhang, Authors of ReScript
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* In addition to the permissions granted to you by the LGPL, you may combine
* or link a "work that uses the Library" with a publicly distributed version
* of this file to produce a combined library or application, then distribute
* that combined work under the terms of your choosing, with no requirement
* to comply with the obligations normally placed on you by section 4 of the
* LGPL version 3 (or the corresponding section of a later version of the LGPL
* should you choose to use a later version).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
(** Extension to the standard library [String] module, fixed some bugs like
avoiding locale sensitivity *)
(** default is false *)
val split_by : ?keep_empty:bool -> (char -> bool) -> string -> string list
(** remove whitespace letters ('\t', '\n', ' ') on both side*)
val trim : string -> string
(** default is false *)
val split : ?keep_empty:bool -> string -> char -> string list
(** split by space chars for quick scripting *)
val quick_split_by_ws : string -> string list
val starts_with : string -> string -> bool
(**
return [-1] when not found, the returned index is useful
see [ends_with_then_chop]
*)
val ends_with_index : string -> string -> int
val ends_with : string -> string -> bool
(**
[ends_with_then_chop name ext]
@example:
{[
ends_with_then_chop "a.cmj" ".cmj"
"a"
]}
This is useful in controlled or file case sensitve system
*)
val ends_with_then_chop : string -> string -> string option
(**
[for_all_from s start p]
if [start] is negative, it raises,
if [start] is too large, it returns true
*)
val for_all_from:
string ->
int ->
(char -> bool) ->
bool
val for_all :
string ->
(char -> bool) ->
bool
val is_empty : string -> bool
val repeat : int -> string -> string
val equal : string -> string -> bool
(**
[extract_until s cursor sep]
When [sep] not found, the cursor is updated to -1,
otherwise cursor is increased to 1 + [sep_position]
User can not determine whether it is found or not by
telling the return string is empty since
"\n\n" would result in an empty string too.
*)
(* val extract_until:
string ->
int ref -> (* cursor to be updated *)
char ->
string *)
val index_count:
string ->
int ->
char ->
int ->
int
(* val index_next :
string ->
int ->
char ->
int *)
(**
[find ~start ~sub s]
returns [-1] if not found
*)
val find : ?start:int -> sub:string -> string -> int
val contain_substring : string -> string -> bool
val non_overlap_count : sub:string -> string -> int
val rfind : sub:string -> string -> int
(** [tail_from s 1]
return a substring from offset 1 (inclusive)
*)
val tail_from : string -> int -> string
(** returns negative number if not found *)
val rindex_neg : string -> char -> int
val rindex_opt : string -> char -> int option
val no_char : string -> char -> int -> int -> bool
val no_slash : string -> bool
(** return negative means no slash, otherwise [i] means the place for first slash *)
val no_slash_idx : string -> int
val no_slash_idx_from : string -> int -> int
(** if no conversion happens, reference equality holds *)
val replace_slash_backward : string -> string
(** if no conversion happens, reference equality holds *)
val replace_backward_slash : string -> string
val empty : string
#ifdef BROWSER
val compare : string -> string -> int
#else
external compare : string -> string -> int = "caml_string_length_based_compare" [@@noalloc];;
#endif
val single_space : string
val concat3 : string -> string -> string -> string
val concat4 : string -> string -> string -> string -> string
val concat5 : string -> string -> string -> string -> string -> string
val inter2 : string -> string -> string
val inter3 : string -> string -> string -> string
val inter4 : string -> string -> string -> string -> string
val concat_array : string -> string array -> string
val single_colon : string
val parent_dir_lit : string
val current_dir_lit : string
val capitalize_ascii : string -> string
val capitalize_sub:
string ->
int ->
string
val uncapitalize_ascii : string -> string
val lowercase_ascii : string -> string
(** Play parity to {!Ext_buffer.add_int_1} *)
(* val get_int_1 : string -> int -> int
val get_int_2 : string -> int -> int
val get_int_3 : string -> int -> int
val get_int_4 : string -> int -> int *)
val get_1_2_3_4 :
string ->
off:int ->
int ->
int
val unsafe_sub :
string ->
int ->
int ->
string
val is_valid_hash_number:
string ->
bool
val hash_number_as_i32_exn:
string ->
int32
val first_marshal_char:
string ->
bool