File: Stdlib.Buffer.html

package info (click to toggle)
ocaml-doc 4.11-2
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 20,580 kB
  • sloc: sh: 37; makefile: 11
file content (520 lines) | stat: -rw-r--r-- 27,706 bytes parent folder | download
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="Start" href="index.html">
<link rel="previous" href="Stdlib.Bool.html">
<link rel="next" href="Stdlib.Bytes.html">
<link rel="Up" href="Stdlib.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of extensions" rel=Appendix href="index_extensions.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Index of module types" rel=Appendix href="index_module_types.html">
<link title="Arg" rel="Chapter" href="Arg.html">
<link title="Array" rel="Chapter" href="Array.html">
<link title="ArrayLabels" rel="Chapter" href="ArrayLabels.html">
<link title="Bigarray" rel="Chapter" href="Bigarray.html">
<link title="Bool" rel="Chapter" href="Bool.html">
<link title="Buffer" rel="Chapter" href="Buffer.html">
<link title="Bytes" rel="Chapter" href="Bytes.html">
<link title="BytesLabels" rel="Chapter" href="BytesLabels.html">
<link title="Callback" rel="Chapter" href="Callback.html">
<link title="CamlinternalFormat" rel="Chapter" href="CamlinternalFormat.html">
<link title="CamlinternalFormatBasics" rel="Chapter" href="CamlinternalFormatBasics.html">
<link title="CamlinternalLazy" rel="Chapter" href="CamlinternalLazy.html">
<link title="CamlinternalMod" rel="Chapter" href="CamlinternalMod.html">
<link title="CamlinternalOO" rel="Chapter" href="CamlinternalOO.html">
<link title="Char" rel="Chapter" href="Char.html">
<link title="Complex" rel="Chapter" href="Complex.html">
<link title="Condition" rel="Chapter" href="Condition.html">
<link title="Digest" rel="Chapter" href="Digest.html">
<link title="Dynlink" rel="Chapter" href="Dynlink.html">
<link title="Ephemeron" rel="Chapter" href="Ephemeron.html">
<link title="Event" rel="Chapter" href="Event.html">
<link title="Filename" rel="Chapter" href="Filename.html">
<link title="Float" rel="Chapter" href="Float.html">
<link title="Format" rel="Chapter" href="Format.html">
<link title="Fun" rel="Chapter" href="Fun.html">
<link title="Gc" rel="Chapter" href="Gc.html">
<link title="Genlex" rel="Chapter" href="Genlex.html">
<link title="Hashtbl" rel="Chapter" href="Hashtbl.html">
<link title="Int" rel="Chapter" href="Int.html">
<link title="Int32" rel="Chapter" href="Int32.html">
<link title="Int64" rel="Chapter" href="Int64.html">
<link title="Lazy" rel="Chapter" href="Lazy.html">
<link title="Lexing" rel="Chapter" href="Lexing.html">
<link title="List" rel="Chapter" href="List.html">
<link title="ListLabels" rel="Chapter" href="ListLabels.html">
<link title="Map" rel="Chapter" href="Map.html">
<link title="Marshal" rel="Chapter" href="Marshal.html">
<link title="MoreLabels" rel="Chapter" href="MoreLabels.html">
<link title="Mutex" rel="Chapter" href="Mutex.html">
<link title="Nativeint" rel="Chapter" href="Nativeint.html">
<link title="Obj" rel="Chapter" href="Obj.html">
<link title="Ocaml_operators" rel="Chapter" href="Ocaml_operators.html">
<link title="Oo" rel="Chapter" href="Oo.html">
<link title="Option" rel="Chapter" href="Option.html">
<link title="Parsing" rel="Chapter" href="Parsing.html">
<link title="Printexc" rel="Chapter" href="Printexc.html">
<link title="Printf" rel="Chapter" href="Printf.html">
<link title="Queue" rel="Chapter" href="Queue.html">
<link title="Random" rel="Chapter" href="Random.html">
<link title="Result" rel="Chapter" href="Result.html">
<link title="Scanf" rel="Chapter" href="Scanf.html">
<link title="Seq" rel="Chapter" href="Seq.html">
<link title="Set" rel="Chapter" href="Set.html">
<link title="Spacetime" rel="Chapter" href="Spacetime.html">
<link title="Stack" rel="Chapter" href="Stack.html">
<link title="StdLabels" rel="Chapter" href="StdLabels.html">
<link title="Stdlib" rel="Chapter" href="Stdlib.html">
<link title="Str" rel="Chapter" href="Str.html">
<link title="Stream" rel="Chapter" href="Stream.html">
<link title="String" rel="Chapter" href="String.html">
<link title="StringLabels" rel="Chapter" href="StringLabels.html">
<link title="Sys" rel="Chapter" href="Sys.html">
<link title="Thread" rel="Chapter" href="Thread.html">
<link title="ThreadUnix" rel="Chapter" href="ThreadUnix.html">
<link title="Uchar" rel="Chapter" href="Uchar.html">
<link title="Unit" rel="Chapter" href="Unit.html">
<link title="Unix" rel="Chapter" href="Unix.html">
<link title="UnixLabels" rel="Chapter" href="UnixLabels.html">
<link title="Weak" rel="Chapter" href="Weak.html"><link title="Iterators" rel="Section" href="#1_Iterators">
<link title="Binary encoding of integers" rel="Section" href="#1_Binaryencodingofintegers">
<title>Stdlib.Buffer</title>
</head>
<body>
<div class="navbar"><a class="pre" href="Stdlib.Bool.html" title="Stdlib.Bool">Previous</a>
&nbsp;<a class="up" href="Stdlib.html" title="Stdlib">Up</a>
&nbsp;<a class="post" href="Stdlib.Bytes.html" title="Stdlib.Bytes">Next</a>
</div>
<h1>Module <a href="type_Stdlib.Buffer.html">Stdlib.Buffer</a></h1>

