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 module gio.DataOutputStream; 26 27 private import gio.Cancellable; 28 private import gio.FilterOutputStream; 29 private import gio.OutputStream; 30 private import gio.SeekableIF; 31 private import gio.SeekableT; 32 private import gio.c.functions; 33 public import gio.c.types; 34 private import glib.ConstructionException; 35 private import glib.ErrorG; 36 private import glib.GException; 37 private import glib.Str; 38 private import gobject.ObjectG; 39 public import gtkc.giotypes; 40 41 42 /** 43 * Data output stream implements #GOutputStream and includes functions for 44 * writing data directly to an output stream. 45 */ 46 public class DataOutputStream : FilterOutputStream, SeekableIF 47 { 48 /** the main Gtk struct */ 49 protected GDataOutputStream* gDataOutputStream; 50 51 /** Get the main Gtk struct */ 52 public GDataOutputStream* getDataOutputStreamStruct(bool transferOwnership = false) 53 { 54 if (transferOwnership) 55 ownedRef = false; 56 return gDataOutputStream; 57 } 58 59 /** the main Gtk struct as a void* */ 60 protected override void* getStruct() 61 { 62 return cast(void*)gDataOutputStream; 63 } 64 65 protected override void setStruct(GObject* obj) 66 { 67 gDataOutputStream = cast(GDataOutputStream*)obj; 68 super.setStruct(obj); 69 } 70 71 /** 72 * Sets our main struct and passes it to the parent class. 73 */ 74 public this (GDataOutputStream* gDataOutputStream, bool ownedRef = false) 75 { 76 this.gDataOutputStream = gDataOutputStream; 77 super(cast(GFilterOutputStream*)gDataOutputStream, ownedRef); 78 } 79 80 // add the Seekable capabilities 81 mixin SeekableT!(GDataOutputStream); 82 83 84 /** */ 85 public static GType getType() 86 { 87 return g_data_output_stream_get_type(); 88 } 89 90 /** 91 * Creates a new data output stream for @base_stream. 92 * 93 * Params: 94 * baseStream = a #GOutputStream. 95 * 96 * Returns: #GDataOutputStream. 97 * 98 * Throws: ConstructionException GTK+ fails to create the object. 99 */ 100 public this(OutputStream baseStream) 101 { 102 auto p = g_data_output_stream_new((baseStream is null) ? null : baseStream.getOutputStreamStruct()); 103 104 if(p is null) 105 { 106 throw new ConstructionException("null returned by new"); 107 } 108 109 this(cast(GDataOutputStream*) p, true); 110 } 111 112 /** 113 * Gets the byte order for the stream. 114 * 115 * Returns: the #GDataStreamByteOrder for the @stream. 116 */ 117 public GDataStreamByteOrder getByteOrder() 118 { 119 return g_data_output_stream_get_byte_order(gDataOutputStream); 120 } 121 122 /** 123 * Puts a byte into the output stream. 124 * 125 * Params: 126 * data = a #guchar. 127 * cancellable = optional #GCancellable object, %NULL to ignore. 128 * 129 * Returns: %TRUE if @data was successfully added to the @stream. 130 * 131 * Throws: GException on failure. 132 */ 133 public bool putByte(char data, Cancellable cancellable) 134 { 135 GError* err = null; 136 137 auto p = g_data_output_stream_put_byte(gDataOutputStream, data, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 138 139 if (err !is null) 140 { 141 throw new GException( new ErrorG(err) ); 142 } 143 144 return p; 145 } 146 147 /** 148 * Puts a signed 16-bit integer into the output stream. 149 * 150 * Params: 151 * data = a #gint16. 152 * cancellable = optional #GCancellable object, %NULL to ignore. 153 * 154 * Returns: %TRUE if @data was successfully added to the @stream. 155 * 156 * Throws: GException on failure. 157 */ 158 public bool putInt16(short data, Cancellable cancellable) 159 { 160 GError* err = null; 161 162 auto p = g_data_output_stream_put_int16(gDataOutputStream, data, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 163 164 if (err !is null) 165 { 166 throw new GException( new ErrorG(err) ); 167 } 168 169 return p; 170 } 171 172 /** 173 * Puts a signed 32-bit integer into the output stream. 174 * 175 * Params: 176 * data = a #gint32. 177 * cancellable = optional #GCancellable object, %NULL to ignore. 178 * 179 * Returns: %TRUE if @data was successfully added to the @stream. 180 * 181 * Throws: GException on failure. 182 */ 183 public bool putInt32(int data, Cancellable cancellable) 184 { 185 GError* err = null; 186 187 auto p = g_data_output_stream_put_int32(gDataOutputStream, data, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 188 189 if (err !is null) 190 { 191 throw new GException( new ErrorG(err) ); 192 } 193 194 return p; 195 } 196 197 /** 198 * Puts a signed 64-bit integer into the stream. 199 * 200 * Params: 201 * data = a #gint64. 202 * cancellable = optional #GCancellable object, %NULL to ignore. 203 * 204 * Returns: %TRUE if @data was successfully added to the @stream. 205 * 206 * Throws: GException on failure. 207 */ 208 public bool putInt64(long data, Cancellable cancellable) 209 { 210 GError* err = null; 211 212 auto p = g_data_output_stream_put_int64(gDataOutputStream, data, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 213 214 if (err !is null) 215 { 216 throw new GException( new ErrorG(err) ); 217 } 218 219 return p; 220 } 221 222 /** 223 * Puts a string into the output stream. 224 * 225 * Params: 226 * str = a string. 227 * cancellable = optional #GCancellable object, %NULL to ignore. 228 * 229 * Returns: %TRUE if @string was successfully added to the @stream. 230 * 231 * Throws: GException on failure. 232 */ 233 public bool putString(string str, Cancellable cancellable) 234 { 235 GError* err = null; 236 237 auto p = g_data_output_stream_put_string(gDataOutputStream, Str.toStringz(str), (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 238 239 if (err !is null) 240 { 241 throw new GException( new ErrorG(err) ); 242 } 243 244 return p; 245 } 246 247 /** 248 * Puts an unsigned 16-bit integer into the output stream. 249 * 250 * Params: 251 * data = a #guint16. 252 * cancellable = optional #GCancellable object, %NULL to ignore. 253 * 254 * Returns: %TRUE if @data was successfully added to the @stream. 255 * 256 * Throws: GException on failure. 257 */ 258 public bool putUint16(ushort data, Cancellable cancellable) 259 { 260 GError* err = null; 261 262 auto p = g_data_output_stream_put_uint16(gDataOutputStream, data, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 263 264 if (err !is null) 265 { 266 throw new GException( new ErrorG(err) ); 267 } 268 269 return p; 270 } 271 272 /** 273 * Puts an unsigned 32-bit integer into the stream. 274 * 275 * Params: 276 * data = a #guint32. 277 * cancellable = optional #GCancellable object, %NULL to ignore. 278 * 279 * Returns: %TRUE if @data was successfully added to the @stream. 280 * 281 * Throws: GException on failure. 282 */ 283 public bool putUint32(uint data, Cancellable cancellable) 284 { 285 GError* err = null; 286 287 auto p = g_data_output_stream_put_uint32(gDataOutputStream, data, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 288 289 if (err !is null) 290 { 291 throw new GException( new ErrorG(err) ); 292 } 293 294 return p; 295 } 296 297 /** 298 * Puts an unsigned 64-bit integer into the stream. 299 * 300 * Params: 301 * data = a #guint64. 302 * cancellable = optional #GCancellable object, %NULL to ignore. 303 * 304 * Returns: %TRUE if @data was successfully added to the @stream. 305 * 306 * Throws: GException on failure. 307 */ 308 public bool putUint64(ulong data, Cancellable cancellable) 309 { 310 GError* err = null; 311 312 auto p = g_data_output_stream_put_uint64(gDataOutputStream, data, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err) != 0; 313 314 if (err !is null) 315 { 316 throw new GException( new ErrorG(err) ); 317 } 318 319 return p; 320 } 321 322 /** 323 * Sets the byte order of the data output stream to @order. 324 * 325 * Params: 326 * order = a %GDataStreamByteOrder. 327 */ 328 public void setByteOrder(GDataStreamByteOrder order) 329 { 330 g_data_output_stream_set_byte_order(gDataOutputStream, order); 331 } 332 }