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 66 public import glib.ErrorG; 67 public import glib.GException; 68 public import gio.Cancellable; 69 70 71 72 73 /** 74 * Description 75 * GSeekable is implemented by streams (implementations of 76 * GInputStream or GOutputStream) that support seeking. 77 */ 78 public template SeekableT(TStruct) 79 { 80 81 /** the main Gtk struct */ 82 protected GSeekable* gSeekable; 83 84 85 public GSeekable* getSeekableTStruct() 86 { 87 return cast(GSeekable*)getStruct(); 88 } 89 90 91 /** 92 */ 93 94 /** 95 * Tells the current position within the stream. 96 * Returns: the offset from the beginning of the buffer. 97 */ 98 public long tell() 99 { 100 // goffset g_seekable_tell (GSeekable *seekable); 101 return g_seekable_tell(getSeekableTStruct()); 102 } 103 104 /** 105 * Tests if the stream supports the GSeekableIface. 106 * Returns: TRUE if seekable can be seeked. FALSE otherwise. 107 */ 108 public int canSeek() 109 { 110 // gboolean g_seekable_can_seek (GSeekable *seekable); 111 return g_seekable_can_seek(getSeekableTStruct()); 112 } 113 114 /** 115 * Seeks in the stream by the given offset, modified by type. 116 * If cancellable is not NULL, then the operation can be cancelled by 117 * triggering the cancellable object from another thread. If the operation 118 * was cancelled, the error G_IO_ERROR_CANCELLED will be returned. 119 * Params: 120 * offset = a goffset. 121 * type = a GSeekType. 122 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 123 * Returns: TRUE if successful. If an error has occurred, this function will return FALSE and set error appropriately if present. 124 * Throws: GException on failure. 125 */ 126 public int seek(long offset, GSeekType type, Cancellable cancellable) 127 { 128 // gboolean g_seekable_seek (GSeekable *seekable, goffset offset, GSeekType type, GCancellable *cancellable, GError **error); 129 GError* err = null; 130 131 auto p = g_seekable_seek(getSeekableTStruct(), offset, type, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 132 133 if (err !is null) 134 { 135 throw new GException( new ErrorG(err) ); 136 } 137 138 return p; 139 } 140 141 /** 142 * Tests if the stream can be truncated. 143 * Returns: TRUE if the stream can be truncated, FALSE otherwise. 144 */ 145 public int canTruncate() 146 { 147 // gboolean g_seekable_can_truncate (GSeekable *seekable); 148 return g_seekable_can_truncate(getSeekableTStruct()); 149 } 150 151 /** 152 * Truncates a stream with a given offset. 153 * If cancellable is not NULL, then the operation can be cancelled by 154 * triggering the cancellable object from another thread. If the operation 155 * was cancelled, the error G_IO_ERROR_CANCELLED will be returned. If an 156 * operation was partially finished when the operation was cancelled the 157 * partial result will be returned, without an error. 158 * Virtual: truncate_fn 159 * Params: 160 * offset = a goffset. 161 * cancellable = optional GCancellable object, NULL to ignore. [allow-none] 162 * Returns: TRUE if successful. If an error has occurred, this function will return FALSE and set error appropriately if present. 163 * Throws: GException on failure. 164 */ 165 public int truncate(long offset, Cancellable cancellable) 166 { 167 // gboolean g_seekable_truncate (GSeekable *seekable, goffset offset, GCancellable *cancellable, GError **error); 168 GError* err = null; 169 170 auto p = g_seekable_truncate(getSeekableTStruct(), offset, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err); 171 172 if (err !is null) 173 { 174 throw new GException( new ErrorG(err) ); 175 } 176 177 return p; 178 } 179 }