summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2012-07-10 11:35:18 +0200
committerMurray Cumming <murrayc@murrayc.com>2012-07-10 11:35:18 +0200
commit0f22741ff39fc7132b332105a6f6cc167f106ca2 (patch)
tree994038faa889adab2b916207d737aa51350ccf79
parent2d760935013ed77eec2b225643536af0d37d175e (diff)
downloadglibmm-0f22741ff39fc7132b332105a6f6cc167f106ca2.tar.gz
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().
-rw-r--r--ChangeLog8
-rw-r--r--gio/src/outputstream.ccg33
-rw-r--r--gio/src/outputstream.hg16
-rw-r--r--tools/m4/convert_glib.m41
4 files changed, 58 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index dd6a4b8f..b332ca6e 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 25e545c8..e0c9e381 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 13cffbfd..ec3c9403 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 70c9d2a1..580ba6bc 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)')