/usr/include/d/gtkd-3/gio/DataInputStream.d is in libgtkd-3-dev 3.7.5-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 | /*
* This file is part of gtkD.
*
* gtkD is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version, with
* some exceptions, please read the COPYING file.
*
* gtkD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with gtkD; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage
module gio.DataInputStream;
private import gio.AsyncResultIF;
private import gio.BufferedInputStream;
private import gio.Cancellable;
private import gio.InputStream;
private import gio.c.functions;
public import gio.c.types;
private import glib.ConstructionException;
private import glib.ErrorG;
private import glib.GException;
private import glib.Str;
private import gobject.ObjectG;
public import gtkc.giotypes;
/**
* Data input stream implements #GInputStream and includes functions for
* reading structured data directly from a binary input stream.
*/
public class DataInputStream : BufferedInputStream
{
/** the main Gtk struct */
protected GDataInputStream* gDataInputStream;
/** Get the main Gtk struct */
public GDataInputStream* getDataInputStreamStruct(bool transferOwnership = false)
{
if (transferOwnership)
ownedRef = false;
return gDataInputStream;
}
/** the main Gtk struct as a void* */
protected override void* getStruct()
{
return cast(void*)gDataInputStream;
}
protected override void setStruct(GObject* obj)
{
gDataInputStream = cast(GDataInputStream*)obj;
super.setStruct(obj);
}
/**
* Sets our main struct and passes it to the parent class.
*/
public this (GDataInputStream* gDataInputStream, bool ownedRef = false)
{
this.gDataInputStream = gDataInputStream;
super(cast(GBufferedInputStream*)gDataInputStream, ownedRef);
}
/** */
public static GType getType()
{
return g_data_input_stream_get_type();
}
/**
* Creates a new data input stream for the @base_stream.
*
* Params:
* baseStream = a #GInputStream.
*
* Returns: a new #GDataInputStream.
*
* Throws: ConstructionException GTK+ fails to create the object.
*/
public this(InputStream baseStream)
{
auto p = g_data_input_stream_new((baseStream is null) ? null : baseStream.getInputStreamStruct());
if(p is null)
{
throw new ConstructionException("null returned by new");
}
this(cast(GDataInputStream*) p, true);
}
/**
* Gets the byte order for the data input stream.
*
* Returns: the @stream's current #GDataStreamByteOrder.
*/
public GDataStreamByteOrder getByteOrder()
{
return g_data_input_stream_get_byte_order(gDataInputStream);
}
/**
* Gets the current newline type for the @stream.
*
* Returns: #GDataStreamNewlineType for the given @stream.
*/
public GDataStreamNewlineType getNewlineType()
{
return g_data_input_stream_get_newline_type(gDataInputStream);
}
/**
* Reads a 16-bit/2-byte value from @stream.
*
* In order to get the correct byte order for this read operation,
* see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().
*
* Params:
* cancellable = optional #GCancellable object, %NULL to ignore.
*
* Returns: a signed 16-bit/2-byte value read from @stream or %0 if
* an error occurred.
*
* Throws: GException on failure.
*/
public short readInt16(Cancellable cancellable)
{
GError* err = null;
auto p = g_data_input_stream_read_int16(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
return p;
}
/**
* Reads a signed 32-bit/4-byte value from @stream.
*
* In order to get the correct byte order for this read operation,
* see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().
*
* If @cancellable is not %NULL, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
* was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
*
* Params:
* cancellable = optional #GCancellable object, %NULL to ignore.
*
* Returns: a signed 32-bit/4-byte value read from the @stream or %0 if
* an error occurred.
*
* Throws: GException on failure.
*/
public int readInt32(Cancellable cancellable)
{
GError* err = null;
auto p = g_data_input_stream_read_int32(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
return p;
}
/**
* Reads a 64-bit/8-byte value from @stream.
*
* In order to get the correct byte order for this read operation,
* see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().
*
* If @cancellable is not %NULL, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
* was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
*
* Params:
* cancellable = optional #GCancellable object, %NULL to ignore.
*
* Returns: a signed 64-bit/8-byte value read from @stream or %0 if
* an error occurred.
*
* Throws: GException on failure.
*/
public long readInt64(Cancellable cancellable)
{
GError* err = null;
auto p = g_data_input_stream_read_int64(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
return p;
}
/**
* Reads a line from the data input stream. Note that no encoding
* checks or conversion is performed; the input is not guaranteed to
* be UTF-8, and may in fact have embedded NUL characters.
*
* If @cancellable is not %NULL, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
* was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
*
* Params:
* length = a #gsize to get the length of the data read in.
* cancellable = optional #GCancellable object, %NULL to ignore.
*
* Returns: a NUL terminated byte array with the line that was read in
* (without the newlines). Set @length to a #gsize to get the length
* of the read line. On an error, it will return %NULL and @error
* will be set. If there's no content to read, it will still return
* %NULL, but @error won't be set.
*
* Throws: GException on failure.
*/
public string readLine(out size_t length, Cancellable cancellable)
{
GError* err = null;
auto retStr = g_data_input_stream_read_line(gDataInputStream, &length, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
scope(exit) Str.freeString(retStr);
return Str.toString(retStr);
}
/**
* The asynchronous version of g_data_input_stream_read_line(). It is
* an error to have two outstanding calls to this function.
*
* When the operation is finished, @callback will be called. You
* can then call g_data_input_stream_read_line_finish() to get
* the result of the operation.
*
* Params:
* ioPriority = the [I/O priority][io-priority] of the request
* cancellable = optional #GCancellable object, %NULL to ignore.
* callback = callback to call when the request is satisfied.
* userData = the data to pass to callback function.
*
* Since: 2.20
*/
public void readLineAsync(int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
{
g_data_input_stream_read_line_async(gDataInputStream, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
}
/**
* Finish an asynchronous call started by
* g_data_input_stream_read_line_async(). Note the warning about
* string encoding in g_data_input_stream_read_line() applies here as
* well.
*
* Params:
* result = the #GAsyncResult that was provided to the callback.
* length = a #gsize to get the length of the data read in.
*
* Returns: a NUL-terminated byte array with the line that was read in
* (without the newlines). Set @length to a #gsize to get the length
* of the read line. On an error, it will return %NULL and @error
* will be set. If there's no content to read, it will still return
* %NULL, but @error won't be set.
*
* Since: 2.20
*
* Throws: GException on failure.
*/
public string readLineFinish(AsyncResultIF result, out size_t length)
{
GError* err = null;
auto retStr = g_data_input_stream_read_line_finish(gDataInputStream, (result is null) ? null : result.getAsyncResultStruct(), &length, &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
scope(exit) Str.freeString(retStr);
return Str.toString(retStr);
}
/**
* Finish an asynchronous call started by
* g_data_input_stream_read_line_async().
*
* Params:
* result = the #GAsyncResult that was provided to the callback.
* length = a #gsize to get the length of the data read in.
*
* Returns: a string with the line that
* was read in (without the newlines). Set @length to a #gsize to
* get the length of the read line. On an error, it will return
* %NULL and @error will be set. For UTF-8 conversion errors, the set
* error domain is %G_CONVERT_ERROR. If there's no content to read,
* it will still return %NULL, but @error won't be set.
*
* Since: 2.30
*
* Throws: GException on failure.
*/
public string readLineFinishUtf8(AsyncResultIF result, out size_t length)
{
GError* err = null;
auto retStr = g_data_input_stream_read_line_finish_utf8(gDataInputStream, (result is null) ? null : result.getAsyncResultStruct(), &length, &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
scope(exit) Str.freeString(retStr);
return Str.toString(retStr);
}
/**
* Reads a UTF-8 encoded line from the data input stream.
*
* If @cancellable is not %NULL, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
* was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
*
* Params:
* length = a #gsize to get the length of the data read in.
* cancellable = optional #GCancellable object, %NULL to ignore.
*
* Returns: a NUL terminated UTF-8 string
* with the line that was read in (without the newlines). Set
* @length to a #gsize to get the length of the read line. On an
* error, it will return %NULL and @error will be set. For UTF-8
* conversion errors, the set error domain is %G_CONVERT_ERROR. If
* there's no content to read, it will still return %NULL, but @error
* won't be set.
*
* Since: 2.30
*
* Throws: GException on failure.
*/
public string readLineUtf8(out size_t length, Cancellable cancellable)
{
GError* err = null;
auto retStr = g_data_input_stream_read_line_utf8(gDataInputStream, &length, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
scope(exit) Str.freeString(retStr);
return Str.toString(retStr);
}
/**
* Reads an unsigned 16-bit/2-byte value from @stream.
*
* In order to get the correct byte order for this read operation,
* see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().
*
* Params:
* cancellable = optional #GCancellable object, %NULL to ignore.
*
* Returns: an unsigned 16-bit/2-byte value read from the @stream or %0 if
* an error occurred.
*
* Throws: GException on failure.
*/
public ushort readUint16(Cancellable cancellable)
{
GError* err = null;
auto p = g_data_input_stream_read_uint16(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
return p;
}
/**
* Reads an unsigned 32-bit/4-byte value from @stream.
*
* In order to get the correct byte order for this read operation,
* see g_data_input_stream_get_byte_order() and g_data_input_stream_set_byte_order().
*
* If @cancellable is not %NULL, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
* was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
*
* Params:
* cancellable = optional #GCancellable object, %NULL to ignore.
*
* Returns: an unsigned 32-bit/4-byte value read from the @stream or %0 if
* an error occurred.
*
* Throws: GException on failure.
*/
public uint readUint32(Cancellable cancellable)
{
GError* err = null;
auto p = g_data_input_stream_read_uint32(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
return p;
}
/**
* Reads an unsigned 64-bit/8-byte value from @stream.
*
* In order to get the correct byte order for this read operation,
* see g_data_input_stream_get_byte_order().
*
* If @cancellable is not %NULL, then the operation can be cancelled by
* triggering the cancellable object from another thread. If the operation
* was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
*
* Params:
* cancellable = optional #GCancellable object, %NULL to ignore.
*
* Returns: an unsigned 64-bit/8-byte read from @stream or %0 if
* an error occurred.
*
* Throws: GException on failure.
*/
public ulong readUint64(Cancellable cancellable)
{
GError* err = null;
auto p = g_data_input_stream_read_uint64(gDataInputStream, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
return p;
}
/**
* Reads a string from the data input stream, up to the first
* occurrence of any of the stop characters.
*
* Note that, in contrast to g_data_input_stream_read_until_async(),
* this function consumes the stop character that it finds.
*
* Don't use this function in new code. Its functionality is
* inconsistent with g_data_input_stream_read_until_async(). Both
* functions will be marked as deprecated in a future release. Use
* g_data_input_stream_read_upto() instead, but note that that function
* does not consume the stop character.
*
* Params:
* stopChars = characters to terminate the read.
* length = a #gsize to get the length of the data read in.
* cancellable = optional #GCancellable object, %NULL to ignore.
*
* Returns: a string with the data that was read
* before encountering any of the stop characters. Set @length to
* a #gsize to get the length of the string. This function will
* return %NULL on an error.
*
* Throws: GException on failure.
*/
public string readUntil(string stopChars, out size_t length, Cancellable cancellable)
{
GError* err = null;
auto retStr = g_data_input_stream_read_until(gDataInputStream, Str.toStringz(stopChars), &length, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
scope(exit) Str.freeString(retStr);
return Str.toString(retStr);
}
/**
* The asynchronous version of g_data_input_stream_read_until().
* It is an error to have two outstanding calls to this function.
*
* Note that, in contrast to g_data_input_stream_read_until(),
* this function does not consume the stop character that it finds. You
* must read it for yourself.
*
* When the operation is finished, @callback will be called. You
* can then call g_data_input_stream_read_until_finish() to get
* the result of the operation.
*
* Don't use this function in new code. Its functionality is
* inconsistent with g_data_input_stream_read_until(). Both functions
* will be marked as deprecated in a future release. Use
* g_data_input_stream_read_upto_async() instead.
*
* Params:
* stopChars = characters to terminate the read.
* ioPriority = the [I/O priority][io-priority] of the request
* cancellable = optional #GCancellable object, %NULL to ignore.
* callback = callback to call when the request is satisfied.
* userData = the data to pass to callback function.
*
* Since: 2.20
*/
public void readUntilAsync(string stopChars, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
{
g_data_input_stream_read_until_async(gDataInputStream, Str.toStringz(stopChars), ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
}
/**
* Finish an asynchronous call started by
* g_data_input_stream_read_until_async().
*
* Params:
* result = the #GAsyncResult that was provided to the callback.
* length = a #gsize to get the length of the data read in.
*
* Returns: a string with the data that was read
* before encountering any of the stop characters. Set @length to
* a #gsize to get the length of the string. This function will
* return %NULL on an error.
*
* Since: 2.20
*
* Throws: GException on failure.
*/
public string readUntilFinish(AsyncResultIF result, out size_t length)
{
GError* err = null;
auto retStr = g_data_input_stream_read_until_finish(gDataInputStream, (result is null) ? null : result.getAsyncResultStruct(), &length, &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
scope(exit) Str.freeString(retStr);
return Str.toString(retStr);
}
/**
* Reads a string from the data input stream, up to the first
* occurrence of any of the stop characters.
*
* In contrast to g_data_input_stream_read_until(), this function
* does not consume the stop character. You have to use
* g_data_input_stream_read_byte() to get it before calling
* g_data_input_stream_read_upto() again.
*
* Note that @stop_chars may contain '\0' if @stop_chars_len is
* specified.
*
* Params:
* stopChars = characters to terminate the read
* stopCharsLen = length of @stop_chars. May be -1 if @stop_chars is
* nul-terminated
* length = a #gsize to get the length of the data read in
* cancellable = optional #GCancellable object, %NULL to ignore
*
* Returns: a string with the data that was read
* before encountering any of the stop characters. Set @length to
* a #gsize to get the length of the string. This function will
* return %NULL on an error
*
* Since: 2.26
*
* Throws: GException on failure.
*/
public string readUpto(string stopChars, ptrdiff_t stopCharsLen, out size_t length, Cancellable cancellable)
{
GError* err = null;
auto retStr = g_data_input_stream_read_upto(gDataInputStream, Str.toStringz(stopChars), stopCharsLen, &length, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
scope(exit) Str.freeString(retStr);
return Str.toString(retStr);
}
/**
* The asynchronous version of g_data_input_stream_read_upto().
* It is an error to have two outstanding calls to this function.
*
* In contrast to g_data_input_stream_read_until(), this function
* does not consume the stop character. You have to use
* g_data_input_stream_read_byte() to get it before calling
* g_data_input_stream_read_upto() again.
*
* Note that @stop_chars may contain '\0' if @stop_chars_len is
* specified.
*
* When the operation is finished, @callback will be called. You
* can then call g_data_input_stream_read_upto_finish() to get
* the result of the operation.
*
* Params:
* stopChars = characters to terminate the read
* stopCharsLen = length of @stop_chars. May be -1 if @stop_chars is
* nul-terminated
* ioPriority = the [I/O priority][io-priority] of the request
* cancellable = optional #GCancellable object, %NULL to ignore
* callback = callback to call when the request is satisfied
* userData = the data to pass to callback function
*
* Since: 2.26
*/
public void readUptoAsync(string stopChars, ptrdiff_t stopCharsLen, int ioPriority, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
{
g_data_input_stream_read_upto_async(gDataInputStream, Str.toStringz(stopChars), stopCharsLen, ioPriority, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
}
/**
* Finish an asynchronous call started by
* g_data_input_stream_read_upto_async().
*
* Note that this function does not consume the stop character. You
* have to use g_data_input_stream_read_byte() to get it before calling
* g_data_input_stream_read_upto_async() again.
*
* Params:
* result = the #GAsyncResult that was provided to the callback
* length = a #gsize to get the length of the data read in
*
* Returns: a string with the data that was read
* before encountering any of the stop characters. Set @length to
* a #gsize to get the length of the string. This function will
* return %NULL on an error.
*
* Since: 2.24
*
* Throws: GException on failure.
*/
public string readUptoFinish(AsyncResultIF result, out size_t length)
{
GError* err = null;
auto retStr = g_data_input_stream_read_upto_finish(gDataInputStream, (result is null) ? null : result.getAsyncResultStruct(), &length, &err);
if (err !is null)
{
throw new GException( new ErrorG(err) );
}
scope(exit) Str.freeString(retStr);
return Str.toString(retStr);
}
/**
* This function sets the byte order for the given @stream. All subsequent
* reads from the @stream will be read in the given @order.
*
* Params:
* order = a #GDataStreamByteOrder to set.
*/
public void setByteOrder(GDataStreamByteOrder order)
{
g_data_input_stream_set_byte_order(gDataInputStream, order);
}
/**
* Sets the newline type for the @stream.
*
* Note that using G_DATA_STREAM_NEWLINE_TYPE_ANY is slightly unsafe. If a read
* chunk ends in "CR" we must read an additional byte to know if this is "CR" or
* "CR LF", and this might block if there is no more data available.
*
* Params:
* type = the type of new line return as #GDataStreamNewlineType.
*/
public void setNewlineType(GDataStreamNewlineType type)
{
g_data_input_stream_set_newline_type(gDataInputStream, type);
}
}
|