glibmm 2.34.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Related Functions | List of all members
Gio::OutputStream Class Reference
Stream Classes

Base class for implementing streaming output. More...

`#include <giomm/outputstream.h>`

Inheritance diagram for Gio::OutputStream:
[legend]

## Public Member Functions

virtual | ~OutputStream ()
GOutputStream* | gobj ()
| Provides access to the underlying C GObject.
const GOutputStream* | gobj () const
| Provides access to the underlying C GObject.
GOutputStream* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
gssize | write (const void* buffer, gsize count, const Glib::RefPtr< Cancellable >& cancellable)
| Tries to write count bytes from buffer into the stream.
gssize | write (const void* buffer, gsize count)
| A write() convenience overload.
gssize | write (const std::string& buffer, const Glib::RefPtr< Cancellable >& cancellable)
| Tries to write count bytes from buffer into the stream.
gssize | write (const std::string& buffer)
| Tries to write count bytes from buffer into the stream.
bool | write_all (const void* buffer, gsize count, gsize& bytes_written, const Glib::RefPtr< Cancellable >& cancellable)
| Tries to write count bytes from buffer into the stream.
bool | write_all (const void* buffer, gsize count, gsize& bytes_written)
| A write_all() convenience overload.
bool | write_all (const std::string& buffer, gsize& bytes_written, const Glib::RefPtr< Cancellable >& cancellable)
| Tries to write count bytes from buffer into the stream.
bool | write_all (const std::string& buffer, gsize& bytes_written)
| Tries to write count bytes from buffer into the stream.
gssize | write_bytes (const Glib::RefPtr< const Glib::Bytes >& bytes, const Glib::RefPtr< Cancellable >& cancellable)
| Tries to write the data from bytes into the stream.
gssize | write_bytes (const Glib::RefPtr< const Glib::Bytes >& bytes)
| A write_bytes() convenience overload.
void | write_bytes_async (const Glib::RefPtr< const Glib::Bytes >& bytes, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, int io_priority=Glib::PRIORITY_DEFAULT)
| Request an asynchronous write of the data in bytes to the stream.
void | write_bytes_async (const Glib::RefPtr< const Glib::Bytes >& bytes, const SlotAsyncReady& slot, int io_priority=Glib::PRIORITY_DEFAULT)
| Request an asynchronous write of the data in bytes to the stream.
gssize | write_bytes_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes a stream write-from-Bytes operation.
gssize | splice (const Glib::RefPtr< InputStream >& source, const Glib::RefPtr< Cancellable >& cancellable, OutputStreamSpliceFlags flags=OUTPUT_STREAM_SPLICE_NONE)
| Splices an input stream into an output stream.
gssize | splice (const Glib::RefPtr< InputStream >& source, OutputStreamSpliceFlags flags=OUTPUT_STREAM_SPLICE_NONE)
| Splices an input stream into an output stream.
bool | flush (const Glib::RefPtr< Cancellable >& cancellable)
| Flushed any outstanding buffers in the stream.
bool | flush ()
| A flush() convenience overload.
bool | close (const Glib::RefPtr< Cancellable >& cancellable)
| Closes the stream, releasing resources related to it.
bool | close ()
| A close() convenience overload.
void | write_async (const void* buffer, gsize count, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, int io_priority=Glib::PRIORITY_DEFAULT)
| Request an asynchronous write of count bytes from buffer into the stream.
void | write_async (const void* buffer, gsize count, const SlotAsyncReady& slot, int io_priority=Glib::PRIORITY_DEFAULT)
| Request an asynchronous write of count bytes from buffer into the stream.
gssize | write_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes a stream write operation.
void | splice_async (const Glib::RefPtr< InputStream >& source, const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, OutputStreamSpliceFlags flags=OUTPUT_STREAM_SPLICE_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Splices a stream asynchronously.
void | splice_async (const Glib::RefPtr< InputStream >& source, const SlotAsyncReady& slot, OutputStreamSpliceFlags flags=OUTPUT_STREAM_SPLICE_NONE, int io_priority=Glib::PRIORITY_DEFAULT)
| Splices a stream asynchronously.
gssize | splice_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes an asynchronous stream splice operation.
void | flush_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, int io_priority=Glib::PRIORITY_DEFAULT)
| Flushes a stream asynchronously.
void | flush_async (const SlotAsyncReady& slot, int io_priority=Glib::PRIORITY_DEFAULT)
| Flushes a stream asynchronously.
bool | flush_finish (const Glib::RefPtr< AsyncResult >& result)
| Finishes flushing an output stream.
void | close_async (const SlotAsyncReady& slot, const Glib::RefPtr< Cancellable >& cancellable, int io_priority=Glib::PRIORITY_DEFAULT)
| Requests an asynchronous close of the stream, releasing resources related to it.
void | close_async (const SlotAsyncReady& slot, int io_priority=Glib::PRIORITY_DEFAULT)
| Requests an asynchronous close of the stream, releasing resources related to it.
bool | close_finish (const Glib::RefPtr< AsyncResult >& result)
| Closes an output stream.
Public Member Functions inherited from Glib::Object
void* | get_data (const QueryQuark& key)
void | set_data (const Quark& key, void* data)
void | set_data (const Quark& key, void* data, DestroyNotify notify)
void | remove_data (const QueryQuark& quark)
void* | steal_data (const QueryQuark& quark)
Public Member Functions inherited from Glib::ObjectBase
void | set_property_value (const Glib::ustring& property_name, const Glib::ValueBase& value)
| You probably want to use a specific property_*() accessor method instead.
void | get_property_value (const Glib::ustring& property_name, Glib::ValueBase& value) const
| You probably want to use a specific property_*() accessor method instead.
template<class PropertyType >
void | set_property (const Glib::ustring& property_name, const PropertyType& value)
| You probably want to use a specific property_*() accessor method instead.
template<class PropertyType >
void | get_property (const Glib::ustring& property_name, PropertyType& value) const
| You probably want to use a specific property_*() accessor method instead.
void | connect_property_changed (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead, but this is necessary when using the reduced API.
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead, but this is necessary when using the reduced API.
void | freeze_notify ()
| Increases the freeze count on object.
void | thaw_notify ()
| Reverts the effect of a previous call to freeze_notify().
virtual void | reference () const
| Increment the reference count for this object.
virtual void | unreference () const
| Decrement the reference count for this object.
GObject* | gobj ()
| Provides access to the underlying C GObject.
const GObject* | gobj () const
| Provides access to the underlying C GObject.
GObject* | gobj_copy () const
| Give a ref-ed copy to someone. Use for direct struct access.
Public Member Functions inherited from sigc::trackable
| trackable (const trackable &src)
trackable & | operator= (const trackable &src)
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const
void | remove_destroy_notify_callback (void *data) const
void | notify_callbacks ()

## Static Public Member Functions

static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system.

## Related Functions

(Note that these are not member functions.)
Glib::RefPtr< Gio::OutputStream > | wrap (GOutputStream* object, bool take_copy=false)
| A Glib::wrap() method for this object.
Related Functions inherited from Glib::Object
Glib::RefPtr< Glib::Object > | wrap (GObject* object, bool take_copy=false)

## Additional Inherited Members

Public Types inherited from Glib::Object
typedef void(* | DestroyNotify )(gpointer data)
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams& construct_params)
| Object (GObject* castitem)
virtual | ~Object ()

