glibmm 2.80.0
|
Base class for implementing streaming output. More...
#include <giomm/outputstream.h>
Public Types | |
enum class | SpliceFlags { NONE = 0x0 , CLOSE_SOURCE = (1 << 0) , CLOSE_TARGET = (1 << 1) } |
Public Types inherited from Glib::Object | |
using | DestroyNotify = void(*)(gpointer data) |
Public Member Functions | |
OutputStream (OutputStream &&src) noexcept | |
OutputStream & | operator= (OutputStream &&src) noexcept |
~OutputStream () noexcept override | |
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) |
A wrapper function for g_output_stream_write() which takes a Bytes as input. | |
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, SpliceFlags flags=SpliceFlags::NONE) |
Splices an input stream into an output stream. | |
gssize | splice (const Glib::RefPtr< InputStream > &source, SpliceFlags flags=SpliceFlags::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 | write_all_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_all_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. | |
bool | write_all_finish (const Glib::RefPtr< AsyncResult > &result, gsize &bytes_written) |
Finishes an asynchronous stream write operation started with g_output_stream_write_all_async(). | |
void | splice_async (const Glib::RefPtr< InputStream > &source, const SlotAsyncReady &slot, const Glib::RefPtr< Cancellable > &cancellable, SpliceFlags flags=SpliceFlags::NONE, int io_priority=Glib::PRIORITY_DEFAULT) |
Splices a stream asynchronously. | |
void | splice_async (const Glib::RefPtr< InputStream > &source, const SlotAsyncReady &slot, SpliceFlags flags=SpliceFlags::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. | |
bool | is_closed () const |
Checks if an output stream has already been closed. | |
bool | is_closing () const |
Checks if an output stream is being closed. | |
bool | has_pending () const |
Checks if an output stream has pending actions. | |
Public Member Functions inherited from Glib::Object | |
Object (const Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&src) noexcept | |
Object & | operator= (Object &&src) noexcept |
void * | get_data (const QueryQuark & key) |
void | set_data (const Quark & key, void *data) |
void | set_data_with_c_callback (const Quark & key, void *data, GDestroyNotify notify) |
void | set_data (const Quark & key, void *data, DestroyNotify notify) |
Prefer set_data_with_c_callback() with a callback with C linkage. | |
void | remove_data (const QueryQuark &quark) |
void * | steal_data (const QueryQuark &quark) |
Public Member Functions inherited from Glib::ObjectBase | |
ObjectBase (const ObjectBase &)=delete | |
ObjectBase & | operator= (const ObjectBase &)=delete |
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. | |
template<class PropertyType > | |
PropertyType | get_property (const Glib::ustring & property_name) const |
You probably want to use a specific property_*() accessor method instead. | |
sigc::connection | 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. | |
sigc::connection | connect_property_changed (const Glib::ustring & property_name, sigc::slot< void()> &&slot) |
You can use the signal_changed() signal of the property proxy instead. | |
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. | |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
Protected Member Functions | |
OutputStream () | |
bool | set_pending () |
Sets stream to have actions pending. | |
void | clear_pending () |
Clears the pending flag on stream. | |
virtual gssize | write_vfunc (const void *buffer, gsize count, const Glib::RefPtr< Cancellable > &cancellable) |
virtual gssize | splice_vfunc (const Glib::RefPtr< InputStream > &source, const Glib::RefPtr< Cancellable > &cancellable, SpliceFlags flags) |
virtual bool | flush_vfunc (const Glib::RefPtr< Cancellable > &cancellable) |
virtual bool | close_vfunc (const Glib::RefPtr< Cancellable > &cancellable) |
Protected Member Functions inherited from Glib::Object | |
Object () | |
Object (const Glib::ConstructParams &construct_params) | |
Object (GObject *castitem) | |
~Object () noexcept override | |
Protected Member Functions inherited from Glib::ObjectBase | |
ObjectBase () | |
This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor. | |
ObjectBase (const char *custom_type_name) | |
A derived constructor always overrides this choice. | |
ObjectBase (const std::type_info &custom_type_info) | |
This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually. | |
ObjectBase (ObjectBase &&src) noexcept | |
ObjectBase & | operator= (ObjectBase &&src) noexcept |
virtual | ~ObjectBase () noexcept=0 |
void | initialize (GObject *castitem) |
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper) |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gio::OutputStream > | wrap (GOutputStream *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Related Symbols inherited from Glib::Object | |
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false) |
Base class for implementing streaming output.
|
noexcept |
|
overridenoexcept |
|
protected |
|
protected |
Clears the pending flag on stream.
bool Gio::OutputStream::close | ( | ) |
A close() convenience overload.
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.
cancellable | Cancellable object. |
true
on success, false
on failure.Glib::Error |
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.
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.
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.
result | A AsyncResult. |
true
if stream was successfully closed, false
otherwise.Glib::Error |
|
protectedvirtual |
Glib::Error. |
bool Gio::OutputStream::flush | ( | ) |
A flush() convenience overload.
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.
cancellable | Cancellable object. |
true
on success, false
on error.Glib::Error |
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().
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().
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.
result | A GAsyncResult. |
true
if flush operation succeeded, false
otherwise.Glib::Error |
|
protectedvirtual |
Glib::Error. |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C GObject.
|
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.
bool Gio::OutputStream::has_pending | ( | ) | const |
Checks if an output stream has pending actions.
true
if stream has pending actions. bool Gio::OutputStream::is_closed | ( | ) | const |
Checks if an output stream has already been closed.
true
if stream is closed. false
otherwise. bool Gio::OutputStream::is_closing | ( | ) | const |
Checks if an output stream is being closed.
This can be used inside e.g. a flush implementation to see if the flush (or other i/o operation) is called from within the closing operation.
true
if stream is being closed. false
otherwise.
|
noexcept |
|
protected |
Sets stream to have actions pending.
If the pending flag is already set or stream is closed, it will return false
and set error.
true
if pending was previously unset and is now set.Glib::Error |
gssize Gio::OutputStream::splice | ( | const Glib::RefPtr< InputStream > & | source, |
const Glib::RefPtr< Cancellable > & | cancellable, | ||
SpliceFlags | flags = SpliceFlags::NONE |
||
) |
Splices an input stream into an output stream.
source | An InputStream. |
flags | A set of SpliceFlags. |
cancellable | A Cancellable object. ignore. |
gssize Gio::OutputStream::splice | ( | const Glib::RefPtr< InputStream > & | source, |
SpliceFlags | flags = SpliceFlags::NONE |
||
) |
Splices an input stream into an output stream.
source | An InputStream. |
flags | A set of SpliceFlags. ignore. |
void Gio::OutputStream::splice_async | ( | const Glib::RefPtr< InputStream > & | source, |
const SlotAsyncReady & | slot, | ||
const Glib::RefPtr< Cancellable > & | cancellable, | ||
SpliceFlags | flags = SpliceFlags::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().
source | An InputStream. |
slot | Callback slot to call when the request is satisfied. |
cancellable | Cancellable object. |
flags | A set of SpliceFlags. |
io_priority | The io priority of the request. |
void Gio::OutputStream::splice_async | ( | const Glib::RefPtr< InputStream > & | source, |
const SlotAsyncReady & | slot, | ||
SpliceFlags | flags = SpliceFlags::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().
source | An InputStream. |
slot | Callback slot to call when the request is satisfied. |
flags | A set of SpliceFlags. |
io_priority | The io priority of the request. |
gssize Gio::OutputStream::splice_finish | ( | const Glib::RefPtr< AsyncResult > & | result | ) |
Finishes an asynchronous stream splice operation.
result | A AsyncResult. |
Glib::Error |
|
protectedvirtual |
Glib::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.
buffer | The buffer containing the data to write. |
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.
buffer | The buffer containing the data to write. |
cancellable | Cancellable object. |
A write() convenience overload.
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 G_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.
buffer | The buffer containing the data to write. |
count | The number of bytes to write. |
cancellable | Cancellable object. |
Glib::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.
buffer | The buffer containing the data to write. |
bytes_written | Location to store the number of bytes that was written to the stream. |
true
on success, false
if there was an error. 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.
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. |
true
on success, false
if there was an error. A write_all() convenience overload.
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.
As a special exception to the normal conventions for functions that use Error, if this function returns false
(and sets error) then bytes_written will be set to the number of bytes that were successfully written before the error was encountered. This functionality is only available from C. If you need it from another language then you must write your own loop around g_output_stream_write().
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, nullptr to ignore. |
true
on success, false
if there was an error.Glib::Error |
void Gio::OutputStream::write_all_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_all_finish() to get the result of the operation.
This is the asynchronous version of write_all().
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().
Note that no copy of buffer will be made, so it must stay valid until slot is called.
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_all_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.
This is the asynchronous version of write_all().
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().
Note that no copy of buffer will be made, so it must stay valid until slot is called.
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. |
bool Gio::OutputStream::write_all_finish | ( | const Glib::RefPtr< AsyncResult > & | result, |
gsize & | bytes_written | ||
) |
Finishes an asynchronous stream write operation started with g_output_stream_write_all_async().
As a special exception to the normal conventions for functions that use Error, if this function returns false
(and sets error) then bytes_written will be set to the number of bytes that were successfully written before the error was encountered. This functionality is only available from C. If you need it from another language then you must write your own loop around g_output_stream_write_async().
result | A AsyncResult. |
bytes_written | Location to store the number of bytes that was written to the stream. |
true
on success, false
if there was an error.Glib::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().
Note that no copy of buffer will be made, so it must stay valid until slot is called. See write_bytes_async() for a Glib::Bytes version that will automatically hold a reference to the contents (without copying) for the duration of the call.
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().
Note that no copy of buffer will be made, so it must stay valid until slot is called. See write_bytes_async() for a Glib::Bytes version that will automatically hold a reference to the contents (without copying) for the duration of the call.
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 | ) |
A write_bytes() convenience overload.
gssize Gio::OutputStream::write_bytes | ( | const Glib::RefPtr< const Glib::Bytes > & | bytes, |
const Glib::RefPtr< Cancellable > & | cancellable | ||
) |
A wrapper function for g_output_stream_write() which takes a Bytes as input.
This can be more convenient for use by language bindings or in other cases where the refcounted nature of Bytes is helpful over a bare pointer interface.
However, note that this function may still perform partial writes, just like g_output_stream_write(). If that occurs, to continue writing, you will need to create a new Bytes containing just the remaining bytes, using Glib::bytes_new_from_bytes(). Passing the same Bytes instance multiple times potentially can result in duplicated data in the output stream.
bytes | The Bytes to write. |
cancellable | Optional cancellable object. |
Glib::Error |
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().
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. |
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().
bytes | The bytes to |
slot | Callback slot to call when the request is satisfied. |
io_priority | The io priority of the request. |
gssize Gio::OutputStream::write_bytes_finish | ( | const Glib::RefPtr< AsyncResult > & | result | ) |
Finishes a stream write-from-Bytes operation.
result | A AsyncResult. |
Glib::Error |
gssize Gio::OutputStream::write_finish | ( | const Glib::RefPtr< AsyncResult > & | result | ) |
Finishes a stream write operation.
result | A AsyncResult. |
Glib::Error |
|
protectedvirtual |
Glib::Error. |
|
related |
A Glib::wrap() method for this object.
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. |