1StdLabels.Bytes(3)                 OCamldoc                 StdLabels.Bytes(3)
2
3
4

NAME

6       StdLabels.Bytes - no description
7

Module

9       Module   StdLabels.Bytes
10

Documentation

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