<pre><span id="MODULEBuffer"><span class="keyword">module</span> Buffer</span>: <code class="type"><a href="Buffer.html">Buffer</a></code></pre><hr width="100%">

<pre><span id="TYPEt"><span class="keyword">type</span> <code class="type"></code>t</span> </pre>
<div class="info ">
<div class="info-desc">
<p>The abstract type of buffers.</p>
</div>
</div>


<pre><span id="VALcreate"><span class="keyword">val</span> create</span> : <code class="type">int -> <a href="Buffer.html#TYPEt">t</a></code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">create&nbsp;n</code> returns a fresh buffer, initially empty.
   The <code class="code">n</code> parameter is the initial size of the internal byte sequence
   that holds the buffer contents. That byte sequence is automatically
   reallocated when more than <code class="code">n</code> characters are stored in the buffer,
   but shrinks back to <code class="code">n</code> characters when <code class="code">reset</code> is called.
   For best performance, <code class="code">n</code> should be of the same order of magnitude
   as the number of characters that are expected to be stored in
   the buffer (for instance, 80 for a buffer that holds one output
   line).  Nothing bad will happen if the buffer grows beyond that
   limit, however. In doubt, take <code class="code">n&nbsp;=&nbsp;16</code> for instance.
   If <code class="code">n</code> is not between 1 and <a href="Sys.html#VALmax_string_length"><code class="code"><span class="constructor">Sys</span>.max_string_length</code></a>, it will
   be clipped to that interval.</p>
</div>
</div>

<pre><span id="VALcontents"><span class="keyword">val</span> contents</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> string</code></pre><div class="info ">
<div class="info-desc">
<p>Return a copy of the current contents of the buffer.
    The buffer itself is unchanged.</p>
</div>
</div>

<pre><span id="VALto_bytes"><span class="keyword">val</span> to_bytes</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> bytes</code></pre><div class="info ">
<div class="info-desc">
<p>Return a copy of the current contents of the buffer.
    The buffer itself is unchanged.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02</li>
</ul>
</div>

<pre><span id="VALsub"><span class="keyword">val</span> sub</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> int -> string</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Buffer</span>.sub&nbsp;b&nbsp;off&nbsp;len</code> returns a copy of <code class="code">len</code> bytes from the
    current contents of the buffer <code class="code">b</code>, starting at offset <code class="code">off</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Raises</b> <code>Invalid_argument</code> if <code class="code">srcoff</code> and <code class="code">len</code> do not designate a valid
    range of <code class="code">b</code>.</li>
</ul>
</div>

<pre><span id="VALblit"><span class="keyword">val</span> blit</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> bytes -> int -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code"><span class="constructor">Buffer</span>.blit&nbsp;src&nbsp;srcoff&nbsp;dst&nbsp;dstoff&nbsp;len</code> copies <code class="code">len</code> characters from
   the current contents of the buffer <code class="code">src</code>, starting at offset <code class="code">srcoff</code>
   to <code class="code">dst</code>, starting at character <code class="code">dstoff</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 3.11.2</li>
