logo top
Main Page   Widgets   glibmm Namespaces   Book  

Gio::OutputStream Class Reference

Base class for implementing streaming output. More...

Inheritance diagram for Gio::OutputStream:

Inheritance graph
[legend]
List of all members.

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.
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.
gssize splice (const Glib::RefPtr<InputStream>& source, OutputStreamSpliceFlags flags, const Glib::RefPtr<Cancellable>& cancellable)
 Splices an input stream into an output stream.
bool flush (const Glib::RefPtr<Cancellable>& cancellable)
 Flushed any outstanding buffers in the stream.
bool close (const Glib::RefPtr<Cancellable>& cancellable)
 Closes the stream, releasing resources related to it.
void write_async (const void* buffer, gsize count, int io_priority, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
gssize write_finish (const Glib::RefPtr<AsyncResult>& result)
 Finishes a stream write operation.
void splice_async (const Glib::RefPtr<InputStream>& source, OutputStreamSpliceFlags flags, int io_priority, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
gssize splice_finish (const Glib::RefPtr<AsyncResult>& result)
 Finishes an asynchronous stream splice operation.
void flush_async (int io_priority, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
bool flush_finish (const Glib::RefPtr<AsyncResult>& result)
 Finishes flushing an output stream.
void close_async (int io_priority, const Glib::RefPtr<Cancellable>& cancellable, const SlotAsyncReady& slot)
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 has_pending () const
 Checks if an ouput stream has pending actions.

Related Functions

(Note that these are not member functions.)

Glib::RefPtr<Gio::OutputStreamwrap (GOutputStream* object, bool take_copy=false)
 A Glib::wrap() method for this object.

Detailed Description

Base class for implementing streaming output.

Since glibmm 2.16:


Constructor & Destructor Documentation

virtual Gio::OutputStream::~OutputStream (  )  [virtual]


Member Function Documentation

GOutputStream* Gio::OutputStream::gobj (  )  [inline]

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

Reimplemented in Gio::FileOutputStream.

const GOutputStream* Gio::OutputStream::gobj (  )  const [inline]

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

Reimplemented in Gio::FileOutputStream.

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.

Reimplemented in Gio::FileOutputStream.

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 G::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 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).

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 G_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:
buffer The buffer containing the data to write.
count The number of bytes to write.
cancellable Optional cancellable object.
error Location to store the error occuring, or 0 to ignore.
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 occured.

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 G::Cancellable object, 0 to ignore.
error Location to store the error occuring, or 0 to ignore.
Returns:
true on success, false if there was an error.

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

Splices an input stream into an output stream.

Parameters:
source A G::InputStream.
flags A set of G::OutputStreamSpliceFlags.
cancellable Optional G::Cancellable object, 0 to ignore.
error A G::Error location to store the error occuring, or 0 to ignore.
Returns:
A gssize containig the size of the data spliced.

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.

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 G::IO_ERROR_CANCELLED will be returned.

Parameters:
cancellable Optional cancellable object.
error Location to store the error occuring, or 0 to ignore.
Returns:
true on success, false on error.

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 return G::IO_ERROR_CLOSED. Closing a stream multiple times will not return an error.

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 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 return G::IO_ERROR_CLOSED 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.

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 G::IO_ERROR_CANCELLED will be returned. 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 Optional cancellable object.
error Location to store the error occuring, or 0 to ignore.
Returns:
true on success, false on failure.

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

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

Finishes a stream write operation.

Parameters:
result A G::AsyncResult.
error A G::Error location to store the error occuring, or 0 to ignore.
Returns:
A gssize containing the number of bytes written to the stream.

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

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

Finishes an asynchronous stream splice operation.

Parameters:
result A G::AsyncResult.
error A G::Error location to store the error occuring, or 0 to ignore.
Returns:
A gssize of the number of bytes spliced.

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

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

Finishes flushing an output stream.

Parameters:
result A GAsyncResult.
error A G::Error location to store the error occuring, or 0 to ignore.
Returns:
true if flush operation suceeded, false otherwise.

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

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

Closes an output stream.

Parameters:
result A G::AsyncResult.
error A G::Error location to store the error occuring, or 0 to ignore.
Returns:
true if stream was successfully closed, false otherwise.

bool Gio::OutputStream::is_closed (  )  const

Checks if an output stream has already been closed.

Returns:
true if stream is closed. false otherwise.

bool Gio::OutputStream::has_pending (  )  const

Checks if an ouput stream has pending actions.

Returns:
true if stream has pending actions.


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.


The documentation for this class was generated from the following file:

Generated for glibmm 2.4 by Doxygen 1.5.1 © 1997-2001