[glibmm] wrap Gio::FileIOStream
- From: Jonathon Jongsma <jjongsma src gnome org>
- To: svn-commits-list gnome org
- Subject: [glibmm] wrap Gio::FileIOStream
- Date: Mon, 18 May 2009 23:35:05 -0400 (EDT)
commit 5947dd5014524ae2e1d95e86825c4fbf35c55e87
Author: Jonathon Jongsma <jonathon quotidian org>
Date: Mon May 18 22:31:39 2009 -0500
wrap Gio::FileIOStream
---
ChangeLog | 8 ++
gio/src/Makefile_list_of_hg.am_fragment | 2 +-
gio/src/fileiostream.ccg | 97 ++++++++++++++++++++++++++
gio/src/fileiostream.hg | 116 +++++++++++++++++++++++++++++++
4 files changed, 222 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5cc03fc..5e7dbbb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2009-05-18 Jonathon Jongsma <jonathon quotidian org>
+ Wrap new Gio::FileIOStream class
+
+ * gio/src/Makefile_list_of_hg.am_fragment:
+ * gio/src/fileiostream.ccg: Copied from gio/src/fileinputstream.ccg.
+ * gio/src/fileiostream.hg: Copied from gio/src/fileinputstream.hg.
+
+2009-05-18 Jonathon Jongsma <jonathon quotidian org>
+
Wrap the new Gio::IOStream class
* gio/src/Makefile_list_of_hg.am_fragment:
diff --git a/gio/src/Makefile_list_of_hg.am_fragment b/gio/src/Makefile_list_of_hg.am_fragment
index 8638971..23a6f93 100644
--- a/gio/src/Makefile_list_of_hg.am_fragment
+++ b/gio/src/Makefile_list_of_hg.am_fragment
@@ -6,7 +6,7 @@
files_posix_hg = unixinputstream.hg unixoutputstream.hg desktopappinfo.hg
files_win32_hg =
files_general_hg = appinfo.hg asyncresult.hg cancellable.hg drive.hg emblem.hg emblemedicon.hg error.hg file.hg fileattributeinfo.hg \
- fileattributeinfolist.hg fileenumerator.hg fileicon.hg fileinfo.hg fileinputstream.hg fileoutputstream.hg \
+ fileattributeinfolist.hg fileenumerator.hg fileicon.hg fileinfo.hg fileinputstream.hg fileiostream.hg fileoutputstream.hg \
filemonitor.hg filterinputstream.hg filteroutputstream.hg filenamecompleter.hg \
icon.hg inputstream.hg iostream.hg loadableicon.hg memoryoutputstream.hg mount.hg mountoperation.hg outputstream.hg \
seekable.hg volume.hg volumemonitor.hg bufferedinputstream.hg \
diff --git a/gio/src/fileiostream.ccg b/gio/src/fileiostream.ccg
new file mode 100644
index 0000000..2c017ea
--- /dev/null
+++ b/gio/src/fileiostream.ccg
@@ -0,0 +1,97 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* Copyright (C) 2007 The gtkmm 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 "slot_async.h"
+#include <glibmm/exceptionhandler.h>
+
+namespace Gio
+{
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<FileInfo> FileIOStream::query_info(const Glib::RefPtr<Cancellable>& cancellable, const std::string& attributes)
+#else
+Glib::RefPtr<FileInfo> FileIOStream::query_info(const Glib::RefPtr<Cancellable>& cancellable, const std::string& attributes, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+ GError* gerror = 0;
+ Glib::RefPtr<FileInfo> retvalue = Glib::wrap(g_file_io_stream_query_info(gobj(), g_strdup((attributes).c_str()), const_cast<GCancellable*>(Glib::unwrap(cancellable)), &(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;
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<FileInfo> FileIOStream::query_info(const std::string& attributes)
+#else
+Glib::RefPtr<FileInfo> FileIOStream::query_info(const std::string& attributes, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+ GError* gerror = 0;
+ Glib::RefPtr<FileInfo> retvalue = Glib::wrap(g_file_io_stream_query_info(gobj(), g_strdup((attributes).c_str()), 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
+FileIOStream::query_info_async(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, const std::string& attributes, 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_file_io_stream_query_info_async(gobj(),
+ const_cast<char*>(attributes.c_str()),
+ io_priority,
+ cancellable->gobj(),
+ &SignalProxy_async_callback,
+ slot_copy);
+}
+
+void
+FileIOStream::query_info_async(const SlotAsyncReady& slot, const std::string& attributes, 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_file_io_stream_query_info_async(gobj(),
+ const_cast<char*>(attributes.c_str()),
+ io_priority,
+ NULL,
+ &SignalProxy_async_callback,
+ slot_copy);
+}
+
+} // namespace Gio
diff --git a/gio/src/fileiostream.hg b/gio/src/fileiostream.hg
new file mode 100644
index 0000000..3567516
--- /dev/null
+++ b/gio/src/fileiostream.hg
@@ -0,0 +1,116 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* Copyright (C) 2007 The gtkmm 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 <giomm/fileinfo.h>
+#include <giomm/iostream.h>
+#include <giomm/seekable.h>
+
+_DEFS(giomm,gio)
+_PINCLUDE(giomm/private/iostream_p.h)
+
+namespace Gio
+{
+
+/** FileIOStream provides input streams that take their content from a file.
+ *
+ * FileInputStream implements Seekable, which allows the input stream to jump to arbitrary positions in the file,
+ * provided the file system of the file allows it.
+ * Use the methods of the Seekable base class for seeking and positioning.
+ *
+ * @ingroup Streams
+ *
+ * @newin2p22
+ */
+class FileIOStream
+: public Gio::IOStream,
+ public Gio::Seekable
+{
+ _CLASS_GOBJECT(FileIOStream, GFileIOStream, G_FILE_IO_STREAM, Gio::IOStream, GIOStream)
+ _IMPLEMENTS_INTERFACE(Seekable)
+
+public:
+
+ /** Queries a file input stream the given @a attributes. This function blocks
+ * while querying the stream. For the asynchronous (non-blocking) version
+ * of this function, see query_info_async(). While the
+ * stream is blocked, the stream will set the pending flag internally, and
+ * any other operations on the stream will throw a Gio::Error with PENDING.
+ *
+ * @param attributes A file attribute query string.
+ * @param cancellable A Cancellable object.
+ * @return A FileInfo, or an empty RefPtr on error.
+ */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ Glib::RefPtr<FileInfo> query_info(const Glib::RefPtr<Cancellable>& cancellable, const std::string& attributes = "*");
+#else
+ Glib::RefPtr<FileInfo> query_info(const Glib::RefPtr<Cancellable>& cancellable, const std::string& attributes, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ /** Queries a file input stream the given @a attributes. This function blocks
+ * while querying the stream. For the asynchronous (non-blocking) version
+ * of this function, see query_info_async(). While the
+ * stream is blocked, the stream will set the pending flag internally, and
+ * any other operations on the stream will throw a Gio::Error with PENDING.
+ *
+ * @param attributes A file attribute query string.
+ * @return A FileInfo, or an empty RefPtr on error.
+ */
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ Glib::RefPtr<FileInfo> query_info(const std::string& attributes = "*");
+#else
+ Glib::RefPtr<FileInfo> query_info(const std::string& attributes, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+ _IGNORE(g_file_input_stream_query_info)
+
+
+ /** Queries the stream information asynchronously. For the synchronous version of this function, see query_info().
+ *
+ * The operation can be cancelled by triggering the cancellable object from another thread. If the operation was cancelled,
+ * a Gio::Error with CANCELLED will be thrown.
+ *
+ * When the operation is finished, @a slot will be called. You can then call query_info_finish() to get the result of the operation.
+ *
+ * @param slot A callback slot which will be called when the request is satisfied.
+ * @param cancellable A Cancellable object which can be used to cancel the operation.
+ * @param attributes A file attribute query string.
+ * @param io_priority The I/O priority of the request.
+ */
+ void query_info_async(const SlotAsyncReady& slot, const Glib::RefPtr<Cancellable>& cancellable, const std::string& attributes = "*", int io_priority = Glib::PRIORITY_DEFAULT);
+
+ /** Queries the stream information asynchronously. For the synchronous version of this function, see query_info().
+ *
+ * When the operation is finished, @a slot will be called. You can then call query_info_finish() to get the result of the operation.
+ *
+ * @param slot A callback slot which will be called when the request is satisfied.
+ * @param attributes A file attribute query string.
+ * @param io_priority The I/O priority of the request.
+ */
+ void query_info_async(const SlotAsyncReady& slot, const std::string& attributes = "*", int io_priority = Glib::PRIORITY_DEFAULT);
+
+ _IGNORE(g_file_io_stream_query_info_async)
+
+ _WRAP_METHOD(Glib::RefPtr<FileInfo> query_info_finish(const Glib::RefPtr<AsyncResult>& result),
+ g_file_io_stream_query_info_finish,
+ errthrow)
+ _WRAP_METHOD(std::string get_etag() const, g_file_io_stream_get_etag)
+
+};
+
+} // namespace Gio
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]