Fix crash on startup if an LV2 plugin has a bad .ttl file.
[ardour.git] / libs / glibmm2 / gio / src / seekable.hg
1 // -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
3 /* Copyright (C) 2007 The gtkmm Development Team
4  *
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.
9  *
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.
14  *
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.
18  */
19
20 #include <giomm/cancellable.h>
21 #include <glibmm/interface.h>
22
23 _DEFS(giomm,gio)
24 _PINCLUDE(glibmm/private/interface_p.h)
25
26 #ifndef DOXYGEN_SHOULD_SKIP_THIS
27 typedef struct _GSeekableIface GSeekableIface;
28 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
29
30
31 namespace Gio
32 {
33
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 
40  * truncate().
41  *
42  * @ingroup Streams
43  *
44  * @newin2p16
45  */
46 class Seekable : public Glib::Interface
47 {
48   _CLASS_INTERFACE(Seekable, GSeekable, G_SEEKABLE, GSeekableIface)
49
50 public:
51   _WRAP_METHOD(goffset tell() const, g_seekable_tell)
52   _WRAP_METHOD(bool can_seek() const, g_seekable_can_seek)
53
54   _WRAP_METHOD(bool seek(goffset offset, Glib::SeekType type, const Glib::RefPtr<Cancellable>& cancellable), g_seekable_seek, errthrow)
55
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 .
58    * 
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>.
63    */
64 #ifdef GLIBMM_EXCEPTIONS_ENABLED
65   bool seek(goffset offset, Glib::SeekType type);
66 #else
67   bool seek(goffset offset, Glib::SeekType type, std::auto_ptr<Glib::Error>& error);
68 #endif //GLIBMM_EXCEPTIONS_ENABLED
69
70   _WRAP_METHOD(bool can_truncate() const, g_seekable_can_truncate)
71
72   _WRAP_METHOD(bool truncate(goffset offset, const Glib::RefPtr<Cancellable>& cancellable), g_seekable_truncate, errthrow)
73
74   //TODO: Document the exception: http://bugzilla.gnome.org/show_bug.cgi?id=509990
75   /** Truncates a stream with a given #offset. 
76    * 
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>.
80    */
81 #ifdef GLIBMM_EXCEPTIONS_ENABLED
82   bool truncate(goffset offset);
83 #else
84   bool truncate(goffset offset, std::auto_ptr<Glib::Error>& error);
85 #endif //GLIBMM_EXCEPTIONS_ENABLED
86
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)
91
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)
94
95   //There are no properties or signals.
96 };
97
98 } // namespace Gio
99