<li><b>Raises</b> <code>Invalid_argument</code> if <code class="code">srcoff</code> and <code class="code">len</code> do not designate a valid
   range of <code class="code">src</code>, or if <code class="code">dstoff</code> and <code class="code">len</code> do not designate a valid
   range of <code class="code">dst</code>.</li>
</ul>
</div>

<pre><span id="VALnth"><span class="keyword">val</span> nth</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> char</code></pre><div class="info ">
<div class="info-desc">
<p>Get the n-th character of the buffer.</p>
</div>
<ul class="info-attributes">
<li><b>Raises</b> <code>Invalid_argument</code> if
    index out of bounds</li>
</ul>
</div>

<pre><span id="VALlength"><span class="keyword">val</span> length</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int</code></pre><div class="info ">
<div class="info-desc">
<p>Return the number of characters currently contained in the buffer.</p>
</div>
</div>

<pre><span id="VALclear"><span class="keyword">val</span> clear</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Empty the buffer.</p>
</div>
</div>

<pre><span id="VALreset"><span class="keyword">val</span> reset</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Empty the buffer and deallocate the internal byte sequence holding the
   buffer contents, replacing it with the initial internal byte sequence
   of length <code class="code">n</code> that was allocated by <a href="Buffer.html#VALcreate"><code class="code"><span class="constructor">Buffer</span>.create</code></a> <code class="code">n</code>.
   For long-lived buffers that may have grown a lot, <code class="code">reset</code> allows
   faster reclamation of the space used by the buffer.</p>
</div>
</div>

<pre><span id="VALadd_char"><span class="keyword">val</span> add_char</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> char -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_char&nbsp;b&nbsp;c</code> appends the character <code class="code">c</code> at the end of buffer <code class="code">b</code>.</p>
</div>
</div>

<pre><span id="VALadd_utf_8_uchar"><span class="keyword">val</span> add_utf_8_uchar</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> <a href="Uchar.html#TYPEt">Uchar.t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_utf_8_uchar&nbsp;b&nbsp;u</code> appends the <a href="https://tools.ietf.org/html/rfc3629">
    UTF-8</a> encoding of <code class="code">u</code> at the end of buffer <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.06.0</li>
</ul>
</div>

<pre><span id="VALadd_utf_16le_uchar"><span class="keyword">val</span> add_utf_16le_uchar</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> <a href="Uchar.html#TYPEt">Uchar.t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_utf_16le_uchar&nbsp;b&nbsp;u</code> appends the
    <a href="https://tools.ietf.org/html/rfc2781">UTF-16LE</a> encoding of <code class="code">u</code>
    at the end of buffer <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.06.0</li>
</ul>
</div>

<pre><span id="VALadd_utf_16be_uchar"><span class="keyword">val</span> add_utf_16be_uchar</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> <a href="Uchar.html#TYPEt">Uchar.t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_utf_16be_uchar&nbsp;b&nbsp;u</code> appends the
    <a href="https://tools.ietf.org/html/rfc2781">UTF-16BE</a> encoding of <code class="code">u</code>
    at the end of buffer <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.06.0</li>
</ul>
</div>

<pre><span id="VALadd_string"><span class="keyword">val</span> add_string</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> string -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_string&nbsp;b&nbsp;s</code> appends the string <code class="code">s</code> at the end of buffer <code class="code">b</code>.</p>
</div>
</div>

<pre><span id="VALadd_bytes"><span class="keyword">val</span> add_bytes</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> bytes -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_bytes&nbsp;b&nbsp;s</code> appends the byte sequence <code class="code">s</code> at the end of buffer <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02</li>
</ul>
</div>

<pre><span id="VALadd_substring"><span class="keyword">val</span> add_substring</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> string -> int -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_substring&nbsp;b&nbsp;s&nbsp;ofs&nbsp;len</code> takes <code class="code">len</code> characters from offset
   <code class="code">ofs</code> in string <code class="code">s</code> and appends them at the end of buffer <code class="code">b</code>.</p>
</div>
</div>

<pre><span id="VALadd_subbytes"><span class="keyword">val</span> add_subbytes</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> bytes -> int -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_subbytes&nbsp;b&nbsp;s&nbsp;ofs&nbsp;len</code> takes <code class="code">len</code> characters from offset
    <code class="code">ofs</code> in byte sequence <code class="code">s</code> and appends them at the end of buffer <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.02</li>
</ul>
</div>

<pre><span id="VALadd_substitute"><span class="keyword">val</span> add_substitute</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> (string -> string) -> string -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_substitute&nbsp;b&nbsp;f&nbsp;s</code> appends the string pattern <code class="code">s</code> at the end
   of buffer <code class="code">b</code> with substitution.
   The substitution process looks for variables into
   the pattern and substitutes each variable name by its value, as
   obtained by applying the mapping <code class="code">f</code> to the variable name. Inside the
   string pattern, a variable name immediately follows a non-escaped
   <code class="code">$</code> character and is one of the following:</p>
