1 // Generated by gmmproc 2.64.2 -- DO NOT MODIFY! 2 #ifndef _GIOMM_INPUTSTREAM_H 3 #define _GIOMM_INPUTSTREAM_H 4 5 6 #include <glibmm/ustring.h> 7 #include <sigc++/sigc++.h> 8 9 /* Copyright (C) 2007 The giomm Development Team 10 * 11 * This library is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 15 * 16 * This library is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 23 */ 24 25 #include <glibmm/object.h> 26 #include <glibmm/priorities.h> 27 #include <glibmm/bytes.h> 28 29 #include <giomm/asyncresult.h> 30 #include <giomm/cancellable.h> 31 32 33 #ifndef DOXYGEN_SHOULD_SKIP_THIS 34 using GInputStream = struct _GInputStream; 35 using GInputStreamClass = struct _GInputStreamClass; 36 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 37 38 39 #ifndef DOXYGEN_SHOULD_SKIP_THIS 40 namespace Gio 41 { class GIOMM_API InputStream_Class; } // namespace Gio 42 #endif //DOXYGEN_SHOULD_SKIP_THIS 43 44 namespace Gio 45 { 46 47 //TODO: Implement operator << and >> for streams? 48 49 /** Base class for implementing streaming input. 50 * 51 * @ingroup Streams 52 * 53 * @newin{2,16} 54 */ 55 56 class GIOMM_API InputStream : public Glib::Object 57 { 58 59 #ifndef DOXYGEN_SHOULD_SKIP_THIS 60 61 public: 62 using CppObjectType = InputStream; 63 using CppClassType = InputStream_Class; 64 using BaseObjectType = GInputStream; 65 using BaseClassType = GInputStreamClass; 66 67 // noncopyable 68 InputStream(const InputStream&) = delete; 69 InputStream& operator=(const InputStream&) = delete; 70 71 private: friend class InputStream_Class; 72 static CppClassType inputstream_class_; 73 74 protected: 75 explicit InputStream(const Glib::ConstructParams& construct_params); 76 explicit InputStream(GInputStream* castitem); 77 78 #endif /* DOXYGEN_SHOULD_SKIP_THIS */ 79 80 public: 81 82 InputStream(InputStream&& src) noexcept; 83 InputStream& operator=(InputStream&& src) noexcept; 84 85 ~InputStream() noexcept override; 86 87 /** Get the GType for this class, for use with the underlying GObject type system. 88 */ 89 static GType get_type() G_GNUC_CONST; 90 91 #ifndef DOXYGEN_SHOULD_SKIP_THIS 92 93 94 static GType get_base_type() G_GNUC_CONST; 95 #endif 96 97 ///Provides access to the underlying C GObject. gobj()98 GInputStream* gobj() { return reinterpret_cast<GInputStream*>(gobject_); } 99 100 ///Provides access to the underlying C GObject. gobj()101 const GInputStream* gobj() const { return reinterpret_cast<GInputStream*>(gobject_); } 102 103 ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. 104 GInputStream* gobj_copy(); 105 106 private: 107 108 109 protected: 110 InputStream(); 111 112 public: 113 114 /** Tries to read @a count bytes from the stream into the buffer starting at 115 * @a buffer. Will block during this read. 116 * 117 * If count is zero returns zero and does nothing. A value of @a count 118 * larger than G_MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown. 119 * 120 * On success, the number of bytes read into the buffer is returned. 121 * It is not an error if this is not the same as the requested size, as it 122 * can happen e.g. near the end of a file. Zero is returned on end of file 123 * (or if @a count is zero), but never otherwise. 124 * 125 * The operation can be cancelled by 126 * triggering the cancellable object from another thread. If the operation 127 * was cancelled, a Gio::Error will be thrown with CANCELLED. If an 128 * operation was partially finished when the operation was cancelled the 129 * partial result will be returned, without an error. 130 * 131 * @param buffer A buffer to read data into (which should be at least count bytes long). 132 * @param count The number of bytes that will be read from the stream. 133 * @param cancellable Cancellable object. 134 * @return Number of bytes read, or -1 on error. 135 * 136 * @throws Glib::Error 137 */ 138 gssize read(void* buffer, gsize count, const Glib::RefPtr<Cancellable>& cancellable); 139 140 /// A read() convenience overload. 141 gssize read(void* buffer, gsize count); 142 143 //TODO: for glibmm 2.17/18, we should decide whether to provide a read() 144 // function as below, which would presumably read until EOL, or one with 145 // an additional size parameter, at the same time taking into account 146 // what operators >> and << (for OutputStream) will do. 147 //TODO: gssize read(std::string& buffer, const Glib::RefPtr<Cancellable>& cancellable); 148 //TODO: gssize read(std::string& buffer); 149 150 151 /** Tries to read @a count bytes from the stream into the buffer starting at 152 * @a buffer. Will block during this read. 153 * 154 * This function is similar to g_input_stream_read(), except it tries to 155 * read as many bytes as requested, only stopping on an error or end of stream. 156 * 157 * On a successful read of @a count bytes, or if we reached the end of the 158 * stream, <tt>true</tt> is returned, and @a bytes_read is set to the number of bytes 159 * read into @a buffer. 160 * 161 * If there is an error during the operation <tt>false</tt> is returned and @a error 162 * is set to indicate the error status. 163 * 164 * As a special exception to the normal conventions for functions that 165 * use Error, if this function returns <tt>false</tt> (and sets @a error) then 166 * @a bytes_read will be set to the number of bytes that were successfully 167 * read before the error was encountered. This functionality is only 168 * available from C. If you need it from another language then you must 169 * write your own loop around g_input_stream_read(). 170 * 171 * @param buffer A buffer to read data into (which should be at least count bytes long). 172 * @param count The number of bytes that will be read from the stream. 173 * @param bytes_read Location to store the number of bytes that was read from the stream. 174 * @param cancellable Optional Cancellable object, <tt>nullptr</tt> to ignore. 175 * @return <tt>true</tt> on success, <tt>false</tt> if there was an error. 176 * 177 * @throws Glib::Error 178 */ 179 bool read_all(void* buffer, gsize count, gsize& bytes_read, const Glib::RefPtr<Cancellable>& cancellable); 180 181 /// A read_all() convenience overload. 182 bool read_all(void* buffer, gsize count, gsize& bytes_read); 183 184 //TODO: bool read_all(std::string& buffer, gsize count, gsize& bytes_read, const Glib::RefPtr<Cancellable>& cancellable); 185 //TODO: bool read_all(std::string& buffer, gsize count, gsize& bytes_read) 186 187 188 /** Like g_input_stream_read(), this tries to read @a count bytes from 189 * the stream in a blocking fashion. However, rather than reading into 190 * a user-supplied buffer, this will create a new Bytes containing 191 * the data that was read. This may be easier to use from language 192 * bindings. 193 * 194 * If count is zero, returns a zero-length Bytes and does nothing. A 195 * value of @a count larger than G_MAXSSIZE will cause a 196 * IO_ERROR_INVALID_ARGUMENT error. 197 * 198 * On success, a new Bytes is returned. It is not an error if the 199 * size of this object is not the same as the requested size, as it 200 * can happen e.g. near the end of a file. A zero-length Bytes is 201 * returned on end of file (or if @a count is zero), but never 202 * otherwise. 203 * 204 * If @a cancellable is not <tt>nullptr</tt>, then the operation can be cancelled by 205 * triggering the cancellable object from another thread. If the operation 206 * was cancelled, the error IO_ERROR_CANCELLED will be returned. If an 207 * operation was partially finished when the operation was cancelled the 208 * partial result will be returned, without an error. 209 * 210 * On error <tt>nullptr</tt> is returned and @a error is set accordingly. 211 * 212 * @newin{2,34} 213 * 214 * @param count Maximum number of bytes that will be read from the stream. Common 215 * values include 4096 and 8192. 216 * @param cancellable Optional Cancellable object, <tt>nullptr</tt> to ignore. 217 * @return A new Bytes, or <tt>nullptr</tt> on error. 218 * 219 * @throws Glib::Error 220 */ 221 Glib::RefPtr<Glib::Bytes> read_bytes(gsize count, const Glib::RefPtr<Cancellable>& cancellable); 222 223 //TODO: Why not use _WRAP_METHOD() for this? 224 /** Request an asynchronous read of @a count bytes from the stream into a 225 * new Glib::Bytes. When the operation is finished @a slot will be called. 226 * You can then call read_bytes_finish() to get the result of the 227 * operation. 228 * 229 * During an async request no other sync and async calls are allowed, and will 230 * result in Gio::Error with PENDING being thrown. 231 * 232 * A value of @a count larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown. 233 * 234 * On success, the new Glib::Bytes will be passed to the callback. It is 235 * not an error if this is smaller than the requested size, as it can 236 * happen e.g. near the end of a file, but generally we try to read as 237 * many bytes as requested. Zero is returned on end of file (or if 238 * @a count is zero), but never otherwise. 239 * 240 * Any outstanding I/O request with higher priority (lower numerical 241 * value) will be executed before an outstanding request with lower 242 * priority. The default priority is PRIORITY_DEFAULT. 243 * 244 * @param count The number of bytes that will be read from the stream. 245 * @param slot Callback to call when the request is satisfied. 246 * @param cancellable A Cancellable object. 247 * @param io_priority The I/O priority of the request. 248 * 249 * @newin{2,34} 250 */ 251 void read_bytes_async(gsize count, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, int io_priority = Glib::PRIORITY_DEFAULT); 252 253 /** Request an asynchronous read of @a count bytes from the stream into a 254 * new Glib::Bytes. When the operation is finished @a slot will be called. 255 * You can then call read_bytes_finish() to get the result of the 256 * operation. 257 * 258 * During an async request no other sync and async calls are allowed, and will 259 * result in Gio::Error with PENDING being thrown. 260 * 261 * A value of @a count larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown. 262 * 263 * On success, the new Glib::Bytes will be passed to the callback. It is 264 * not an error if this is smaller than the requested size, as it can 265 * happen e.g. near the end of a file, but generally we try to read as 266 * many bytes as requested. Zero is returned on end of file (or if 267 * @a count is zero), but never otherwise. 268 * 269 * Any outstanding I/O request with higher priority (lower numerical 270 * value) will be executed before an outstanding request with lower 271 * priority. The default priority is PRIORITY_DEFAULT. 272 * 273 * @param count The number of bytes that will be read from the stream. 274 * @param slot Callback to call when the request is satisfied.h 275 * @param io_priority The I/O priority of the request. 276 * 277 * @newin{2,34} 278 */ 279 void read_bytes_async(gsize count, const SlotAsyncReady& slot, int io_priority = Glib::PRIORITY_DEFAULT); 280 281 282 /** Finishes an asynchronous stream read-into-Bytes operation. 283 * 284 * @newin{2,34} 285 * 286 * @param result A AsyncResult. 287 * @return The newly-allocated Bytes, or <tt>nullptr</tt> on error. 288 * 289 * @throws Glib::Error 290 */ 291 Glib::RefPtr<Glib::Bytes> read_bytes_finish(const Glib::RefPtr<AsyncResult>& result); 292 293 294 /** Tries to skip @a count bytes from the stream. Will block during the operation. 295 * 296 * This is identical to g_input_stream_read(), from a behaviour standpoint, 297 * but the bytes that are skipped are not returned to the user. Some 298 * streams have an implementation that is more efficient than reading the data. 299 * 300 * This function is optional for inherited classes, as the default implementation 301 * emulates it using read. 302 * 303 * The operation can be cancelled by 304 * triggering the cancellable object from another thread. If the operation 305 * was cancelled, a Gio::Error will be thrown with CANCELLED. If an 306 * operation was partially finished when the operation was cancelled the 307 * partial result will be returned, without an error. 308 * 309 * @param count The number of bytes that will be skipped from the stream. 310 * @param cancellable Cancellable object. 311 * @return Number of bytes skipped, or -1 on error. 312 * 313 * @throws Glib::Error 314 */ 315 gssize skip(gsize count, const Glib::RefPtr<Cancellable>& cancellable); 316 317 /// A skip() convenience overload. 318 gssize skip(gsize count); 319 320 321 /** Closes the stream, releasing resources related to it. 322 * 323 * Once the stream is closed, all other operations will throw a Gio::Error with CLOSED. 324 * Closing a stream multiple times will not return an error. 325 * 326 * Streams will be automatically closed when the last reference 327 * is dropped, but you might want to call this function to make sure 328 * resources are released as early as possible. 329 * 330 * Some streams might keep the backing store of the stream (e.g. a file descriptor) 331 * open after the stream is closed. See the documentation for the individual 332 * stream for details. 333 * 334 * On failure the first error that happened will be reported, but the close 335 * operation will finish as much as possible. A stream that failed to 336 * close will still throw a Gio::Error with CLOSED for all operations. Still, it 337 * is important to check and report the error to the user. 338 * 339 * The operation can be cancelled by 340 * triggering the cancellable object from another thread. If the operation 341 * was cancelled, a Gio::Error will be thrown with CANCELLED. 342 * Cancelling a close will still leave the stream closed, but some streams 343 * can use a faster close that doesn't block to e.g. check errors. 344 * 345 * @param cancellable Cancellable object. 346 * @return <tt>true</tt> on success, <tt>false</tt> on failure. 347 * 348 * @throws Glib::Error 349 */ 350 bool close(const Glib::RefPtr<Cancellable>& cancellable); 351 352 /// A close() convenience overload. 353 bool close(); 354 355 356 /** Request an asynchronous read of @a count bytes from the stream into the buffer 357 * starting at @a buffer. When the operation is finished @a slot will be called. 358 * You can then call read_finish() to get the result of the 359 * operation. 360 * 361 * During an async request no other sync and async calls are allowed, and will 362 * result in Gio::Error with PENDING being thrown. 363 * 364 * A value of @a count larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown. 365 * 366 * On success, the number of bytes read into the buffer will be passed to the 367 * @a slot callback. It is not an error if this is not the same as the requested size, as it 368 * can happen e.g. near the end of a file, but generally we try to read 369 * as many bytes as requested. Zero is returned on end of file 370 * (or if @a count is zero), but never otherwise. 371 * 372 * Any outstanding i/o request with higher priority (lower numerical value) will 373 * be executed before an outstanding request with lower priority. Default 374 * priority is PRIORITY_DEFAULT. 375 * 376 * The asyncronous methods have a default fallback that uses threads to implement 377 * asynchronicity, so they are optional for inheriting classes. However, if you 378 * override one you must override all. 379 * 380 * @param buffer A buffer to read data into (which should be at least count bytes long). 381 * @param count The number of bytes that will be read from the stream. 382 * @param slot Callback to call when the request is satisfied. 383 * @param cancellable A Cancellable object. 384 * @param io_priority The I/O priority of the request. 385 */ 386 void read_async(void* buffer, gsize count, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, int io_priority = Glib::PRIORITY_DEFAULT); 387 388 /** Request an asynchronous read of @a count bytes from the stream into the buffer 389 * starting at @a buffer. When the operation is finished @a slot will be called. 390 * You can then call read_finish() to get the result of the 391 * operation. 392 * 393 * During an async request no other sync and async calls are allowed, and will 394 * result in a Gio::Error with PENDING being thrown. 395 * 396 * A value of @a count larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown. 397 * 398 * On success, the number of bytes read into the buffer will be passed to the 399 * @a slot callback. It is not an error if this is not the same as the requested size, as it 400 * can happen e.g. near the end of a file, but generally we try to read 401 * as many bytes as requested. Zero is returned on end of file 402 * (or if @a count is zero), but never otherwise. 403 * 404 * Any outstanding i/o request with higher priority (lower numerical value) will 405 * be executed before an outstanding request with lower priority. Default 406 * priority is PRIORITY_DEFAULT. 407 * 408 * The asyncronous methods have a default fallback that uses threads to implement 409 * asynchronicity, so they are optional for inheriting classes. However, if you 410 * override one you must override all. 411 * 412 * @param buffer A buffer to read data into (which should be at least count bytes long). 413 * @param count The number of bytes that will be read from the stream. 414 * @param slot Callback to call when the request is satisfied. 415 * @param io_priority The I/O priority of the request. 416 */ 417 void read_async(void* buffer, gsize count, const SlotAsyncReady& slot, int io_priority = Glib::PRIORITY_DEFAULT); 418 419 420 /** Finishes an asynchronous stream read operation. 421 * 422 * @param result A AsyncResult. 423 * @return Number of bytes read in, or -1 on error, or 0 on end of file. 424 * 425 * @throws Glib::Error 426 */ 427 gssize read_finish(const Glib::RefPtr<AsyncResult>& result); 428 429 430 /** Request an asynchronous read of @a count bytes from the stream into the buffer 431 * starting at @a buffer. This is the asynchronous equivalent of read_all(). 432 * 433 * When the operation is finished @a slot will be called. 434 * You can then call read_all_finish() to get the result of the 435 * operation. 436 * 437 * During an async request no other sync and async calls are allowed, and will 438 * result in Gio::Error with PENDING being thrown. 439 * 440 * A value of @a count larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown. 441 * 442 * On success, the number of bytes read into the buffer will be passed to the 443 * @a slot callback. It is not an error if this is not the same as the requested size, as it 444 * can happen e.g. near the end of a file, but generally we try to read 445 * as many bytes as requested. Zero is returned on end of file 446 * (or if @a count is zero), but never otherwise. 447 * 448 * Any outstanding i/o request with higher priority (lower numerical value) will 449 * be executed before an outstanding request with lower priority. Default 450 * priority is PRIORITY_DEFAULT. 451 * 452 * The asyncronous methods have a default fallback that uses threads to implement 453 * asynchronicity, so they are optional for inheriting classes. However, if you 454 * override one you must override all. 455 * 456 * @param buffer A buffer to read data into (which should be at least count bytes long). 457 * @param count The number of bytes that will be read from the stream. 458 * @param slot Callback to call when the request is satisfied. 459 * @param cancellable A Cancellable object. 460 * @param io_priority The I/O priority of the request. 461 */ 462 void read_all_async(void* buffer, gsize count, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, int io_priority = Glib::PRIORITY_DEFAULT); 463 464 /** Request an asynchronous read of @a count bytes from the stream into the buffer 465 * starting at @a buffer. This is the asynchronous equivalent of read_all(). 466 * 467 * When the operation is finished @a slot will be called. 468 * You can then call read_all_finish() to get the result of the 469 * operation. 470 * 471 * During an async request no other sync and async calls are allowed, and will 472 * result in a Gio::Error with PENDING being thrown. 473 * 474 * A value of @a count larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown. 475 * 476 * On success, the number of bytes read into the buffer will be passed to the 477 * @a slot callback. It is not an error if this is not the same as the requested size, as it 478 * can happen e.g. near the end of a file, but generally we try to read 479 * as many bytes as requested. Zero is returned on end of file 480 * (or if @a count is zero), but never otherwise. 481 * 482 * Any outstanding i/o request with higher priority (lower numerical value) will 483 * be executed before an outstanding request with lower priority. Default 484 * priority is PRIORITY_DEFAULT. 485 * 486 * The asyncronous methods have a default fallback that uses threads to implement 487 * asynchronicity, so they are optional for inheriting classes. However, if you 488 * override one you must override all. 489 * 490 * @param buffer A buffer to read data into (which should be at least count bytes long). 491 * @param count The number of bytes that will be read from the stream. 492 * @param slot Callback to call when the request is satisfied. 493 * @param io_priority The I/O priority of the request. 494 */ 495 void read_all_async(void* buffer, gsize count, const SlotAsyncReady& slot, int io_priority = Glib::PRIORITY_DEFAULT); 496 497 498 /** Finishes an asynchronous stream read operation started with 499 * g_input_stream_read_all_async(). 500 * 501 * As a special exception to the normal conventions for functions that 502 * use Error, if this function returns <tt>false</tt> (and sets @a error) then 503 * @a bytes_read will be set to the number of bytes that were successfully 504 * read before the error was encountered. This functionality is only 505 * available from C. If you need it from another language then you must 506 * write your own loop around g_input_stream_read_async(). 507 * 508 * @newin{2,44} 509 * 510 * @param result A AsyncResult. 511 * @param bytes_read Location to store the number of bytes that was read from the stream. 512 * @return <tt>true</tt> on success, <tt>false</tt> if there was an error. 513 * 514 * @throws Glib::Error 515 */ 516 bool read_all_finish(const Glib::RefPtr<AsyncResult>& result, gsize& bytes_read); 517 518 519 //TODO: Use std::size_type instead of gsize? 520 521 /** Request an asynchronous skip of @a count bytes from the stream into the buffer 522 * starting at @a buffer. When the operation is finished @a slot will be called. 523 * You can then call skip_finish() to get the result of the operation. 524 * 525 * During an async request no other sync and async calls are allowed, and will 526 * result in Gio::Error with PENDING being thrown. 527 * 528 * A value of @a count larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown. 529 * 530 * On success, the number of bytes skipped will be passed to the 531 * callback. It is not an error if this is not the same as the requested size, as it 532 * can happen e.g. near the end of a file, but generally we try to skip 533 * as many bytes as requested. Zero is returned on end of file 534 * (or if @a count is zero), but never otherwise. 535 * 536 * Any outstanding i/o request with higher priority (lower numerical value) will 537 * be executed before an outstanding request with lower priority. Default 538 * priority is PRIORITY_DEFAULT. 539 * 540 * The asyncronous methods have a default fallback that uses threads to implement 541 * asynchronicity, so they are optional for inheriting classes. However, if you 542 * override one you must override all. 543 * 544 * @param count The number of bytes that will be skipped from the stream. 545 * @param slot Callback to call when the request is satisfied. 546 * @param cancellable A Cancellable object. 547 * @param io_priority The I/O priority of the request. 548 */ 549 void skip_async(gsize count, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, int io_priority = Glib::PRIORITY_DEFAULT); 550 551 /** Request an asynchronous skip of @a count bytes from the stream into the buffer 552 * starting at @a buffer. When the operation is finished @a slot will be called. 553 * You can then call skip_finish() to get the result of the operation. 554 * 555 * During an async request no other sync and async calls are allowed, and will 556 * result in Gio::Error with PENDING being thrown. 557 * 558 * A value of @a count larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown. 559 * 560 * On success, the number of bytes skipped will be passed to the 561 * callback. It is not an error if this is not the same as the requested size, as it 562 * can happen e.g. near the end of a file, but generally we try to skip 563 * as many bytes as requested. Zero is returned on end of file 564 * (or if @a count is zero), but never otherwise. 565 * 566 * Any outstanding i/o request with higher priority (lower numerical value) will 567 * be executed before an outstanding request with lower priority. Default 568 * priority is PRIORITY_DEFAULT. 569 * 570 * The asyncronous methods have a default fallback that uses threads to implement 571 * asynchronicity, so they are optional for inheriting classes. However, if you 572 * override one you must override all. 573 * 574 * @param count The number of bytes that will be skipped from the stream. 575 * @param slot Callback to call when the request is satisfied. 576 * @param io_priority The I/O priority of the request. 577 */ 578 void skip_async(gsize count, const SlotAsyncReady& slot, int io_priority = Glib::PRIORITY_DEFAULT); 579 580 581 /** Finishes a stream skip operation. 582 * 583 * @param result A AsyncResult. 584 * @return The size of the bytes skipped, or `-1` on error. 585 * 586 * @throws Glib::Error 587 */ 588 gssize skip_finish(const Glib::RefPtr<AsyncResult>& result); 589 590 /** Requests an asynchronous closes of the stream, releasing resources related to it. 591 * When the operation is finished @a slot will be called. 592 * You can then call close_finish() to get the result of the 593 * operation. 594 * 595 * For behaviour details see close(). 596 * 597 * The asyncronous methods have a default fallback that uses threads to implement 598 * asynchronicity, so they are optional for inheriting classes. However, if you 599 * override one you must override all. 600 * 601 * @param slot Callback to call when the request is satisfied. 602 * @param cancellable A Cancellable object. 603 * @param io_priority The I/O priority of the request. 604 */ 605 void close_async(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, int io_priority = Glib::PRIORITY_DEFAULT); 606 607 /** Requests an asynchronous closes of the stream, releasing resources related to it. 608 * When the operation is finished @a slot will be called. 609 * You can then call close_finish() to get the result of the 610 * operation. 611 * 612 * For behaviour details see close(). 613 * 614 * The asyncronous methods have a default fallback that uses threads to implement 615 * asynchronicity, so they are optional for inheriting classes. However, if you 616 * override one you must override all. 617 * 618 * @param slot Callback to call when the request is satisfied. 619 * @param io_priority The I/O priority of the request. 620 */ 621 void close_async(const SlotAsyncReady& slot, int io_priority = Glib::PRIORITY_DEFAULT); 622 623 624 /** Finishes closing a stream asynchronously, started from g_input_stream_close_async(). 625 * 626 * @param result A AsyncResult. 627 * @return <tt>true</tt> if the stream was closed successfully. 628 * 629 * @throws Glib::Error 630 */ 631 gboolean close_finish(const Glib::RefPtr<AsyncResult>& result); 632 633 634 /** Checks if an input stream is closed. 635 * 636 * @newin{2,50} 637 * 638 * @return <tt>true</tt> if the stream is closed. 639 */ 640 bool is_closed() const; 641 642 /** Checks if an input stream has pending actions. 643 * 644 * @newin{2,50} 645 * 646 * @return <tt>true</tt> if @a stream has pending actions. 647 */ 648 bool has_pending() const; 649 650 protected: 651 652 /** Sets @a stream to have actions pending. If the pending flag is 653 * already set or @a stream is closed, it will return <tt>false</tt> and set 654 * @a error. 655 * 656 * @newin{2,50} 657 * 658 * @return <tt>true</tt> if pending was previously unset and is now set. 659 * 660 * @throws Glib::Error 661 */ 662 bool set_pending(); 663 664 /** Clears the pending flag on @a stream. 665 * 666 * @newin{2,50} 667 */ 668 void clear_pending(); 669 670 //TODO: When we can break ABI, add vfuncs. See https://bugzilla.gnome.org/show_bug.cgi?id=572471 671 672 673 //_WRAP_VFUNC(gssize read(void* buffer, gsize count, const Glib::RefPtr<Cancellable>& cancellable), read_fn, errthrow, err_return_value -1) 674 //_WRAP_VFUNC(gssize skip(gsize count, const Glib::RefPtr<Cancellable>& cancellable), skip, errthrow, err_return_value -1) 675 //_WRAP_VFUNC(bool close(const Glib::RefPtr<Cancellable>& cancellable), close_fn, errthrow) 676 677 678 public: 679 680 public: 681 //C++ methods used to invoke GTK+ virtual functions: 682 683 protected: 684 //GTK+ Virtual Functions (override these to change behaviour): 685 686 //Default Signal Handlers:: 687 688 689 }; 690 691 } // namespace Gio 692 693 694 namespace Glib 695 { 696 /** A Glib::wrap() method for this object. 697 * 698 * @param object The C instance. 699 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref. 700 * @result A C++ instance that wraps this C instance. 701 * 702 * @relates Gio::InputStream 703 */ 704 GIOMM_API 705 Glib::RefPtr<Gio::InputStream> wrap(GInputStream* object, bool take_copy = false); 706 } 707 708 709 #endif /* _GIOMM_INPUTSTREAM_H */ 710 711