1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD 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
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GSeekable.html
27  * outPack = gio
28  * outFile = SeekableT
29  * strct   = GSeekable
30  * realStrct=
31  * ctorStrct=
32  * clss    = SeekableT
33  * interf  = SeekableIF
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * 	- TStruct
38  * extend  = 
39  * implements:
40  * prefixes:
41  * 	- g_seekable_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.ErrorG
48  * 	- glib.GException
49  * 	- gio.Cancellable
50  * structWrap:
51  * 	- GCancellable* -> Cancellable
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module gio.SeekableT;
58 
59 public  import gtkc.giotypes;
60 
61 public import gtkc.gio;
62 public import glib.ConstructionException;
63 public import gobject.ObjectG;
64 
65 public import glib.ErrorG;
66 public import glib.GException;
67 public import gio.Cancellable;
68 
69 
70 
71 /**
72  * GSeekable is implemented by streams (implementations of
73  * GInputStream or GOutputStream) that support seeking.
74  */
75 public template SeekableT(TStruct)
76 {
77 	
78 	/** the main Gtk struct */
79 	protected GSeekable* gSeekable;
80 	
81 	
82 	/** Get the main Gtk struct */
83 	public GSeekable* getSeekableTStruct()
84 	{
85 		return cast(GSeekable*)getStruct();
86 	}
87 	
88 	
89 	/**
90 	 */
91 	
92 	/**
93 	 * Tells the current position within the stream.
94 	 * Returns: the offset from the beginning of the buffer.
95 	 */
96 	public long tell()
97 	{
98 		// goffset g_seekable_tell (GSeekable *seekable);
99 		return g_seekable_tell(getSeekableTStruct());
100 	}
101 	
102 	/**
103 	 * Tests if the stream supports the GSeekableIface.
104 	 * Returns: TRUE if seekable can be seeked. FALSE otherwise.
105 	 */
106 	public int canSeek()
107 	{
108 		// gboolean g_seekable_can_seek (GSeekable *seekable);
109 		return g_seekable_can_seek(getSeekableTStruct());
110 	}
111 	
112 	/**
113 	 * Seeks in the stream by the given offset, modified by type.
114 	 * If cancellable is not NULL, then the operation can be cancelled by
115 	 * triggering the cancellable object from another thread. If the operation
116 	 * was cancelled, the error G_IO_ERROR_CANCELLED will be returned.
117 	 * Params:
118 	 * offset = a goffset.
119 	 * type = a GSeekType.
120 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
121 	 * Returns: TRUE if successful. If an error has occurred, this function will return FALSE and set error appropriately if present.
122 	 * Throws: GException on failure.
123 	 */
124 	public int seek(long offset, GSeekType type, Cancellable cancellable)
125 	{
126 		// gboolean g_seekable_seek (GSeekable *seekable,  goffset offset,  GSeekType type,  GCancellable *cancellable,  GError **error);
127 		GError* err = null;
128 		
129 		auto p = g_seekable_seek(getSeekableTStruct(), offset, type, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
130 		
131 		if (err !is null)
132 		{
133 			throw new GException( new ErrorG(err) );
134 		}
135 		
136 		return p;
137 	}
138 	
139 	/**
140 	 * Tests if the stream can be truncated.
141 	 * Returns: TRUE if the stream can be truncated, FALSE otherwise.
142 	 */
143 	public int canTruncate()
144 	{
145 		// gboolean g_seekable_can_truncate (GSeekable *seekable);
146 		return g_seekable_can_truncate(getSeekableTStruct());
147 	}
148 	
149 	/**
150 	 * Truncates a stream with a given offset.
151 	 * If cancellable is not NULL, then the operation can be cancelled by
152 	 * triggering the cancellable object from another thread. If the operation
153 	 * was cancelled, the error G_IO_ERROR_CANCELLED will be returned. If an
154 	 * operation was partially finished when the operation was cancelled the
155 	 * partial result will be returned, without an error.
156 	 * Virtual: truncate_fn
157 	 * Params:
158 	 * offset = a goffset.
159 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
160 	 * Returns: TRUE if successful. If an error has occurred, this function will return FALSE and set error appropriately if present.
161 	 * Throws: GException on failure.
162 	 */
163 	public int truncate(long offset, Cancellable cancellable)
164 	{
165 		// gboolean g_seekable_truncate (GSeekable *seekable,  goffset offset,  GCancellable *cancellable,  GError **error);
166 		GError* err = null;
167 		
168 		auto p = g_seekable_truncate(getSeekableTStruct(), offset, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
169 		
170 		if (err !is null)
171 		{
172 			throw new GException( new ErrorG(err) );
173 		}
174 		
175 		return p;
176 	}
177 }