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
|
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<refentry id="class-giobufferedinputstream">
<refnamediv>
<refname>gio.BufferedInputStream</refname>
<refpurpose>Buffered Input Stream</refpurpose>
</refnamediv>
<refsect1>
<title>Synopsis</title>
<classsynopsis language="python">
<ooclass><classname>gio.BufferedInputStream</classname></ooclass>
<ooclass><classname><link linkend="class-giofilterinputstream">gio.FilterInputStream</link></classname></ooclass>
<constructorsynopsis language="python">
<methodname><link linkend="constructor-giobufferedinputstream">gio.BufferedInputStream</link></methodname>
<methodparam><parameter role="keyword">base_stream</parameter></methodparam>
</constructorsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-giobufferedinputstream--fill">fill</link></methodname>
<methodparam><parameter role="keyword">count</parameter></methodparam>
<methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-giobufferedinputstream--fill-async">fill_async</link></methodname>
<methodparam><parameter role="keyword">count</parameter></methodparam>
<methodparam><parameter role="keyword">callback</parameter></methodparam>
<methodparam><parameter role="keyword">io_priority</parameter><initializer>glib.PRIORITY_DEFAULT</initializer></methodparam>
<methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
<methodparam><parameter role="keyword">user_data</parameter><initializer>None</initializer></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-giobufferedinputstream--fill-finish">fill_finish</link></methodname>
<methodparam><parameter role="keyword">result</parameter></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-giobufferedinputstream--get-available">get_available</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-giobufferedinputstream--get-buffer-size">get_buffer_size</link></methodname>
<methodparam></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-giobufferedinputstream--read-byte">read_byte</link></methodname>
<methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
</methodsynopsis>
<methodsynopsis language="python">
<methodname><link linkend="method-giobufferedinputstream--set-buffer-size">set_buffer_size</link></methodname>
<methodparam><parameter role="keyword">size</parameter></methodparam>
</methodsynopsis>
</classsynopsis>
<programlisting>
<emphasis role="bold">Functions</emphasis>
<methodsynopsis language="python">
<methodname><link linkend="function-gio--buffered-input-stream-new-sized">gio.buffered_input_stream_new_sized</link></methodname>
<methodparam><parameter role="keyword">size</parameter></methodparam>
</methodsynopsis></programlisting>
</refsect1>
<refsect1>
<title>Ancestry</title>
<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
+-- <link linkend="class-gioinputstream">gio.InputStream</link>
+-- <link linkend="class-giofilterinputstream">gio.FilterInputStream</link>
+-- <link linkend="class-giobufferedinputstream">gio.BufferedInputStream</link>
</synopsis>
</refsect1>
<refsect1 id="properties-giobufferedinputstream">
<title>gio.BufferedInputStream Properties</title>
<blockquote role="properties">
<informaltable pgwide="1" frame="none">
<tgroup cols="3">
<colspec column="1" colwidth="1in"/>
<colspec column="2" colwidth="1in"/>
<colspec column="3" colwidth="4in"/>
<tbody>
<row valign="top">
<entry>"buffer-size"</entry>
<entry>Read - Write - Construct</entry>
<entry>The size of the backend buffer. Allowed values: >= 1. Default value: 4096.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</blockquote>
</refsect1>
<refsect1>
<title>Description</title>
<para>
<link linkend="class-giobufferedinputstream"><classname>gio.BufferedInputStream</classname></link>
implements <link linkend="class-giofilterinputstream"><classname>gio.FilterInputStream</classname></link>
and provides for buffered reads.
</para>
<para>
By default,
<link linkend="class-giobufferedinputstream"><classname>gio.BufferedInputStream</classname></link>'s
buffer size is set at 4 kilobytes.
</para>
<para>
To create a buffered input stream, use
<methodname><link linkend="constructor-giobufferedinputstream">gio.BufferedInputStream</link></methodname>(),
or <methodname><link linkend="function-gio--buffered-input-stream-new-sized">gio.buffered_input_stream_new_sized</link></methodname>()
to specify the buffer's size at construction.
</para>
<para>
To get the size of a buffer within a buffered input stream, use
<methodname><link linkend="method-giobufferedinputstream--get-buffer-size">get_buffer_size</link></methodname>().
To change the size of a buffered input stream's buffer, use
<methodname><link linkend="method-giobufferedinputstream--set-buffer-size">set_buffer_size</link></methodname>().
Note that the buffer's size cannot be reduced below the size of the data within the buffer.
</para>
</refsect1>
<refsect1 id="constructor-giobufferedinputstream">
<title>Constructor</title>
<programlisting><constructorsynopsis language="python">
<methodname>gio.BufferedInputStream</methodname>
<methodparam><parameter role="keyword">base_stream</parameter></methodparam>
</constructorsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter>base_stream</parameter> :</term>
<listitem><simpara>a
<link linkend="class-gioinputstream"><classname>gio.InputStream</classname></link>.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>a new
<link linkend="class-gioinputstream"><classname>gio.InputStream</classname></link>
for the given base_stream.
</simpara></listitem>
</varlistentry>
</variablelist>
<para>
Creates a new <link linkend="class-gioinputstream"><classname>gio.InputStream</classname></link>
from the given base_stream, with a buffer set to the default size (4 kilobytes).
</para>
</refsect1>
<refsect1>
<title>Methods</title>
<refsect2 id="method-giobufferedinputstream--fill">
<title>gio.BufferedInputStream.fill</title>
<programlisting><methodsynopsis language="python">
<methodname>fill</methodname>
<methodparam><parameter role="keyword">count</parameter></methodparam>
<methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">count</parameter> :</term>
<listitem><simpara>the number of bytes that will be read from the stream.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter role="keyword">cancellable</parameter> :</term>
<listitem><simpara>optional
<link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link>
object, <literal>None</literal> to ignore.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the number of bytes read into stream's buffer,
up to count, or -1 on error.
</simpara></listitem>
</varlistentry>
</variablelist>
<para>
The <methodname>fill</methodname>() method tries to read count bytes
from the stream into the buffer. Will block during this read.
</para>
<para>
If count is zero, returns zero and does nothing. A value of count
larger than G_MAXSSIZE will cause a gio.ERROR_INVALID_ARGUMENT error.
</para>
<para>
On success, the number of bytes read into the buffer is returned. It
is not an error if this is not the same as the requested size, as it can
happen e.g. near the end of a file. Zero is returned on end of file
(or if count is zero), but never otherwise.
</para>
<para>
If count is -1 then the attempted read size is equal to the number
of bytes that are required to fill the buffer.
</para>
<para>
If cancellable is not <literal>None</literal>, then the operation can
be cancelled by triggering the cancellable object from another thread.
If the operation was cancelled, the error gio.ERROR_CANCELLED will be
returned. If an operation was partially finished when the operation was
cancelled the partial result will be returned, without an error.
</para>
<para>
On error -1 is returned and error is set accordingly.
</para>
<para>
For the asynchronous, non-blocking, version of this function, see
<methodname><link linkend="method-giobufferedinputstream--fill-async">gio.BufferedInputStream.fill_async</link></methodname>().
</para>
</refsect2>
<refsect2 id="method-giobufferedinputstream--fill-async">
<title>gio.BufferedInputStream.fill_async</title>
<programlisting><methodsynopsis language="python">
<methodname>fill_async</methodname>
<methodparam><parameter role="keyword">count</parameter></methodparam>
<methodparam><parameter role="keyword">callback</parameter></methodparam>
<methodparam><parameter role="keyword">io_priority</parameter><initializer>glib.PRIORITY_DEFAULT</initializer></methodparam>
<methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
<methodparam><parameter role="keyword">user_data</parameter><initializer>None</initializer></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">count</parameter> :</term>
<listitem><simpara>the number of bytes that will be read from the stream.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter>callback</parameter> :</term>
<listitem><simpara>a GAsyncReadyCallback to call when the request is satisfied.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter>io_priority</parameter> :</term>
<listitem><simpara>the
<xref linkend="glib-priority-constants" endterm="glib-priority-constants-title"></xref>
of the request.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter>cancellable</parameter> :</term>
<listitem><simpara>optional
<link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link>
object, <literal>None</literal> to ignore.</simpara></listitem>
</varlistentry>
<varlistentry>
<term><parameter>user_data</parameter> :</term>
<listitem><simpara>the data to pass to callback function.
</simpara></listitem>
</varlistentry>
</variablelist>
<para>
The <methodname>fill_async</methodname>() method reads data into stream's
buffer asynchronously, up to count size. io_priority can be used to
prioritize reads.
</para>
<para>
For the synchronous version of this function, see
<methodname><link linkend="method-giobufferedinputstream--fill">gio.BufferedInputStream.fill</link></methodname>().
</para>
<para>
If cancellable is not <literal>None</literal>, then the operation can be cancelled
by triggering the cancellable object from another thread. If the operation was
cancelled, the error gio.ERROR_CANCELLED will be set
</para>
<para>
If count is -1 then the attempted read size is equal to the number of bytes
that are required to fill the buffer.
</para>
</refsect2>
<refsect2 id="method-giobufferedinputstream--fill-finish">
<title>gio.BufferedInputStream.fill_finish</title>
<programlisting><methodsynopsis language="python">
<methodname>fill_finish</methodname>
<methodparam><parameter role="keyword">result</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">result</parameter> :</term>
<listitem><simpara>a <link linkend="class-gioasyncresult"><classname>gio.AsyncResult</classname></link>.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the size of the read stream, or -1 on an error.
</simpara></listitem>
</varlistentry>
</variablelist>
<para>
The <methodname>fill_finish</methodname>() method finishes an asynchronous
file append operation started with
<methodname><link linkend="method-giobufferedinputstream--fill-async">gio.BufferedInputStream.fill_async</link></methodname>().
</para>
</refsect2>
<refsect2 id="method-giobufferedinputstream--get-available">
<title>gio.BufferedInputStream.get_available</title>
<programlisting><methodsynopsis language="python">
<methodname>get_available</methodname>
<methodparam></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>size of the available stream.
</simpara></listitem>
</varlistentry>
</variablelist>
<para>
The <methodname>get_available</methodname>() method gets the size of
the available data within the stream.
</para>
</refsect2>
<refsect2 id="method-giobufferedinputstream--get-buffer-size">
<title>gio.BufferedInputStream.get_buffer_size</title>
<programlisting><methodsynopsis language="python">
<methodname>get_buffer_size</methodname>
<methodparam></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the current buffer size.
</simpara></listitem>
</varlistentry>
</variablelist>
<para>
The <methodname>get_buffer_size</methodname>() method gets the size
of the input buffer.
</para>
</refsect2>
<refsect2 id="method-giobufferedinputstream--read-byte">
<title>gio.BufferedInputStream.read_byte</title>
<programlisting><methodsynopsis language="python">
<methodname>read_byte</methodname>
<methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">cancellable</parameter> :</term>
<listitem><simpara>optional
<link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link>
object, <literal>None</literal> to ignore.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the byte read from the stream, or -1 on end of stream or error.
</simpara></listitem>
</varlistentry>
</variablelist>
<para>
The <methodname>read_byte</methodname>() method tries to read a single
byte from the stream or the buffer. Will block during this read.
</para>
<para>
On success, the byte read from the stream is returned. On end of stream -1
is returned but it's not an exceptional error and error is not set.
</para>
<para>
If cancellable is not <literal>None</literal>, then the operation can
be cancelled by triggering the cancellable object from another thread.
If the operation was cancelled, the error gio.ERROR_CANCELLED will be
returned. If an operation was partially finished when the operation was
cancelled the partial result will be returned, without an error.
</para>
<para>
On error -1 is returned and error is set accordingly.
</para>
</refsect2>
<refsect2 id="method-giobufferedinputstream--set-buffer-size">
<title>gio.BufferedInputStream.set_buffer_size</title>
<programlisting><methodsynopsis language="python">
<methodname>set_buffer_size</methodname>
<methodparam><parameter role="keyword">size</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter role="keyword">size</parameter> :</term>
<listitem><simpara>the new buffer size.
</simpara></listitem>
</varlistentry>
</variablelist>
<para>
The <methodname>set_buffer_size</methodname>() method sets the size
of the internal buffer of stream to size, or to the size of the contents
of the buffer. The buffer can never be resized smaller than its current contents.
</para>
</refsect2>
</refsect1>
<refsect1>
<title>Functions</title>
<refsect2 id="function-gio--buffered-input-stream-new-sized">
<title>gio.buffered_input_stream_new_sized</title>
<programlisting><methodsynopsis language="python">
<methodname>buffered_input_stream_new_sized</methodname>
<methodparam><parameter role="keyword">size</parameter></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter>size</parameter> :</term>
<listitem><simpara>the requested buffer size.
</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>A new
<link linkend="class-gioinputstream"><classname>gio.InputStream</classname></link>.
</simpara></listitem>
</varlistentry>
</variablelist>
<para>
The <methodname>buffered_input_stream_new_sized</methodname>() function creates
a new <link linkend="class-giobufferedinputstream"><classname>gio.BufferedInputStream</classname></link>
from the given base_stream, with a buffer set to size.
</para>
</refsect2>
</refsect1>
</refentry>
|