1BytesLabels(3)                   OCaml library                  BytesLabels(3)
2
3
4

NAME

6       BytesLabels - Byte sequence operations.
7

Module

9       Module   BytesLabels
10

Documentation

12       Module BytesLabels
13        : sig end
14
15
16       Byte sequence operations.
17
18
19       Since 4.02.0
20
21
22
23
24
25
26       val length : bytes -> int
27
28       Return the length (number of bytes) of the argument.
29
30
31
32       val get : bytes -> int -> char
33
34
35       get s n returns the byte at index n in argument s .
36
37       Raise Invalid_argument if n is not a valid index in s .
38
39
40
41       val set : bytes -> int -> char -> unit
42
43
44       set s n c modifies s in place, replacing the byte at index n with c .
45
46       Raise Invalid_argument if n is not a valid index in s .
47
48
49
50       val create : int -> bytes
51
52
53       create  n  returns  a  new  byte sequence of length n . The sequence is
54       uninitialized and contains arbitrary bytes.
55
56       Raise Invalid_argument if n < 0 or n > Sys.max_string_length .
57
58
59
60       val make : int -> char -> bytes
61
62
63       make n c returns a new byte sequence of length n , filled with the byte
64       c .
65
66       Raise Invalid_argument if n < 0 or n > Sys.max_string_length .
67
68
69
70       val init : int -> f:(int -> char) -> bytes
71
72
73       init  n  f returns a fresh byte sequence of length n , with character i
74       initialized to the result of f i .
75
76       Raise Invalid_argument if n < 0 or n > Sys.max_string_length .
77
78
79
80       val empty : bytes
81
82       A byte sequence of size 0.
83
84
85
86       val copy : bytes -> bytes
87
88       Return a new byte sequence that contains the same bytes  as  the  argu‐
89       ment.
90
91
92
93       val of_string : string -> bytes
94
95       Return  a  new  byte sequence that contains the same bytes as the given
96       string.
97
98
99
100       val to_string : bytes -> string
101
102       Return a new string that contains the same  bytes  as  the  given  byte
103       sequence.
104
105
106
107       val sub : bytes -> pos:int -> len:int -> bytes
108
109
110       sub  s start len returns a new byte sequence of length len , containing
111       the subsequence of s that starts at position start and has length len .
112
113       Raise Invalid_argument if start and len do not designate a valid  range
114       of s .
115
116
117
118       val sub_string : bytes -> pos:int -> len:int -> string
119
120       Same as sub but return a string instead of a byte sequence.
121
122
123
124       val extend : bytes -> left:int -> right:int -> bytes
125
126
127       extend s left right returns a new byte sequence that contains the bytes
128       of s , with left uninitialized bytes prepended and right  uninitialized
129       bytes  appended  to  it.  If  left or right is negative, then bytes are
130       removed (instead of appended) from the corresponding side of s .
131
132       Raise Invalid_argument if the result length is negative or longer  than
133       Sys.max_string_length bytes.
134
135
136       Since 4.05.0
137
138
139
140       val fill : bytes -> pos:int -> len:int -> char -> unit
141
142
143       fill s start len c modifies s in place, replacing len characters with c
144       , starting at start .
145
146       Raise Invalid_argument if start and len do not designate a valid  range
147       of s .
148
149
150
151       val  blit  :  src:bytes  ->  src_pos:int -> dst:bytes -> dst_pos:int ->
152       len:int -> unit
153
154
155       blit src srcoff dst dstoff len copies len bytes  from  sequence  src  ,
156       starting at index srcoff , to sequence dst , starting at index dstoff .
157       It works correctly even if src and dst are the same byte sequence,  and
158       the source and destination intervals overlap.
159
160       Raise Invalid_argument if srcoff and len do not designate a valid range
161       of src , or if dstoff and len do not designate a valid range of dst .
162
163
164
165       val blit_string : src:string -> src_pos:int -> dst:bytes -> dst_pos:int
166       -> len:int -> unit
167
168
169       blit  src  srcoff  dst  dstoff  len  copies len bytes from string src ,
170       starting at index srcoff , to byte sequence dst  ,  starting  at  index
171       dstoff .
172
173       Raise Invalid_argument if srcoff and len do not designate a valid range
174       of src , or if dstoff and len do not designate a valid range of dst .
175
176
177       Since 4.05.0
178
179
180
181       val concat : sep:bytes -> bytes list -> bytes
182
183
184       concat sep sl concatenates the list of byte sequences  sl  ,  inserting
185       the separator byte sequence sep between each, and returns the result as
186       a new byte sequence.
187
188
189
190       val cat : bytes -> bytes -> bytes
191
192
193       cat s1 s2 concatenates s1 and s2 and returns the  result  as  new  byte
194       sequence.
195
196       Raise    Invalid_argument    if    the    result    is    longer   than
197       Sys.max_string_length bytes.
198
199
200       Since 4.05.0
201
202
203
204       val iter : f:(char -> unit) -> bytes -> unit
205
206
207       iter f s applies function f in turn to all the bytes  of  s  .   It  is
208       equivalent  to f (get s 0); f (get s 1); ...; f (get s (length s - 1));
209       () .
210
211
212
213       val iteri : f:(int -> char -> unit) -> bytes -> unit
214
215       Same as Bytes.iter , but the function is applied to the  index  of  the
216       byte as first argument and the byte itself as second argument.
217
218
219
220       val map : f:(char -> char) -> bytes -> bytes
221
222
223       map f s applies function f in turn to all the bytes of s and stores the
224       resulting bytes in a new sequence that is returned as the result.
225
226
227
228       val mapi : f:(int -> char -> char) -> bytes -> bytes
229
230
231       mapi f s calls f with each character of s and its index (in  increasing
232       index  order)  and stores the resulting bytes in a new sequence that is
233       returned as the result.
234
235
236
237       val trim : bytes -> bytes
238
239       Return a copy of the argument, without leading and trailing whitespace.
240       The  bytes regarded as whitespace are the ASCII characters ' ' , '\012'
241       , '\n' , '\r' , and '\t' .
242
243
244
245       val escaped : bytes -> bytes
246
247       Return a copy of the argument, with special characters  represented  by
248       escape sequences, following the lexical conventions of OCaml.
249
250
251
252       val index : bytes -> char -> int
253
254
255       index s c returns the index of the first occurrence of byte c in s .
256
257       Raise Not_found if c does not occur in s .
258
259
260
261       val index_opt : bytes -> char -> int option
262
263
264       index_opt  s c returns the index of the first occurrence of byte c in s
265       or None if c does not occur in s .
266
267
268       Since 4.05
269
270
271
272       val rindex : bytes -> char -> int
273
274
275       rindex s c returns the index of the last occurrence of byte c in s .
276
277       Raise Not_found if c does not occur in s .
278
279
280
281       val rindex_opt : bytes -> char -> int option
282
283
284       rindex_opt s c returns the index of the last occurrence of byte c in  s
285       or None if c does not occur in s .
286
287
288       Since 4.05
289
290
291
292       val index_from : bytes -> int -> char -> int
293
294
295       index_from s i c returns the index of the first occurrence of byte c in
296       s after position i .  Bytes.index s c is equivalent to Bytes.index_from
297       s 0 c .
298
299       Raise  Invalid_argument  if  i  is  not  a valid position in s .  Raise
300       Not_found if c does not occur in s after position i .
301
302
303
304       val index_from_opt : bytes -> int -> char -> int option
305
306
307       index_from _opts i c returns the index of the first occurrence of  byte
308       c in s after position i or None if c does not occur in s after position
309       i .  Bytes.index_opt s c is equivalent to Bytes.index_from_opt s 0 c .
310
311       Raise Invalid_argument if i is not a valid position in s .
312
313
314       Since 4.05
315
316
317
318       val rindex_from : bytes -> int -> char -> int
319
320
321       rindex_from s i c returns the index of the last occurrence of byte c in
322       s  before  position  i+1  .   rindex s c is equivalent to rindex_from s
323       (Bytes.length s - 1) c .
324
325       Raise Invalid_argument if i+1 is not a valid position  in  s  .   Raise
326       Not_found if c does not occur in s before position i+1 .
327
328
329
330       val rindex_from_opt : bytes -> int -> char -> int option
331
332
333       rindex_from_opt  s i c returns the index of the last occurrence of byte
334       c in s before position i+1 or None if c does  not  occur  in  s  before
335       position  i+1  .   rindex_opt  s  c  is  equivalent  to  rindex_from  s
336       (Bytes.length s - 1) c .
337
338       Raise Invalid_argument if i+1 is not a valid position in s .
339
340
341       Since 4.05
342
343
344
345       val contains : bytes -> char -> bool
346
347
348       contains s c tests if byte c appears in s .
349
350
351
352       val contains_from : bytes -> int -> char -> bool
353
354
355       contains_from s start c tests if byte c appears  in  s  after  position
356       start .  contains s c is equivalent to contains_from s 0 c .
357
358       Raise Invalid_argument if start is not a valid position in s .
359
360
361
362       val rcontains_from : bytes -> int -> char -> bool
363
364
365       rcontains_from  s  stop  c tests if byte c appears in s before position
366       stop+1 .
367
368       Raise Invalid_argument if stop < 0 or stop+1 is not a valid position in
369       s .
370
371
372
373       val uppercase : bytes -> bytes
374
375       Deprecated.   Functions  operating  on Latin-1 character set are depre‐
376       cated.
377
378
379       Return a copy of the argument, with all lowercase letters translated to
380       uppercase, including accented letters of the ISO Latin-1 (8859-1) char‐
381       acter set.
382
383
384
385       val lowercase : bytes -> bytes
386
387       Deprecated.  Functions operating on Latin-1 character  set  are  depre‐
388       cated.
389
390
391       Return a copy of the argument, with all uppercase letters translated to
392       lowercase, including accented letters of the ISO Latin-1 (8859-1) char‐
393       acter set.
394
395
396
397       val capitalize : bytes -> bytes
398
399       Deprecated.   Functions  operating  on Latin-1 character set are depre‐
400       cated.
401
402
403       Return a copy of the argument, with the first character set  to  upper‐
404       case, using the ISO Latin-1 (8859-1) character set..
405
406
407
408       val uncapitalize : bytes -> bytes
409
410       Deprecated.   Functions  operating  on Latin-1 character set are depre‐
411       cated.
412
413
414       Return a copy of the argument, with the first character set  to  lower‐
415       case, using the ISO Latin-1 (8859-1) character set..
416
417
418
419       val uppercase_ascii : bytes -> bytes
420
421       Return a copy of the argument, with all lowercase letters translated to
422       uppercase, using the US-ASCII character set.
423
424
425       Since 4.05.0
426
427
428
429       val lowercase_ascii : bytes -> bytes
430
431       Return a copy of the argument, with all uppercase letters translated to
432       lowercase, using the US-ASCII character set.
433
434
435       Since 4.05.0
436
437
438
439       val capitalize_ascii : bytes -> bytes
440
441       Return  a  copy of the argument, with the first character set to upper‐
442       case, using the US-ASCII character set.
443
444
445       Since 4.05.0
446
447
448
449       val uncapitalize_ascii : bytes -> bytes
450
451       Return a copy of the argument, with the first character set  to  lower‐
452       case, using the US-ASCII character set.
453
454
455       Since 4.05.0
456
457
458       type t = bytes
459
460
461       An alias for the type of byte sequences.
462
463
464
465       val compare : t -> t -> int
466
467       The comparison function for byte sequences, with the same specification
468       as Pervasives.compare .  Along with the type t , this function  compare
469       allows  the  module  Bytes  to  be  passed  as argument to the functors
470       Set.Make and Map.Make .
471
472
473
474       val equal : t -> t -> bool
475
476       The equality function for byte sequences.
477
478
479       Since 4.05.0
480
481
482
483
484       === Iterators ===
485
486
487       val to_seq : t -> char Seq.t
488
489       Iterate on the string, in increasing index order. Modifications of  the
490       string during iteration will be reflected in the iterator.
491
492
493       Since 4.07
494
495
496
497       val to_seqi : t -> (int * char) Seq.t
498
499       Iterate  on  the  string,  in  increasing order, yielding indices along
500       chars
501
502
503       Since 4.07
504
505
506
507       val of_seq : char Seq.t -> t
508
509       Create a string from the generator
510
511
512       Since 4.07
513
514
515
516
517
518OCamldoc                          2018-07-14                    BytesLabels(3)
Impressum