1 // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 /* Copyright (C) 2007 The gtkmm Development Team
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <giomm/cancellable.h>
21 #include <glibmm/interface.h>
24 _PINCLUDE(glibmm/private/interface_p.h)
26 #ifndef DOXYGEN_SHOULD_SKIP_THIS
27 typedef struct _GSeekableIface GSeekableIface;
28 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
34 /** Stream seeking interface.
35 * Seekable is implemented by streams (implementations of InputStream or OutputStream) that support seeking.
36 * To find the position of a stream, use tell(). To find
37 * out if a stream supports seeking, use can_seek(). To position a
38 * stream, use seek(). To find out if a stream supports
39 * truncating, use can_truncate(). To truncate a stream, use
46 class Seekable : public Glib::Interface
48 _CLASS_INTERFACE(Seekable, GSeekable, G_SEEKABLE, GSeekableIface)
51 _WRAP_METHOD(goffset tell() const, g_seekable_tell)
52 _WRAP_METHOD(bool can_seek() const, g_seekable_can_seek)
54 _WRAP_METHOD(bool seek(goffset offset, Glib::SeekType type, const Glib::RefPtr<Cancellable>& cancellable), g_seekable_seek, errthrow)
56 //TODO: Document the exception: http://bugzilla.gnome.org/show_bug.cgi?id=509990
57 /** Seeks in the stream by the given @a offset, modified by @a type .
59 * @param offset A #goffset.
60 * @param type A Glib::SeekType.
61 * @return <tt>true</tt> if successful. If an error
62 * has occurred, this function will return <tt>false</tt>.
64 #ifdef GLIBMM_EXCEPTIONS_ENABLED
65 bool seek(goffset offset, Glib::SeekType type);
67 bool seek(goffset offset, Glib::SeekType type, std::auto_ptr<Glib::Error>& error);
68 #endif //GLIBMM_EXCEPTIONS_ENABLED
70 _WRAP_METHOD(bool can_truncate() const, g_seekable_can_truncate)
72 _WRAP_METHOD(bool truncate(goffset offset, const Glib::RefPtr<Cancellable>& cancellable), g_seekable_truncate, errthrow)
74 //TODO: Document the exception: http://bugzilla.gnome.org/show_bug.cgi?id=509990
75 /** Truncates a stream with a given #offset.
77 * @param offset A #goffset.
78 * @return <tt>true</tt> if successful. If an error
79 * has occured, this function will return <tt>false</tt>.
81 #ifdef GLIBMM_EXCEPTIONS_ENABLED
82 bool truncate(goffset offset);
84 bool truncate(goffset offset, std::auto_ptr<Glib::Error>& error);
85 #endif //GLIBMM_EXCEPTIONS_ENABLED
87 //_WRAP_VFUNC(goffset tell() const, tell)
88 //_WRAP_VFUNC(goffset can_seek() const, can_seek)
89 //_WRAP_VFUNC(goffset seek(goffset offset, Glib::SeekType type, const Glib::RefPtr<Cancellable>& cancellable, GError** error), seek)
90 //_WRAP_VFUNC(goffset can_truncate() const, can_truncate)
92 //Renamed to truncate() - we don't know why it's called truncate_fn in C.
93 //_WRAP_VFUNC(goffset truncate(goffset offset, const Glib::RefPtr<Cancellable>& cancellable, GError** error), truncate_fn)
95 //There are no properties or signals.