## Detailed Description

Base class for implementing streaming output.

Since glibmm 2.16:

## Constructor & Destructor Documentation

virtual Gio::OutputStream::~OutputStream | ( |  | ) |

virtual

## Member Function Documentation

bool Gio::OutputStream::close | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Closes the stream, releasing resources related to it.

Once the stream is closed, all other operations will throw a Gio::Error with CLOSED. Closing a stream multiple times will not cause an error to be thrown.

Closing a stream will automatically flush any outstanding buffers in the stream.

Streams will be automatically closed when the last reference is dropped, but you might want to call this function to make sure resources are released as early as possible.

Some streams might keep the backing store of the stream (e.g. a file descriptor) open after the stream is closed. See the documentation for the individual stream for details.

On failure the first error that happened will be reported, but the close operation will finish as much as possible. A stream that failed to close will still throw a Gio::Error with CLOSED for all operations. Still, it is important to check and report the error to the user, otherwise there might be a loss of data as all data might not be written.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED. Cancelling a close will still leave the stream closed, but there some streams can use a faster close that doesn't block to e.g. check errors. On cancellation (as with any error) there is no guarantee that all written data will reach the target.

Parameters

  cancellable | Cancellable object.

Returns
  `true` on success, `false` on failure.

bool Gio::OutputStream::close | ( |  | ) |

