diff options
author | Murray Cumming <murrayc@murrayc.com> | 2012-07-10 11:35:18 +0200 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2012-07-10 11:35:18 +0200 |
commit | 0f22741ff39fc7132b332105a6f6cc167f106ca2 (patch) | |
tree | 994038faa889adab2b916207d737aa51350ccf79 | |
parent | 2d760935013ed77eec2b225643536af0d37d175e (diff) | |
download | glibmm-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-- | ChangeLog | 8 | ||||
-rw-r--r-- | gio/src/outputstream.ccg | 33 | ||||
-rw-r--r-- | gio/src/outputstream.hg | 16 | ||||
-rw-r--r-- | tools/m4/convert_glib.m4 | 1 |
4 files changed, 58 insertions, 0 deletions
@@ -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)') |