diff options
author | Jonathon Jongsma <jonathon@quotidian.org> | 2009-05-18 22:16:24 -0500 |
---|---|---|
committer | Jonathon Jongsma <jonathon@quotidian.org> | 2009-05-18 22:16:24 -0500 |
commit | d9fdab38ce4e0bc6fe634ed0f10588b2f6a62c1e (patch) | |
tree | 81c509acf58b382bc6ed98d5f322f8760fdc7afd /gio/src/iostream.ccg | |
parent | 8935f5eab38123b2e774d9d6be6046095a716ec4 (diff) | |
download | glibmm-d9fdab38ce4e0bc6fe634ed0f10588b2f6a62c1e.tar.gz |
wrap Gio::IOStream
Diffstat (limited to 'gio/src/iostream.ccg')
-rw-r--r-- | gio/src/iostream.ccg | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/gio/src/iostream.ccg b/gio/src/iostream.ccg new file mode 100644 index 00000000..e86d6e7b --- /dev/null +++ b/gio/src/iostream.ccg @@ -0,0 +1,80 @@ +// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*- + +/* Copyright (C) 2007 The giomm Development Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <gio/gio.h> +#include <giomm/asyncresult.h> +#include "slot_async.h" + +namespace Gio +{ + + + +#ifdef GLIBMM_EXCEPTIONS_ENABLED +bool IOStream::close() +#else +bool IOStream::close(std::auto_ptr<Glib::Error>& error) +#endif //GLIBMM_EXCEPTIONS_ENABLED +{ + GError* gerror = 0; + bool retvalue = g_io_stream_close(gobj(), NULL, &(gerror)); +#ifdef GLIBMM_EXCEPTIONS_ENABLED + if(gerror) + ::Glib::Error::throw_exception(gerror); +#else + if(gerror) + error = ::Glib::Error::throw_exception(gerror); +#endif //GLIBMM_EXCEPTIONS_ENABLED + + return retvalue; +} + + +void +IOStream::close_async(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_io_stream_close_async(gobj(), + io_priority, + cancellable->gobj(), + &SignalProxy_async_callback, + slot_copy); +} + +void +IOStream::close_async(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_io_stream_close_async(gobj(), + io_priority, + NULL, + &SignalProxy_async_callback, + slot_copy); +} + + +} // namespace Gio |