<ul>
<li>a non empty sequence of alphanumeric or <code class="code">_</code> characters,</li>
<li>an arbitrary sequence of characters enclosed by a pair of
   matching parentheses or curly brackets.
   An escaped <code class="code">$</code> character is a <code class="code">$</code> that immediately follows a backslash
   character; it then stands for a plain <code class="code">$</code>.</li>
</ul>
</div>
<ul class="info-attributes">
<li><b>Raises</b> <code>Not_found</code> if the closing character of a parenthesized variable
   cannot be found.</li>
</ul>
</div>

<pre><span id="VALadd_buffer"><span class="keyword">val</span> add_buffer</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> <a href="Buffer.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_buffer&nbsp;b1&nbsp;b2</code> appends the current contents of buffer <code class="code">b2</code>
   at the end of buffer <code class="code">b1</code>.  <code class="code">b2</code> is not modified.</p>
</div>
</div>

<pre><span id="VALadd_channel"><span class="keyword">val</span> add_channel</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> <a href="Stdlib.html#TYPEin_channel">in_channel</a> -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_channel&nbsp;b&nbsp;ic&nbsp;n</code> reads at most <code class="code">n</code> characters from the
   input channel <code class="code">ic</code> and stores them at the end of buffer <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Raises</b> <code>End_of_file</code> if the channel contains fewer than <code class="code">n</code>
   characters. In this case, the characters are still added to
   the buffer, so as to avoid loss of data.</li>
</ul>
</div>

<pre><span id="VALoutput_buffer"><span class="keyword">val</span> output_buffer</span> : <code class="type"><a href="Stdlib.html#TYPEout_channel">out_channel</a> -> <a href="Buffer.html#TYPEt">t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">output_buffer&nbsp;oc&nbsp;b</code> writes the current contents of buffer <code class="code">b</code>
   on the output channel <code class="code">oc</code>.</p>
</div>
</div>

<pre><span id="VALtruncate"><span class="keyword">val</span> truncate</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">truncate&nbsp;b&nbsp;len</code> truncates the length of <code class="code">b</code> to <code class="code">len</code>
  Note: the internal byte sequence is not shortened.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.05.0</li>
<li><b>Raises</b> <code>Invalid_argument</code> if <code class="code">len&nbsp;&lt;&nbsp;0</code> or <code class="code">len&nbsp;&gt;&nbsp;length&nbsp;b</code>.</li>
</ul>
</div>
<h2 id="1_Iterators">Iterators</h2>
<pre><span id="VALto_seq"><span class="keyword">val</span> to_seq</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> char <a href="Seq.html#TYPEt">Seq.t</a></code></pre><div class="info ">
<div class="info-desc">
<p>Iterate on the buffer, in increasing order.
    Modification of the buffer during iteration is undefined behavior.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.07</li>
</ul>
</div>

<pre><span id="VALto_seqi"><span class="keyword">val</span> to_seqi</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> (int * char) <a href="Seq.html#TYPEt">Seq.t</a></code></pre><div class="info ">
<div class="info-desc">
<p>Iterate on the buffer, in increasing order, yielding indices along chars.
    Modification of the buffer during iteration is undefined behavior.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.07</li>
</ul>
</div>

<pre><span id="VALadd_seq"><span class="keyword">val</span> add_seq</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> char <a href="Seq.html#TYPEt">Seq.t</a> -> unit</code></pre><div class="info ">
<div class="info-desc">
<p>Add chars to the buffer</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.07</li>
</ul>
</div>

<pre><span id="VALof_seq"><span class="keyword">val</span> of_seq</span> : <code class="type">char <a href="Seq.html#TYPEt">Seq.t</a> -> <a href="Buffer.html#TYPEt">t</a></code></pre><div class="info ">
<div class="info-desc">
<p>Create a buffer from the generator</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.07</li>
</ul>
</div>
<h2 id="1_Binaryencodingofintegers">Binary encoding of integers</h2><p>The functions in this section append binary encodings of integers
    to buffers.</p>

<p>Little-endian (resp. big-endian) encoding means that least
    (resp. most) significant bytes are stored first.  Big-endian is
    also known as network byte order.  Native-endian encoding is
    either little-endian or big-endian depending on <a href="Sys.html#VALbig_endian"><code class="code"><span class="constructor">Sys</span>.big_endian</code></a>.</p>

