[glibmm] Gio::OutputStream: Add write_bytes().
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Gio::OutputStream: Add write_bytes().
- Date: Tue, 10 Jul 2012 09:35:26 +0000 (UTC)
commit 0f22741ff39fc7132b332105a6f6cc167f106ca2
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Jul 10 11:35:18 2012 +0200
Gio::OutputStream: Add write_bytes().
* tools/m4/convert_glib.m4:
* gio/src/outputstream.[hg|ccg]: Add write_bytes(), write_bytes_async(),
and write_bytes_finish().
ChangeLog | 8 ++++++++
gio/src/outputstream.ccg | 33 +++++++++++++++++++++++++++++++++
gio/src/outputstream.hg | 16 ++++++++++++++++
tools/m4/convert_glib.m4 | 1 +
4 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index dd6a4b8..b332ca6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2012-07-10 Murray Cumming <murrayc murrayc com>
+ Gio::OutputStream: Add write_bytes().
+
+ * tools/m4/convert_glib.m4:
+ * gio/src/outputstream.[hg|ccg]: Add write_bytes(), write_bytes_async(),
+ and write_bytes_finish().
+
+2012-07-10 Murray Cumming <murrayc murrayc com>
+
Added Glib::Bytes and Gio::InputStream::read_bytes().
* glib/src/bytes.[hg|ccg]:
diff --git a/gio/src/outputstream.ccg b/gio/src/outputstream.ccg
index 25e545c..e0c9e38 100644
--- a/gio/src/outputstream.ccg
+++ b/gio/src/outputstream.ccg
@@ -213,6 +213,39 @@ bool OutputStream::write_all(const std::string& buffer, gsize& bytes_written)
return retvalue;
}
+
+void
+OutputStream::write_bytes_async(const Glib::RefPtr<const Glib::Bytes>& bytes, const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, 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_output_stream_write_bytes_async(gobj(),
+ const_cast<GBytes*>(Glib::unwrap(bytes)),
+ io_priority,
+ Glib::unwrap(cancellable),
+ &SignalProxy_async_callback,
+ slot_copy);
+}
+
+void
+OutputStream::write_bytes_async(const Glib::RefPtr<const Glib::Bytes>& bytes, const SlotAsyncReady& slot, 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_output_stream_write_bytes_async(gobj(),
+ const_cast<GBytes*>(Glib::unwrap(bytes)),
+ io_priority,
+ 0,
+ &SignalProxy_async_callback,
+ slot_copy);
+}
+
gssize OutputStream::splice(const Glib::RefPtr<InputStream>& source, const Glib::RefPtr<Cancellable>& cancellable, OutputStreamSpliceFlags flags)
{
GError* gerror = 0;
diff --git a/gio/src/outputstream.hg b/gio/src/outputstream.hg
index 13cffbf..ec3c940 100644
--- a/gio/src/outputstream.hg
+++ b/gio/src/outputstream.hg
@@ -165,6 +165,22 @@ public:
*/
bool write_all(const std::string& buffer, gsize& bytes_written);
+ _WRAP_METHOD(gssize write_bytes(const Glib::RefPtr<const Glib::Bytes>& bytes, const Glib::RefPtr<Cancellable>& cancellable), g_output_stream_write_bytes, errthrow)
+
+ //TODO: Documentation.
+ /**
+ * @newin{2,34}
+ */
+ 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);
+
+ /**
+ * @newin{2,34}
+ */
+ void write_bytes_async(const Glib::RefPtr<const Glib::Bytes>& bytes, const SlotAsyncReady& slot, int io_priority = Glib::PRIORITY_DEFAULT);
+ _IGNORE(g_output_stream_write_bytes_async)
+
+ _WRAP_METHOD(gssize write_bytes_finish(const Glib::RefPtr<AsyncResult>& result), g_output_stream_write_bytes_finish, errthrow)
+
/** Splices an input stream into an output stream.
*
* @param source An InputStream.
diff --git a/tools/m4/convert_glib.m4 b/tools/m4/convert_glib.m4
index 70c9d2a..580ba6b 100644
--- a/tools/m4/convert_glib.m4
+++ b/tools/m4/convert_glib.m4
@@ -125,6 +125,7 @@ _CONVERSION(`OptionGroup&',`GOptionGroup*',`($3).gobj()')
dnl Bytes
_CONVERSION(`GBytes*',`Glib::RefPtr<Glib::Bytes>',`Glib::wrap($3)')
_CONVERSION(`GBytes*',`Glib::RefPtr<const Glib::Bytes>',`Glib::wrap($3)')
+_CONVERSION(`const Glib::RefPtr<const Glib::Bytes>&',`GBytes*',__CONVERT_CONST_REFPTR_TO_P_SUN(Glib::Bytes)))
dnl Regex
_CONVERSION(`GRegex*',`Glib::RefPtr<Regex>',`Glib::wrap($3)')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]