A close() convenience overload.

void Gio::OutputStream::close_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Requests an asynchronous close of the stream, releasing resources related to it.

When the operation is finished the slot will be called, giving the results. You can then call close_finish() to get the result of the operation. For behaviour details see close().

The asyncronous methods have a default fallback that uses threads to implement asynchronicity, so they are optional for inheriting classes. However, if you override one you must override all.

Parameters

  slot | Callback slot to call when the request is satisfied.
  cancellable | Cancellable object.
  io_priority | The io priority of the request.

void Gio::OutputStream::close_async | ( | const SlotAsyncReady& | slot,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Requests an asynchronous close of the stream, releasing resources related to it.

When the operation is finished the slot will be called, giving the results. You can then call close_finish() to get the result of the operation. For behaviour details see close().

The asyncronous methods have a default fallback that uses threads to implement asynchronicity, so they are optional for inheriting classes. However, if you override one you must override all.

Parameters

  slot | Callback slot to call when the request is satisfied.
  io_priority | The io priority of the request.

bool Gio::OutputStream::close_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Closes an output stream.

Parameters

  result | A AsyncResult.

Returns
  `true` if stream was successfully closed, `false` otherwise.

bool Gio::OutputStream::flush | ( | const Glib::RefPtr< Cancellable >& | cancellable | ) |

Flushed any outstanding buffers in the stream.

Will block during the operation. Closing the stream will implicitly cause a flush.

This function is optional for inherited classes.

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED.

Parameters

  cancellable | Cancellable object.

Returns
  `true` on success, `false` on error.

bool Gio::OutputStream::flush | ( |  | ) |

A flush() convenience overload.

void Gio::OutputStream::flush_async | ( | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Flushes a stream asynchronously.

When the operation is finished the slot will be called, giving the results. You can then call flush_finish() to get the result of the operation. For behaviour details see flush().

Parameters

  slot | Callback slot to call when the request is satisfied.
  cancellable | Cancellable object.
  io_priority | The io priority of the request.

void Gio::OutputStream::flush_async | ( | const SlotAsyncReady& | slot,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Flushes a stream asynchronously.

When the operation is finished the slot will be called, giving the results. You can then call flush_finish() to get the result of the operation. For behaviour details see flush().

Parameters

  slot | Callback slot to call when the request is satisfied.
  io_priority | The io priority of the request.

bool Gio::OutputStream::flush_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes flushing an output stream.

Parameters

  result | A GAsyncResult.

Returns
  `true` if flush operation succeeded, `false` otherwise.

static GType Gio::OutputStream::get_type | ( |  | ) |

static

Get the GType for this class, for use with the underlying GObject type system.

GOutputStream* Gio::OutputStream::gobj | ( |  | ) |

inline

Provides access to the underlying C GObject.

const GOutputStream* Gio::OutputStream::gobj | ( |  | ) | const

inline

Provides access to the underlying C GObject.

GOutputStream* Gio::OutputStream::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

gssize Gio::OutputStream::splice | ( | const Glib::RefPtr< InputStream >& | source,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | OutputStreamSpliceFlags | flags = `OUTPUT_STREAM_SPLICE_NONE`
| ) |  |

Splices an input stream into an output stream.

Parameters

  source | An InputStream.
  flags | A set of OutputStreamSpliceFlags.
  cancellable | A Cancellable object. ignore.

Returns
  A #gssize containing the size of the data spliced.

gssize Gio::OutputStream::splice | ( | const Glib::RefPtr< InputStream >& | source,
|  | OutputStreamSpliceFlags | flags = `OUTPUT_STREAM_SPLICE_NONE`
| ) |  |

Splices an input stream into an output stream.

Parameters

  source | An InputStream.
  flags | A set of OutputStreamSpliceFlags. ignore.

Returns
  A #gssize containing the size of the data spliced.

void Gio::OutputStream::splice_async | ( | const Glib::RefPtr< InputStream >& | source,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | OutputStreamSpliceFlags | flags = `OUTPUT_STREAM_SPLICE_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Splices a stream asynchronously.

When the operation is finished slot will be called. You can then call splice_finish() to get the result of the operation.

For the synchronous, blocking version of this function, see splice().

Parameters

  source | An InputStream.
  slot | Callback slot to call when the request is satisfied.
  cancellable | Cancellable object.
  io_priority | The io priority of the request.

void Gio::OutputStream::splice_async | ( | const Glib::RefPtr< InputStream >& | source,
|  | const SlotAsyncReady& | slot,
|  | OutputStreamSpliceFlags | flags = `OUTPUT_STREAM_SPLICE_NONE`,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Splices a stream asynchronously.

When the operation is finished slot will be called. You can then call splice_finish() to get the result of the operation.

For the synchronous, blocking version of this function, see splice().

Parameters

  source | An InputStream.
  slot | Callback slot to call when the request is satisfied.
  io_priority | The io priority of the request.

gssize Gio::OutputStream::splice_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes an asynchronous stream splice operation.

Parameters

  result | A AsyncResult.

Returns
  A #gssize of the number of bytes spliced. Note that if the number of bytes spliced is greater than MAXSSIZE, then that will be returned, and there is no way to determine the actual number of bytes spliced.

gssize Gio::OutputStream::write | ( | const void * | buffer,
|  | gsize | count,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Tries to write count bytes from buffer into the stream.

Will block during the operation.

If count is zero returns zero and does nothing. A value of count larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown.

On success, the number of bytes written to the stream is returned. It is not an error if this is not the same as the requested size, as it can happen e.g. on a partial i/o error, or if there is not enough storage in the stream. All writes either block until at least one byte is written, so zero is never returned (unless count is zero).

The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, a Gio::Error will be thrown with CANCELLED. If an operation was partially finished when the operation was cancelled the partial result will be returned, without an error.

Parameters

  buffer | The buffer containing the data to write.
  count | The number of bytes to write.
  cancellable | Cancellable object.

Returns
  Number of bytes written, or -1 on error.

gssize Gio::OutputStream::write | ( | const void * | buffer,
|  | gsize | count
| ) |  |

A write() convenience overload.

gssize Gio::OutputStream::write | ( | const std::string & | buffer,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Tries to write count bytes from buffer into the stream.

Will block during the operation.

If count is zero returns zero and does nothing. A value of count larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown.

On success, the number of bytes written to the stream is returned. It is not an error if this is not the same as the requested size, as it can happen e.g. on a partial i/o error, or if the there is not enough storage in the stream. All writes either block until at least one byte is written, so zero is never returned (unless count is zero).

On error -1 is returned.

Parameters

  buffer | The buffer containing the data to write.
  cancellable | Cancellable object.

Returns
  Number of bytes written, or -1 on error.

gssize Gio::OutputStream::write | ( | const std::string & | buffer | ) |

Tries to write count bytes from buffer into the stream.

Will block during the operation.

If string that is larger than MAXSSIZE bytes will cause a Gio::Error with INVALID_ARGUMENT to be thrown.

On success, the number of bytes written to the stream is returned. It is not an error if this is not the same as the requested size, as it can happen e.g. on a partial i/o error, or if the there is not enough storage in the stream. All writes either block until at least one byte is written, so zero is never returned (unless count is zero).

On error -1 is returned.

Parameters

  buffer | The buffer containing the data to write.

Returns
  Number of bytes written, or -1 on error.

bool Gio::OutputStream::write_all | ( | const void * | buffer,
|  | gsize | count,
|  | gsize & | bytes_written,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Tries to write count bytes from buffer into the stream.

Will block during the operation.

This function is similar to g_output_stream_write(), except it tries to write as many bytes as requested, only stopping on an error.

On a successful write of count bytes, `true` is returned, and bytes_written is set to count.

If there is an error during the operation `false` is returned and error is set to indicate the error status, bytes_written is updated to contain the number of bytes written into the stream before the error occurred.

Parameters

  buffer | The buffer containing the data to write.
  count | The number of bytes to write.
  bytes_written | Location to store the number of bytes that was written to the stream.
  cancellable | Optional Cancellable object, `0` to ignore.

Returns
  `true` on success, `false` if there was an error.

bool Gio::OutputStream::write_all | ( | const void * | buffer,
|  | gsize | count,
|  | gsize & | bytes_written
| ) |  |

A write_all() convenience overload.

bool Gio::OutputStream::write_all | ( | const std::string & | buffer,
|  | gsize & | bytes_written,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Tries to write count bytes from buffer into the stream.

Will block during the operation.

This function is similar to write(), except it tries to write as many bytes as requested, only stopping on an error.

On a successful write of count bytes, `true` is returned, and bytes_written is set to count .

If there is an error during the operation `false` is returned and error is set to indicate the error status, bytes_written is updated to contain the number of bytes written into the stream before the error occured.

Parameters

  buffer | The buffer containing the data to write.
  bytes_written | Location to store the number of bytes that was written to the stream.
  cancellable | Cancellable object.

Returns
  `true` on success, `false` if there was an error.

bool Gio::OutputStream::write_all | ( | const std::string & | buffer,
|  | gsize & | bytes_written
| ) |  |

Tries to write count bytes from buffer into the stream.

Will block during the operation.

This function is similar to write(), except it tries to write as many bytes as requested, only stopping on an error.

On a successful write of count bytes, `true` is returned, and bytes_written is set to count .

If there is an error during the operation `false` is returned and error is set to indicate the error status, bytes_written is updated to contain the number of bytes written into the stream before the error occured.

Parameters

  buffer | The buffer containing the data to write.
  bytes_written | Location to store the number of bytes that was written to the stream.

Returns
  `true` on success, `false` if there was an error.

void Gio::OutputStream::write_async | ( | const void * | buffer,
|  | gsize | count,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Request an asynchronous write of count bytes from buffer into the stream.

When the operation is finished slot will be called. You can then call write_finish() to get the result of the operation.

During an async request no other sync and async calls are allowed, and will result in Gio::Error with PENDING being thrown.

A value of count larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown.

On success, the number of bytes written will be passed to the callback slot. It is not an error if this is not the same as the requested size, as it can happen e.g. on a partial I/O error, but generally we try to write as many bytes as requested.

Any outstanding I/O request with higher priority (lower numerical value) will be executed before an outstanding request with lower priority. Default priority is Glib::PRIORITY_DEFAULT.

The asyncronous methods have a default fallback that uses threads to implement asynchronicity, so they are optional for inheriting classes. However, if you override one you must override all.

For the synchronous, blocking version of this function, see write().

Parameters

  buffer | The buffer containing the data to write.
  count | The number of bytes to write
  slot | Callback slot to call when the request is satisfied.
  cancellable | Cancellable object.
  io_priority | The io priority of the request.

void Gio::OutputStream::write_async | ( | const void * | buffer,
|  | gsize | count,
|  | const SlotAsyncReady& | slot,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Request an asynchronous write of count bytes from buffer into the stream.

When the operation is finished slot will be called. You can then call write_finish() to get the result of the operation.

During an async request no other sync and async calls are allowed, and will result in Gio::Error with PENDING being thrown.

A value of count larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown.

On success, the number of bytes written will be passed to the callback slot. It is not an error if this is not the same as the requested size, as it can happen e.g. on a partial I/O error, but generally we try to write as many bytes as requested.

Any outstanding I/O request with higher priority (lower numerical value) will be executed before an outstanding request with lower priority. Default priority is Glib::PRIORITY_DEFAULT.

The asyncronous methods have a default fallback that uses threads to implement asynchronicity, so they are optional for inheriting classes. However, if you override one you must override all.

For the synchronous, blocking version of this function, see write().

Parameters

  buffer | The buffer containing the data to write.
  count | The number of bytes to write
  slot | Callback slot to call when the request is satisfied.
  io_priority | The io priority of the request.

gssize Gio::OutputStream::write_bytes | ( | const Glib::RefPtr< const Glib::Bytes >& | bytes,
|  | const Glib::RefPtr< Cancellable >& | cancellable
| ) |  |

Tries to write the data from bytes into the stream.

Will block during the operation.

If bytes is 0-length, returns 0 and does nothing. A Bytes larger than MAXSSIZE will cause a IO_ERROR_INVALID_ARGUMENT error.

On success, the number of bytes written to the stream is returned. It is not an error if this is not the same as the requested size, as it can happen e.g. on a partial I/O error, or if there is not enough storage in the stream. All writes block until at least one byte is written or an error occurs; 0 is never returned (unless the size of bytes is 0).

If cancellable is not `0`, then the operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled, the error IO_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.

On error -1 is returned and error is set accordingly.

Parameters

  bytes | The Bytes to write.
  cancellable | Optional cancellable object.

Returns
  Number of bytes written, or -1 on error.

gssize Gio::OutputStream::write_bytes | ( | const Glib::RefPtr< const Glib::Bytes >& | bytes | ) |

A write_bytes() convenience overload.

void Gio::OutputStream::write_bytes_async | ( | const Glib::RefPtr< const Glib::Bytes >& | bytes,
|  | const SlotAsyncReady& | slot,
|  | const Glib::RefPtr< Cancellable >& | cancellable,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Request an asynchronous write of the data in bytes to the stream.

When the operation is finished slot will be called. You can then call write_bytes_finish() to get the result of the operation.

During an async request no other sync and async calls are allowed, and will result in Gio::Error with PENDING being thrown.

A Glib:Bytes larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown.

On success, the number of bytes written will be passed to the callback slot. It is not an error if this is not the same as the requested size, as it can happen e.g. on a partial I/O error, but generally we try to write as many bytes as requested.

You are guaranteed that this method will never fail with IO_ERROR_WOULD_BLOCK - if the stream can't accept more data, the method will just wait until this changes.

Any outstanding I/O request with higher priority (lower numerical value) will be executed before an outstanding request with lower priority. Default priority is Glib::PRIORITY_DEFAULT.

For the synchronous, blocking version of this function, see write_bytes().

Parameters

  bytes | The bytes to
  slot | Callback slot to call when the request is satisfied.
  cancellable | Cancellable object.
  io_priority | The io priority of the request.

Since glibmm 2.34:

void Gio::OutputStream::write_bytes_async | ( | const Glib::RefPtr< const Glib::Bytes >& | bytes,
|  | const SlotAsyncReady& | slot,
|  | int | io_priority = `Glib::PRIORITY_DEFAULT`
| ) |  |

Request an asynchronous write of the data in bytes to the stream.

When the operation is finished slot will be called. You can then call write_bytes_finish() to get the result of the operation.

During an async request no other sync and async calls are allowed, and will result in Gio::Error with PENDING being thrown.

A Glib:Bytes larger than MAXSSIZE will cause a Gio::Error with INVALID_ARGUMENT to be thrown.

On success, the number of bytes written will be passed to the callback slot. It is not an error if this is not the same as the requested size, as it can happen e.g. on a partial I/O error, but generally we try to write as many bytes as requested.

You are guaranteed that this method will never fail with IO_ERROR_WOULD_BLOCK - if the stream can't accept more data, the method will just wait until this changes.

Any outstanding I/O request with higher priority (lower numerical value) will be executed before an outstanding request with lower priority. Default priority is Glib::PRIORITY_DEFAULT.

For the synchronous, blocking version of this function, see write_bytes().

Parameters

  bytes | The bytes to
  slot | Callback slot to call when the request is satisfied.
  io_priority | The io priority of the request.

Since glibmm 2.34:

gssize Gio::OutputStream::write_bytes_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes a stream write-from-Bytes operation.

Parameters

  result | A AsyncResult.

Returns
  A #gssize containing the number of bytes written to the stream.

gssize Gio::OutputStream::write_finish | ( | const Glib::RefPtr< AsyncResult >& | result | ) |

Finishes a stream write operation.

Parameters

  result | A AsyncResult.

Returns
  A #gssize containing the number of bytes written to the stream.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::OutputStream > wrap | ( | GOutputStream * | object,
|  | bool | take_copy = `false`
| ) |  |

related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.