<p>32-bit and 64-bit integers are represented by the <code class="code">int32</code> and
    <code class="code">int64</code> types, which can be interpreted either as signed or
    unsigned numbers.</p>

<p>8-bit and 16-bit integers are represented by the <code class="code">int</code> type,
    which has more bits than the binary encoding.  Functions that
    encode these values truncate their inputs to their least
    significant bytes.</p>

<pre><span id="VALadd_uint8"><span class="keyword">val</span> add_uint8</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_uint8&nbsp;b&nbsp;i</code> appends a binary unsigned 8-bit integer <code class="code">i</code> to
    <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08</li>
</ul>
</div>

<pre><span id="VALadd_int8"><span class="keyword">val</span> add_int8</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_int8&nbsp;b&nbsp;i</code> appends a binary signed 8-bit integer <code class="code">i</code> to
    <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08</li>
</ul>
</div>

<pre><span id="VALadd_uint16_ne"><span class="keyword">val</span> add_uint16_ne</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_uint16_ne&nbsp;b&nbsp;i</code> appends a binary native-endian unsigned 16-bit
    integer <code class="code">i</code> to <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08</li>
</ul>
</div>

<pre><span id="VALadd_uint16_be"><span class="keyword">val</span> add_uint16_be</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_uint16_be&nbsp;b&nbsp;i</code> appends a binary big-endian unsigned 16-bit
    integer <code class="code">i</code> to <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08</li>
</ul>
</div>

<pre><span id="VALadd_uint16_le"><span class="keyword">val</span> add_uint16_le</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_uint16_le&nbsp;b&nbsp;i</code> appends a binary little-endian unsigned 16-bit
    integer <code class="code">i</code> to <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08</li>
</ul>
</div>

<pre><span id="VALadd_int16_ne"><span class="keyword">val</span> add_int16_ne</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_int16_ne&nbsp;b&nbsp;i</code> appends a binary native-endian signed 16-bit
    integer <code class="code">i</code> to <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08</li>
</ul>
</div>

<pre><span id="VALadd_int16_be"><span class="keyword">val</span> add_int16_be</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_int16_be&nbsp;b&nbsp;i</code> appends a binary big-endian signed 16-bit
    integer <code class="code">i</code> to <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08</li>
</ul>
</div>

<pre><span id="VALadd_int16_le"><span class="keyword">val</span> add_int16_le</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_int16_le&nbsp;b&nbsp;i</code> appends a binary little-endian signed 16-bit
    integer <code class="code">i</code> to <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08</li>
</ul>
</div>

<pre><span id="VALadd_int32_ne"><span class="keyword">val</span> add_int32_ne</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int32 -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_int32_ne&nbsp;b&nbsp;i</code> appends a binary native-endian 32-bit integer
    <code class="code">i</code> to <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08</li>
</ul>
</div>

<pre><span id="VALadd_int32_be"><span class="keyword">val</span> add_int32_be</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int32 -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_int32_be&nbsp;b&nbsp;i</code> appends a binary big-endian 32-bit integer
    <code class="code">i</code> to <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08</li>
</ul>
</div>

<pre><span id="VALadd_int32_le"><span class="keyword">val</span> add_int32_le</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int32 -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_int32_le&nbsp;b&nbsp;i</code> appends a binary little-endian 32-bit integer
    <code class="code">i</code> to <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08</li>
</ul>
</div>

<pre><span id="VALadd_int64_ne"><span class="keyword">val</span> add_int64_ne</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int64 -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_int64_ne&nbsp;b&nbsp;i</code> appends a binary native-endian 64-bit integer
    <code class="code">i</code> to <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08</li>
</ul>
</div>

<pre><span id="VALadd_int64_be"><span class="keyword">val</span> add_int64_be</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int64 -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_int64_be&nbsp;b&nbsp;i</code> appends a binary big-endian 64-bit integer
    <code class="code">i</code> to <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08</li>
</ul>
</div>

<pre><span id="VALadd_int64_le"><span class="keyword">val</span> add_int64_le</span> : <code class="type"><a href="Buffer.html#TYPEt">t</a> -> int64 -> unit</code></pre><div class="info ">
<div class="info-desc">
<p><code class="code">add_int64_ne&nbsp;b&nbsp;i</code> appends a binary little-endian 64-bit integer
    <code class="code">i</code> to <code class="code">b</code>.</p>
</div>
<ul class="info-attributes">
<li><b>Since</b> 4.08</li>
</ul>
</div>
</body></html>