1<?xml version="1.0" standalone="no"?> 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> 4 5<refentry id="class-giodatainputstream"> 6 <refnamediv> 7 <refname>gio.DataInputStream</refname> 8 <refpurpose>Data Input Stream</refpurpose> 9 </refnamediv> 10 11 <refsect1> 12 <title>Synopsis</title> 13 14 <classsynopsis language="python"> 15 <ooclass><classname>gio.DataInputStream</classname></ooclass> 16 <ooclass><classname><link linkend="class-giobufferedinputstream">gio.BufferedInputStream</link></classname></ooclass> 17 18 <constructorsynopsis language="python"> 19 <methodname><link linkend="constructor-giodatainputstream">gio.DataInputStream</link></methodname> 20 <methodparam><parameter role="keyword">base_stream</parameter></methodparam> 21 </constructorsynopsis> 22 23 <methodsynopsis language="python"> 24 <methodname><link linkend="method-giodatainputstream--get-byte-order">get_byte_order</link></methodname> 25 <methodparam></methodparam> 26 </methodsynopsis> 27 <methodsynopsis language="python"> 28 <methodname><link linkend="method-giodatainputstream--get-newline-type">get_newline_type</link></methodname> 29 <methodparam></methodparam> 30 </methodsynopsis> 31 <methodsynopsis language="python"> 32 <methodname><link linkend="method-giodatainputstream--read-byte">read_byte</link></methodname> 33 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 34 </methodsynopsis> 35 <methodsynopsis language="python"> 36 <methodname><link linkend="method-giodatainputstream--read-int16">read_int16</link></methodname> 37 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 38 </methodsynopsis> 39 <methodsynopsis language="python"> 40 <methodname><link linkend="method-giodatainputstream--read-int32">read_int32</link></methodname> 41 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 42 </methodsynopsis> 43 <methodsynopsis language="python"> 44 <methodname><link linkend="method-giodatainputstream--read-int64">read_int64</link></methodname> 45 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 46 </methodsynopsis> 47 <methodsynopsis language="python"> 48 <methodname><link linkend="method-giodatainputstream--read-line">read_line</link></methodname> 49 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 50 </methodsynopsis> 51 <methodsynopsis language="python"> 52 <methodname><link linkend="method-giodatainputstream--read-line-async">read_line_async</link></methodname> 53 <methodparam><parameter role="keyword">callback</parameter></methodparam> 54 <methodparam><parameter role="keyword">io_priority</parameter><initializer>glib.PRIORITY_DEFAULT</initializer></methodparam> 55 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 56 <methodparam><parameter role="keyword">user_data</parameter><initializer>None</initializer></methodparam> 57 </methodsynopsis> 58 <methodsynopsis language="python"> 59 <methodname><link linkend="method-giodatainputstream--read-line-finish">read_line_finish</link></methodname> 60 <methodparam><parameter role="keyword">result</parameter></methodparam> 61 </methodsynopsis> 62 <methodsynopsis language="python"> 63 <methodname><link linkend="method-giodatainputstream--read-uint16">read_uint16</link></methodname> 64 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 65 </methodsynopsis> 66 <methodsynopsis language="python"> 67 <methodname><link linkend="method-giodatainputstream--read-uint32">read_uint32</link></methodname> 68 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 69 </methodsynopsis> 70 <methodsynopsis language="python"> 71 <methodname><link linkend="method-giodatainputstream--read-uint64">read_uint64</link></methodname> 72 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 73 </methodsynopsis> 74 <methodsynopsis language="python"> 75 <methodname><link linkend="method-giodatainputstream--read-until">read_until</link></methodname> 76 <methodparam><parameter role="keyword">stop_chars</parameter></methodparam> 77 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 78 </methodsynopsis> 79 <methodsynopsis language="python"> 80 <methodname><link linkend="method-giodatainputstream--read-until-async">read_until_async</link></methodname> 81 <methodparam><parameter role="keyword">stop_chars</parameter></methodparam> 82 <methodparam><parameter role="keyword">callback</parameter></methodparam> 83 <methodparam><parameter role="keyword">io_priority</parameter><initializer>glib.PRIORITY_DEFAULT</initializer></methodparam> 84 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 85 <methodparam><parameter role="keyword">user_data</parameter><initializer>None</initializer></methodparam> 86 </methodsynopsis> 87 <methodsynopsis language="python"> 88 <methodname><link linkend="method-giodatainputstream--read-until-finish">read_until_finish</link></methodname> 89 <methodparam><parameter role="keyword">result</parameter></methodparam> 90 </methodsynopsis> 91 <methodsynopsis language="python"> 92 <methodname><link linkend="method-giodatainputstream--set-byte-order">set_byte_order</link></methodname> 93 <methodparam><parameter role="keyword">order</parameter></methodparam> 94 </methodsynopsis> 95 <methodsynopsis language="python"> 96 <methodname><link linkend="method-giodatainputstream--set-newline-type">set_newline_type</link></methodname> 97 <methodparam><parameter role="keyword">type</parameter></methodparam> 98 </methodsynopsis> 99 100 </classsynopsis> 101 102 </refsect1> 103 104 <refsect1> 105 <title>Ancestry</title> 106 107<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link> 108 +-- <link linkend="class-gioinputstream">gio.InputStream</link> 109 +-- <link linkend="class-giofilterinputstream">gio.FilterInputStream</link> 110 +-- <link linkend="class-giobufferedinputstream">gio.BufferedInputStream</link> 111 +-- <link linkend="class-giodatainputstream">gio.DataInputStream</link> 112</synopsis> 113 114 </refsect1> 115 116 <refsect1 id="properties-giodatainputstream"> 117 <title>gio.DataInputStream Properties</title> 118 119 <blockquote role="properties"> 120 <informaltable pgwide="1" frame="none"> 121 <tgroup cols="3"> 122 <colspec column="1" colwidth="1in"/> 123 <colspec column="2" colwidth="1in"/> 124 <colspec column="3" colwidth="4in"/> 125 <tbody> 126 <row valign="top"> 127 <entry>"byte-order"</entry> 128 <entry>Read - Write</entry> 129 <entry>The byte order. Default value: gio.DATA_STREAM_BYTE_ORDER_BIG_ENDIAN.</entry> 130 </row> 131 <row valign="top"> 132 <entry>"newline-type"</entry> 133 <entry>Read - Write</entry> 134 <entry>The accepted types of line ending. Default value: gio.DATA_STREAM_NEWLINE_TYPE_LF.</entry> 135 </row> 136 </tbody> 137 </tgroup> 138 </informaltable> 139 </blockquote> 140 141 </refsect1> 142 143 <refsect1> 144 <title>Description</title> 145 146 <para> 147 <link linkend="class-giodatainputstream"><classname>gio.DataInputStream</classname></link> 148 implements <link linkend="class-gioinputstream"><classname>gio.InputStream</classname></link> 149 and includes functions for reading structured data directly from a binary input stream. 150 </para> 151 </refsect1> 152 153 <refsect1 id="constructor-giodatainputstream"> 154 <title>Constructor</title> 155 156 <programlisting><constructorsynopsis language="python"> 157 <methodname>gio.DataInputStream</methodname> 158 <methodparam><parameter role="keyword">base_stream</parameter></methodparam> 159 </constructorsynopsis></programlisting> 160 <variablelist> 161 <varlistentry> 162 <term><parameter>base_stream</parameter> :</term> 163 <listitem><simpara>a 164 <link linkend="class-gioinputstream"><classname>gio.InputStream</classname></link>. 165 </simpara></listitem> 166 </varlistentry> 167 <varlistentry> 168 <term><emphasis>Returns</emphasis> :</term> 169 <listitem><simpara>a new 170 <link linkend="class-giodatainputstream"><classname>gio.DataInputStream</classname></link> 171 </simpara></listitem> 172 </varlistentry> 173 </variablelist> 174 175 <para> 176 Creates a new <link linkend="class-giodatainputstream"><classname>gio.DataInputStream</classname></link> 177 from the given base_stream. 178 </para> 179 180 </refsect1> 181 182 <refsect1> 183 <title>Methods</title> 184 185 <refsect2 id="method-giodatainputstream--get-byte-order"> 186 <title>gio.DataInputStream.get_byte_order</title> 187 188 <programlisting><methodsynopsis language="python"> 189 <methodname>get_byte_order</methodname> 190 <methodparam></methodparam> 191 </methodsynopsis></programlisting> 192 193 <variablelist> 194 <varlistentry> 195 <term><emphasis>Returns</emphasis> :</term> 196 <listitem><simpara>the stream's current 197 <xref linkend="gio-data-stream-byte-order-constants" endterm="gio-data-stream-byte-order-constants-title"></xref>. 198 </simpara></listitem> 199 </varlistentry> 200 </variablelist> 201 202 <para> 203 The <methodname>get_byte_order</methodname>() method gets the byte 204 order for the data input stream. 205 </para> 206 </refsect2> 207 208 <refsect2 id="method-giodatainputstream--get-newline-type"> 209 <title>gio.DataInputStream.get_newline_type</title> 210 211 <programlisting><methodsynopsis language="python"> 212 <methodname>get_newline_type</methodname> 213 <methodparam></methodparam> 214 </methodsynopsis></programlisting> 215 216 <variablelist> 217 <varlistentry> 218 <term><emphasis>Returns</emphasis> :</term> 219 <listitem><simpara><xref linkend="gio-data-stream-newline-type-constants" endterm="gio-data-stream-newline-type-constants-title"></xref> 220 for the given stream. 221 </simpara></listitem> 222 </varlistentry> 223 </variablelist> 224 225 <para> 226 The <methodname>get_newline_type</methodname>() method gets the current 227 newline type for the stream. 228 </para> 229 </refsect2> 230 231 <refsect2 id="method-giodatainputstream--read-byte"> 232 <title>gio.DataInputStream.read_byte</title> 233 234 <programlisting><methodsynopsis language="python"> 235 <methodname>read_byte</methodname> 236 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 237 </methodsynopsis></programlisting> 238 239 <variablelist> 240 <varlistentry> 241 <term><parameter role="keyword">cancellable</parameter> :</term> 242 <listitem><simpara>optional 243 <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link> 244 object, <literal>None</literal> to ignore. 245 </simpara></listitem> 246 </varlistentry> 247 <varlistentry> 248 <term><emphasis>Returns</emphasis> :</term> 249 <listitem><simpara>an unsigned 8-bit/1-byte value read from the 250 stream or 0 if an error occurred. 251 </simpara></listitem> 252 </varlistentry> 253 </variablelist> 254 255 <para> 256 The <methodname>read_byte</methodname>() method reads an unsigned 8-bit/1-byte value from stream. 257 </para> 258 </refsect2> 259 260 <refsect2 id="method-giodatainputstream--read-int16"> 261 <title>gio.DataInputStream.read_int16</title> 262 263 <programlisting><methodsynopsis language="python"> 264 <methodname>read_int16</methodname> 265 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 266 </methodsynopsis></programlisting> 267 268 <variablelist> 269 <varlistentry> 270 <term><parameter role="keyword">cancellable</parameter> :</term> 271 <listitem><simpara>optional 272 <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link> 273 object, <literal>None</literal> to ignore. 274 </simpara></listitem> 275 </varlistentry> 276 <varlistentry> 277 <term><emphasis>Returns</emphasis> :</term> 278 <listitem><simpara>a signed 16-bit/2-byte value read from stream or 0 if an error occurred. 279 </simpara></listitem> 280 </varlistentry> 281 </variablelist> 282 283 <para> 284 The <methodname>read_int16</methodname>() method reads a 16-bit/2-byte value from stream. 285 </para> 286 <para> 287 In order to get the correct byte order for this read operation, see 288 <methodname><link linkend="method-giodatainputstream--get-byte_order">gio.DataInputStream.get_byte_order</link></methodname>() 289 and 290 <methodname><link linkend="method-giodatainputstream--set-byte_order">gio.DataInputStream.set_byte_order</link></methodname>(). 291 </para> 292 <para> 293 If cancellable is not <literal>None</literal>, then the operation can be cancelled by 294 triggering the cancellable object from another thread. If the operation was cancelled, 295 the error gio.ERROR_CANCELLED will be returned. 296 </para> 297 </refsect2> 298 299 <refsect2 id="method-giodatainputstream--read-int32"> 300 <title>gio.DataInputStream.read_int32</title> 301 302 <programlisting><methodsynopsis language="python"> 303 <methodname>read_int32</methodname> 304 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 305 </methodsynopsis></programlisting> 306 307 <variablelist> 308 <varlistentry> 309 <term><parameter role="keyword">cancellable</parameter> :</term> 310 <listitem><simpara>optional 311 <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link> 312 object, <literal>None</literal> to ignore. 313 </simpara></listitem> 314 </varlistentry> 315 <varlistentry> 316 <term><emphasis>Returns</emphasis> :</term> 317 <listitem><simpara>a signed 32-bit/4-byte value read from the stream 318 or 0 if an error occurred. 319 </simpara></listitem> 320 </varlistentry> 321 </variablelist> 322 323 <para> 324 The <methodname>read_int32</methodname>() method reads a signed 32-bit/4-byte value from stream. 325 </para> 326 <para> 327 In order to get the correct byte order for this read operation, see 328 <methodname><link linkend="method-giodatainputstream--get-byte_order">gio.DataInputStream.get_byte_order</link></methodname>() 329 and 330 <methodname><link linkend="method-giodatainputstream--set-byte_order">gio.DataInputStream.set_byte_order</link></methodname>(). 331 </para> 332 <para> 333 If cancellable is not <literal>None</literal>, then the operation can be cancelled by 334 triggering the cancellable object from another thread. If the operation was cancelled, 335 the error gio.ERROR_CANCELLED will be returned. 336 </para> 337 </refsect2> 338 339 <refsect2 id="method-giodatainputstream--read-int64"> 340 <title>gio.DataInputStream.read_int64</title> 341 342 <programlisting><methodsynopsis language="python"> 343 <methodname>read_int64</methodname> 344 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 345 </methodsynopsis></programlisting> 346 347 <variablelist> 348 <varlistentry> 349 <term><parameter role="keyword">cancellable</parameter> :</term> 350 <listitem><simpara>optional 351 <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link> 352 object, <literal>None</literal> to ignore. 353 </simpara></listitem> 354 </varlistentry> 355 <varlistentry> 356 <term><emphasis>Returns</emphasis> :</term> 357 <listitem><simpara>a signed 64-bit/8-byte value read from the stream 358 or 0 if an error occurred. 359 </simpara></listitem> 360 </varlistentry> 361 </variablelist> 362 363 <para> 364 The <methodname>read_int64</methodname>() method reads a signed 64-bit/8-byte value from stream. 365 </para> 366 <para> 367 In order to get the correct byte order for this read operation, see 368 <methodname><link linkend="method-giodatainputstream--get-byte_order">gio.DataInputStream.get_byte_order</link></methodname>() 369 and 370 <methodname><link linkend="method-giodatainputstream--set-byte_order">gio.DataInputStream.set_byte_order</link></methodname>(). 371 </para> 372 <para> 373 If cancellable is not <literal>None</literal>, then the operation can be cancelled by 374 triggering the cancellable object from another thread. If the operation was cancelled, 375 the error gio.ERROR_CANCELLED will be returned. 376 </para> 377 </refsect2> 378 379 <refsect2 id="method-giodatainputstream--read-line"> 380 <title>gio.DataInputStream.read_line</title> 381 382 <programlisting><methodsynopsis language="python"> 383 <methodname>read_line</methodname> 384 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 385 </methodsynopsis></programlisting> 386 387 <variablelist> 388 <varlistentry> 389 <term><parameter role="keyword">cancellable</parameter> :</term> 390 <listitem><simpara>optional 391 <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link> 392 object, <literal>None</literal> to ignore. 393 </simpara></listitem> 394 </varlistentry> 395 <varlistentry> 396 <term><emphasis>Returns</emphasis> :</term> 397 <listitem><simpara>a string with the line that was read in (without the newlines). 398 Set length to a gsize to get the length of the read line. On an error, it will return 399 <literal>None</literal> and error will be set. If there's no content to read, it 400 will still return <literal>None</literal>, but error won't be set. 401 </simpara></listitem> 402 </varlistentry> 403 </variablelist> 404 405 <para> 406 The <methodname>read_line</methodname>() reads a line from the data input stream. 407 </para> 408 <para> 409 If cancellable is not <literal>None</literal>, then the operation can 410 be cancelled by triggering the cancellable object from another thread. 411 If the operation was cancelled, the error gio.ERROR_CANCELLED will be 412 returned. If an operation was partially finished when the operation was 413 cancelled the partial result will be returned, without an error. 414 </para> 415 </refsect2> 416 417 <refsect2 id="method-giodatainputstream--read-line-async"> 418 <title>gio.DataInputStream.read_line_async</title> 419 420 <programlisting><methodsynopsis language="python"> 421 <methodname>read_line_async</methodname> 422 <methodparam><parameter role="keyword">callback</parameter></methodparam> 423 <methodparam><parameter role="keyword">io_priority</parameter><initializer>glib.PRIORITY_DEFAULT</initializer></methodparam> 424 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 425 <methodparam><parameter role="keyword">user_data</parameter><initializer>None</initializer></methodparam> 426 </methodsynopsis></programlisting> 427 428 <variablelist> 429 <varlistentry> 430 <term><parameter>callback</parameter> :</term> 431 <listitem><simpara>a GAsyncReadyCallback to call when the request is satisfied. 432 </simpara></listitem> 433 </varlistentry> 434 <varlistentry> 435 <term><parameter>io_priority</parameter> :</term> 436 <listitem><simpara>the 437 <xref linkend="glib-priority-constants" endterm="glib-priority-constants-title"></xref> 438 of the request. 439 </simpara></listitem> 440 </varlistentry> 441 <varlistentry> 442 <term><parameter>cancellable</parameter> :</term> 443 <listitem><simpara>optional 444 <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link> 445 object, <literal>None</literal> to ignore.</simpara></listitem> 446 </varlistentry> 447 <varlistentry> 448 <term><parameter>user_data</parameter> :</term> 449 <listitem><simpara>the data to pass to callback function. 450 </simpara></listitem> 451 </varlistentry> 452 </variablelist> 453 454 <para> 455 The <methodname>read_line_async</methodname>() method is the asynchronous version of 456 <methodname><link linkend="method-giodatainputstream--read-line">gio.DataInputStream.read_line</link></methodname>(). 457 It is an error to have two outstanding calls to this function. 458 </para> 459 <para> 460 For the synchronous version of this function, see 461 <methodname><link linkend="method-giodatainputstream--read-line">gio.DataInputStream.read_line</link></methodname>(). 462 </para> 463 <para> 464 If cancellable is not <literal>None</literal>, then the operation can be cancelled 465 by triggering the cancellable object from another thread. If the operation was 466 cancelled, the error gio.ERROR_CANCELLED will be set 467 </para> 468 </refsect2> 469 470 <refsect2 id="method-giodatainputstream--read-line-finish"> 471 <title>gio.DataInputStream.read_line_finish</title> 472 473 <programlisting><methodsynopsis language="python"> 474 <methodname>read_line_finish</methodname> 475 <methodparam><parameter role="keyword">result</parameter></methodparam> 476 </methodsynopsis></programlisting> 477 478 <variablelist> 479 <varlistentry> 480 <term><parameter role="keyword">result</parameter> :</term> 481 <listitem><simpara>a <link linkend="class-gioasyncresult"><classname>gio.AsyncResult</classname></link>. 482 </simpara></listitem> 483 </varlistentry> 484 <varlistentry> 485 <term><emphasis>Returns</emphasis> :</term> 486 <listitem><simpara>a string with the line that was read in (without the newlines). 487 On an error, it will return <literal>None</literal> and error will be set. 488 If there's no content to read, it will still return <literal>None</literal>, 489 but error won't be set. 490 </simpara></listitem> 491 </varlistentry> 492 </variablelist> 493 494 <para> 495 The <methodname>read_line_finish</methodname>() method finishes an asynchronous 496 file append operation started with 497 <methodname><link linkend="method-giodatainputstream--read-line-async">gio.DataInputStream.read_line_async</link></methodname>(). 498 </para> 499 </refsect2> 500 501 <refsect2 id="method-giodatainputstream--read-uint16"> 502 <title>gio.DataInputStream.read_uint16</title> 503 504 <programlisting><methodsynopsis language="python"> 505 <methodname>read_uint16</methodname> 506 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 507 </methodsynopsis></programlisting> 508 509 <variablelist> 510 <varlistentry> 511 <term><parameter role="keyword">cancellable</parameter> :</term> 512 <listitem><simpara>optional 513 <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link> 514 object, <literal>None</literal> to ignore. 515 </simpara></listitem> 516 </varlistentry> 517 <varlistentry> 518 <term><emphasis>Returns</emphasis> :</term> 519 <listitem><simpara>a signed 16-bit/2-byte value read from stream or 0 if an error occurred. 520 </simpara></listitem> 521 </varlistentry> 522 </variablelist> 523 524 <para> 525 The <methodname>read_uint16</methodname>() method reads a 16-bit/2-byte value from stream. 526 </para> 527 <para> 528 In order to get the correct byte order for this read operation, see 529 <methodname><link linkend="method-giodatainputstream--get-byte_order">gio.DataInputStream.get_byte_order</link></methodname>() 530 and 531 <methodname><link linkend="method-giodatainputstream--set-byte_order">gio.DataInputStream.set_byte_order</link></methodname>(). 532 </para> 533 <para> 534 If cancellable is not <literal>None</literal>, then the operation can be cancelled by 535 triggering the cancellable object from another thread. If the operation was cancelled, 536 the error gio.ERROR_CANCELLED will be returned. 537 </para> 538 </refsect2> 539 540 <refsect2 id="method-giodatainputstream--read-uint32"> 541 <title>gio.DataInputStream.read_uint32</title> 542 543 <programlisting><methodsynopsis language="python"> 544 <methodname>read_uint32</methodname> 545 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 546 </methodsynopsis></programlisting> 547 548 <variablelist> 549 <varlistentry> 550 <term><parameter role="keyword">cancellable</parameter> :</term> 551 <listitem><simpara>optional 552 <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link> 553 object, <literal>None</literal> to ignore. 554 </simpara></listitem> 555 </varlistentry> 556 <varlistentry> 557 <term><emphasis>Returns</emphasis> :</term> 558 <listitem><simpara>a signed 32-bit/4-byte value read from the stream 559 or 0 if an error occurred. 560 </simpara></listitem> 561 </varlistentry> 562 </variablelist> 563 564 <para> 565 The <methodname>read_uint32</methodname>() method reads a signed 32-bit/4-byte value from stream. 566 </para> 567 <para> 568 In order to get the correct byte order for this read operation, see 569 <methodname><link linkend="method-giodatainputstream--get-byte_order">gio.DataInputStream.get_byte_order</link></methodname>() 570 and 571 <methodname><link linkend="method-giodatainputstream--set-byte_order">gio.DataInputStream.set_byte_order</link></methodname>(). 572 </para> 573 <para> 574 If cancellable is not <literal>None</literal>, then the operation can be cancelled by 575 triggering the cancellable object from another thread. If the operation was cancelled, 576 the error gio.ERROR_CANCELLED will be returned. 577 </para> 578 </refsect2> 579 580 <refsect2 id="method-giodatainputstream--read-uint64"> 581 <title>gio.DataInputStream.read_uint64</title> 582 583 <programlisting><methodsynopsis language="python"> 584 <methodname>read_uint64</methodname> 585 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 586 </methodsynopsis></programlisting> 587 588 <variablelist> 589 <varlistentry> 590 <term><parameter role="keyword">cancellable</parameter> :</term> 591 <listitem><simpara>optional 592 <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link> 593 object, <literal>None</literal> to ignore. 594 </simpara></listitem> 595 </varlistentry> 596 <varlistentry> 597 <term><emphasis>Returns</emphasis> :</term> 598 <listitem><simpara>a signed 64-bit/8-byte value read from the stream 599 or 0 if an error occurred. 600 </simpara></listitem> 601 </varlistentry> 602 </variablelist> 603 604 <para> 605 The <methodname>read_uint64</methodname>() method reads a signed 64-bit/8-byte value from stream. 606 </para> 607 <para> 608 In order to get the correct byte order for this read operation, see 609 <methodname><link linkend="method-giodatainputstream--get-byte_order">gio.DataInputStream.get_byte_order</link></methodname>() 610 and 611 <methodname><link linkend="method-giodatainputstream--set-byte_order">gio.DataInputStream.set_byte_order</link></methodname>(). 612 </para> 613 <para> 614 If cancellable is not <literal>None</literal>, then the operation can be cancelled by 615 triggering the cancellable object from another thread. If the operation was cancelled, 616 the error gio.ERROR_CANCELLED will be returned. 617 </para> 618 </refsect2> 619 620 <refsect2 id="method-giodatainputstream--read-until"> 621 <title>gio.DataInputStream.read_until</title> 622 623 <programlisting><methodsynopsis language="python"> 624 <methodname>read_until</methodname> 625 <methodparam><parameter role="keyword">stop_chars</parameter></methodparam> 626 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 627 </methodsynopsis></programlisting> 628 629 <variablelist> 630 <varlistentry> 631 <term><parameter role="keyword">stop_chars</parameter> :</term> 632 <listitem><simpara>characters to terminate the read. 633 </simpara></listitem> 634 </varlistentry> 635 <varlistentry> 636 <term><parameter role="keyword">cancellable</parameter> :</term> 637 <listitem><simpara>optional 638 <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link> 639 object, <literal>None</literal> to ignore. 640 </simpara></listitem> 641 </varlistentry> 642 <varlistentry> 643 <term><emphasis>Returns</emphasis> :</term> 644 <listitem><simpara>a string with the data that was read before encountering 645 any of the stop characters. This function will return NULL on an error. 646 </simpara></listitem> 647 </varlistentry> 648 </variablelist> 649 650 <para> 651 The <methodname>read_until</methodname>() reads a string from the data input 652 stream, up to the first occurrence of any of the stop characters. 653 </para> 654 </refsect2> 655 656 <refsect2 id="method-giodatainputstream--read-until-async"> 657 <title>gio.DataInputStream.read_until_async</title> 658 659 <programlisting><methodsynopsis language="python"> 660 <methodname>read_until_async</methodname> 661 <methodparam><parameter role="keyword">stop_chars</parameter></methodparam> 662 <methodparam><parameter role="keyword">callback</parameter></methodparam> 663 <methodparam><parameter role="keyword">io_priority</parameter><initializer>glib.PRIORITY_DEFAULT</initializer></methodparam> 664 <methodparam><parameter role="keyword">cancellable</parameter><initializer>None</initializer></methodparam> 665 <methodparam><parameter role="keyword">user_data</parameter><initializer>None</initializer></methodparam> 666 </methodsynopsis></programlisting> 667 668 <variablelist> 669 <varlistentry> 670 <term><parameter role="keyword">stop_chars</parameter> :</term> 671 <listitem><simpara>characters to terminate the read. 672 </simpara></listitem> 673 </varlistentry> 674 <varlistentry> 675 <term><parameter>callback</parameter> :</term> 676 <listitem><simpara>a GAsyncReadyCallback to call when the request is satisfied. 677 </simpara></listitem> 678 </varlistentry> 679 <varlistentry> 680 <term><parameter>io_priority</parameter> :</term> 681 <listitem><simpara>the 682 <xref linkend="glib-priority-constants" endterm="glib-priority-constants-title"></xref> 683 of the request. 684 </simpara></listitem> 685 </varlistentry> 686 <varlistentry> 687 <term><parameter>cancellable</parameter> :</term> 688 <listitem><simpara>optional 689 <link linkend="class-giocancellable"><classname>gio.Cancellable</classname></link> 690 object, <literal>None</literal> to ignore.</simpara></listitem> 691 </varlistentry> 692 <varlistentry> 693 <term><parameter>user_data</parameter> :</term> 694 <listitem><simpara>the data to pass to callback function. 695 </simpara></listitem> 696 </varlistentry> 697 </variablelist> 698 699 <para> 700 The <methodname>read_until_async</methodname>() method it's the asynchronous version of 701 <methodname><link linkend="method-giodatainputstream--read-until">gio.DataInputStream.read_until</link></methodname>(). 702 It is an error to have two outstanding calls to this function. 703 </para> 704 <para> 705 For the synchronous version of this function, see 706 <methodname><link linkend="method-giodatainputstream--read-until">gio.DataInputStream.read_until</link></methodname>(). 707 </para> 708 <para> 709 If cancellable is not <literal>None</literal>, then the operation can be cancelled 710 by triggering the cancellable object from another thread. If the operation was 711 cancelled, the error gio.ERROR_CANCELLED will be set 712 </para> 713 <para> 714 When the operation is finished, callback will be called. You can then call 715 <methodname><link linkend="method-giodatainputstream--read-until-finish">gio.DataInputStream.read_until_finish</link></methodname>() 716 to get the result of the operation. 717 </para> 718 </refsect2> 719 720 <refsect2 id="method-giodatainputstream--read-until-finish"> 721 <title>gio.DataInputStream.read_until_finish</title> 722 723 <programlisting><methodsynopsis language="python"> 724 <methodname>read_until_finish</methodname> 725 <methodparam><parameter role="keyword">result</parameter></methodparam> 726 </methodsynopsis></programlisting> 727 728 <variablelist> 729 <varlistentry> 730 <term><parameter role="keyword">result</parameter> :</term> 731 <listitem><simpara>a <link linkend="class-gioasyncresult"><classname>gio.AsyncResult</classname></link>. 732 </simpara></listitem> 733 </varlistentry> 734 <varlistentry> 735 <term><emphasis>Returns</emphasis> :</term> 736 <listitem><simpara>a string with the data that was read before encountering 737 any of the stop characters. This function will return <literal>None</literal> on an error. 738 </simpara></listitem> 739 </varlistentry> 740 </variablelist> 741 742 <para> 743 The <methodname>read_until_finish</methodname>() method finishes an asynchronous 744 file append operation started with 745 <methodname><link linkend="method-giodatainputstream--read-until-async">gio.DataInputStream.read_until_async</link></methodname>(). 746 </para> 747 </refsect2> 748 749 <refsect2 id="method-giodatainputstream--set-byte-order"> 750 <title>gio.DataInputStream.set_byte_order</title> 751 752 <programlisting><methodsynopsis language="python"> 753 <methodname>set_byte_order</methodname> 754 <methodparam><parameter role="keyword">order</parameter></methodparam> 755 </methodsynopsis></programlisting> 756 757 <variablelist> 758 <varlistentry> 759 <term><parameter role="keyword">order</parameter> :</term> 760 <listitem><simpara>a 761 <xref linkend="gio-data-stream-byte-order-constants" endterm="gio-data-stream-byte-order-constants-title"></xref> to set. 762 </simpara></listitem> 763 </varlistentry> 764 </variablelist> 765 766 <para> 767 The <methodname>set_byte_order</methodname>() method sets the byte order for 768 the given stream. All subsequent reads from the stream will be read in the given order. 769 </para> 770 </refsect2> 771 772 <refsect2 id="method-giodatainputstream--set-newline-type"> 773 <title>gio.DataInputStream.set_newline_type</title> 774 775 <programlisting><methodsynopsis language="python"> 776 <methodname>set_newline_type</methodname> 777 <methodparam><parameter role="keyword">type</parameter></methodparam> 778 </methodsynopsis></programlisting> 779 780 <variablelist> 781 <varlistentry> 782 <term><parameter role="keyword">type</parameter> :</term> 783 <listitem><simpara>a 784 <xref linkend="gio-data-stream-newline-type-constants" endterm="gio-data-stream-newline-type-constants-title"></xref> to set. 785 </simpara></listitem> 786 </varlistentry> 787 </variablelist> 788 789 <para> 790 The <methodname>set_newline_type</methodname>() method sets the newline type for the stream. 791 </para> 792 <note> 793 Note that using gio.DATA_STREAM_NEWLINE_TYPE_ANY is slightly unsafe. If a 794 read chunk ends in "CR" we must read an additional byte to know if this is 795 "CR" or "CR LF", and this might block if there is no more data availible. 796 </note> 797 </refsect2> 798 </refsect1> 799</refentry> 800