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.SimpleIOStream; 26 27 private import gio.IOStream; 28 private import gio.InputStream; 29 private import gio.OutputStream; 30 private import gio.c.functions; 31 public import gio.c.types; 32 private import glib.ConstructionException; 33 private import gobject.ObjectG; 34 public import gtkc.giotypes; 35 36 37 /** 38 * GSimpleIOStream creates a #GIOStream from an arbitrary #GInputStream and 39 * #GOutputStream. This allows any pair of input and output streams to be used 40 * with #GIOStream methods. 41 * 42 * This is useful when you obtained a #GInputStream and a #GOutputStream 43 * by other means, for instance creating them with platform specific methods as 44 * g_unix_input_stream_new() or g_win32_input_stream_new(), and you want 45 * to take advantage of the methods provided by #GIOStream. 46 * 47 * Since: 2.44 48 */ 49 public class SimpleIOStream : IOStream 50 { 51 /** the main Gtk struct */ 52 protected GSimpleIOStream* gSimpleIOStream; 53 54 /** Get the main Gtk struct */ 55 public GSimpleIOStream* getSimpleIOStreamStruct(bool transferOwnership = false) 56 { 57 if (transferOwnership) 58 ownedRef = false; 59 return gSimpleIOStream; 60 } 61 62 /** the main Gtk struct as a void* */ 63 protected override void* getStruct() 64 { 65 return cast(void*)gSimpleIOStream; 66 } 67 68 protected override void setStruct(GObject* obj) 69 { 70 gSimpleIOStream = cast(GSimpleIOStream*)obj; 71 super.setStruct(obj); 72 } 73 74 /** 75 * Sets our main struct and passes it to the parent class. 76 */ 77 public this (GSimpleIOStream* gSimpleIOStream, bool ownedRef = false) 78 { 79 this.gSimpleIOStream = gSimpleIOStream; 80 super(cast(GIOStream*)gSimpleIOStream, ownedRef); 81 } 82 83 84 /** */ 85 public static GType getType() 86 { 87 return g_simple_io_stream_get_type(); 88 } 89 90 /** 91 * Creates a new #GSimpleIOStream wrapping @input_stream and @output_stream. 92 * See also #GIOStream. 93 * 94 * Params: 95 * inputStream = a #GInputStream. 96 * outputStream = a #GOutputStream. 97 * 98 * Returns: a new #GSimpleIOStream instance. 99 * 100 * Since: 2.44 101 * 102 * Throws: ConstructionException GTK+ fails to create the object. 103 */ 104 public this(InputStream inputStream, OutputStream outputStream) 105 { 106 auto p = g_simple_io_stream_new((inputStream is null) ? null : inputStream.getInputStreamStruct(), (outputStream is null) ? null : outputStream.getOutputStreamStruct()); 107 108 if(p is null) 109 { 110 throw new ConstructionException("null returned by new"); 111 } 112 113 this(cast(GSimpleIOStream*) p, true); 114 } 115 }