summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Alburquerque <jaalburqu@svn.gnome.org>2012-10-03 16:10:27 -0400
committerJosé Alburquerque <jaalburqu@svn.gnome.org>2012-10-03 19:10:13 -0400
commit1b22023d3061d0f6c3d032fa23ea14bcaf8a4eeb (patch)
treebbc50794de1fabbc470c73adb96a3126e7d933d4
parent59fff691f84b728c499ffa09264702d79e04e307 (diff)
downloadglibmm-1b22023d3061d0f6c3d032fa23ea14bcaf8a4eeb.tar.gz
IOStream: Add the splice_async() and splice_finish() methods.
* gio/src/iostream.{ccg,hg}: Add cancellable and non-cancellable versions of the splice_async() method wrapping the corresponding C function. Add the splice_finish() method wrapping the corresponding C function. Also add the class docs.
-rw-r--r--ChangeLog9
-rw-r--r--gio/src/iostream.ccg28
-rw-r--r--gio/src/iostream.hg57
3 files changed, 93 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 7788666c..272797e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-10-03 José Alburquerque <jaalburquerque@gmail.com>
+
+ IOStream: Add the splice_async() and splice_finish() methods.
+
+ * gio/src/iostream.{ccg,hg}: Add cancellable and non-cancellable
+ versions of the splice_async() method wrapping the corresponding C
+ function. Add the splice_finish() method wrapping the corresponding C
+ function. Also add the class docs.
+
2012-10-02 José Alburquerque <jaalburquerque@gmail.com>
FileInfo, FileAttributeMatcher: Wrap some unwrapped functions.
diff --git a/gio/src/iostream.ccg b/gio/src/iostream.ccg
index 6dc2b5af..c1aae465 100644
--- a/gio/src/iostream.ccg
+++ b/gio/src/iostream.ccg
@@ -55,5 +55,33 @@ IOStream::close_async(const SlotAsyncReady& slot, int io_priority)
slot_copy);
}
+void
+IOStream::splice_async(const Glib::RefPtr<IOStream>& stream2,
+ const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable,
+ IOStreamSpliceFlags flags, int io_priority)
+{
+ // Create a copy of the slot.
+ // A pointer to it will be passed through the callback's data parameter
+ // and deleted in the callback.
+ SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+ g_io_stream_splice_async(gobj(), Glib::unwrap(stream2),
+ static_cast<GIOStreamSpliceFlags>(flags), io_priority,
+ Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy);
+}
+
+void
+IOStream::splice_async(const Glib::RefPtr<IOStream>& stream2,
+ const SlotAsyncReady& slot, IOStreamSpliceFlags flags, int io_priority)
+{
+ // Create a copy of the slot.
+ // A pointer to it will be passed through the callback's data parameter
+ // and deleted in the callback.
+ SlotAsyncReady* slot_copy = new SlotAsyncReady(slot);
+
+ g_io_stream_splice_async(gobj(), Glib::unwrap(stream2),
+ static_cast<GIOStreamSpliceFlags>(flags), io_priority, 0,
+ &SignalProxy_async_callback, slot_copy);
+}
} // namespace Gio
diff --git a/gio/src/iostream.hg b/gio/src/iostream.hg
index 083ea900..35f49221 100644
--- a/gio/src/iostream.hg
+++ b/gio/src/iostream.hg
@@ -30,7 +30,32 @@ _PINCLUDE(glibmm/private/object_p.h)
namespace Gio
{
-/**
+_WRAP_ENUM(IOStreamSpliceFlags, GIOStreamSpliceFlags, NO_GTYPE)
+
+/** IOStream - Base class for implementing read/write streams.
+ * IOStream represents an object that has both read and write streams.
+ * Generally the two streams acts as separate input and output streams, but
+ * they share some common resources and state. For instance, for seekable
+ * streams they may use the same position in both streams.
+ *
+ * Examples of IOStream objects are SocketConnection which represents a two-way
+ * network connection, and FileIOStream which represent a file handle opened in
+ * read-write mode.
+ *
+ * To do the actual reading and writing you need to get the substreams with
+ * get_input_stream() and get_output_stream().
+ *
+ * The IOStream object owns the input and the output streams, not the other way
+ * around, so keeping the substreams alive will not keep the IOStream object
+ * alive. If the IOStream object is freed it will be closed, thus closing the
+ * substream, so even if the substreams stay alive they will always just return
+ * a Gio::IO_ERROR_CLOSED for all operations.
+ *
+ * To close a stream use close() which will close the common stream object and
+ * also the individual substreams. You can also close the substreams
+ * themselves. In most cases this only marks the substream as closed, so
+ * further I/O on it fails. However, some streams may support "half-closed"
+ * states where one direction of the stream is actually shut down.
*
* @ingroup Streams
*
@@ -41,6 +66,36 @@ class IOStream : public Glib::Object
_CLASS_GOBJECT(IOStream, GIOStream, G_IO_STREAM, Glib::Object, GObject)
public:
+
+ /** Asyncronously splice the output stream to the input stream of @a
+ * stream2, and splice the output stream of @a stream2 to the input stream of
+ * this stream.
+ *
+ * When the operation is finished @a slot will be called. You can then call
+ * splice_finish() to get the result of the operation.
+ *
+ * @param stream2 The second IOStream.
+ * @param slot A SlotAsyncReady slot.
+ * @param cancellable A Cancellable object.
+ * @param flags A set of IOStreamSpliceFlags.
+ * @param io_priority The io priority of the request.
+ *
+ * @newin{2,34}
+ */
+ void splice_async(const Glib::RefPtr<IOStream>& stream2,
+ const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable,
+ IOStreamSpliceFlags flags = Gio::IO_STREAM_SPLICE_NONE,
+ int io_priority = Glib::PRIORITY_DEFAULT);
+ _IGNORE(g_io_stream_splice_async)
+
+ /// A non-cancellable version of splice_async().
+ void splice_async(const Glib::RefPtr<IOStream>& stream2,
+ const SlotAsyncReady& slot,
+ IOStreamSpliceFlags flags = Gio::IO_STREAM_SPLICE_NONE,
+ int io_priority = Glib::PRIORITY_DEFAULT);
+
+ _WRAP_METHOD(static bool splice_finish(const Glib::RefPtr<AsyncResult>& result), g_io_stream_splice_finish, errthrow)
+
_WRAP_METHOD(Glib::RefPtr<InputStream> get_input_stream(), g_io_stream_get_input_stream, refreturn)
_WRAP_METHOD(Glib::RefPtr<OutputStream> get_output_stream(), g_io_stream_get_output_stream, refreturn)
_WRAP_METHOD(bool close(const Glib::RefPtr<Cancellable>& cancellable{?}), g_io_stream_close, errthrow)