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.UnixInputStream; 26 27 private import gio.FileDescriptorBasedIF; 28 private import gio.FileDescriptorBasedT; 29 private import gio.InputStream; 30 private import gio.PollableInputStreamIF; 31 private import gio.PollableInputStreamT; 32 private import glib.ConstructionException; 33 private import gobject.ObjectG; 34 private import gtkc.gio; 35 public import gtkc.giotypes; 36 37 38 /** 39 * #GUnixInputStream implements #GInputStream for reading from a UNIX 40 * file descriptor, including asynchronous operations. (If the file 41 * descriptor refers to a socket or pipe, this will use poll() to do 42 * asynchronous I/O. If it refers to a regular file, it will fall back 43 * to doing asynchronous I/O in another thread.) 44 * 45 * Note that `<gio/gunixinputstream.h>` belongs to the UNIX-specific GIO 46 * interfaces, thus you have to use the `gio-unix-2.0.pc` pkg-config 47 * file when using it. 48 */ 49 public class UnixInputStream : InputStream, FileDescriptorBasedIF, PollableInputStreamIF 50 { 51 /** the main Gtk struct */ 52 protected GUnixInputStream* gUnixInputStream; 53 54 /** Get the main Gtk struct */ 55 public GUnixInputStream* getUnixInputStreamStruct(bool transferOwnership = false) 56 { 57 if (transferOwnership) 58 ownedRef = false; 59 return gUnixInputStream; 60 } 61 62 /** the main Gtk struct as a void* */ 63 protected override void* getStruct() 64 { 65 return cast(void*)gUnixInputStream; 66 } 67 68 protected override void setStruct(GObject* obj) 69 { 70 gUnixInputStream = cast(GUnixInputStream*)obj; 71 super.setStruct(obj); 72 } 73 74 /** 75 * Sets our main struct and passes it to the parent class. 76 */ 77 public this (GUnixInputStream* gUnixInputStream, bool ownedRef = false) 78 { 79 this.gUnixInputStream = gUnixInputStream; 80 super(cast(GInputStream*)gUnixInputStream, ownedRef); 81 } 82 83 // add the FileDescriptorBased capabilities 84 mixin FileDescriptorBasedT!(GUnixInputStream); 85 86 // add the PollableInputStream capabilities 87 mixin PollableInputStreamT!(GUnixInputStream); 88 89 90 /** */ 91 public static GType getType() 92 { 93 return g_unix_input_stream_get_type(); 94 } 95 96 /** 97 * Creates a new #GUnixInputStream for the given @fd. 98 * 99 * If @close_fd is %TRUE, the file descriptor will be closed 100 * when the stream is closed. 101 * 102 * Params: 103 * fd = a UNIX file descriptor 104 * closeFd = %TRUE to close the file descriptor when done 105 * 106 * Returns: a new #GUnixInputStream 107 * 108 * Throws: ConstructionException GTK+ fails to create the object. 109 */ 110 public this(int fd, bool closeFd) 111 { 112 auto p = g_unix_input_stream_new(fd, closeFd); 113 114 if(p is null) 115 { 116 throw new ConstructionException("null returned by new"); 117 } 118 119 this(cast(GUnixInputStream*) p, true); 120 } 121 122 /** 123 * Returns whether the file descriptor of @stream will be 124 * closed when the stream is closed. 125 * 126 * Returns: %TRUE if the file descriptor is closed when done 127 * 128 * Since: 2.20 129 */ 130 public bool getCloseFd() 131 { 132 return g_unix_input_stream_get_close_fd(gUnixInputStream) != 0; 133 } 134 135 /** 136 * Return the UNIX file descriptor that the stream reads from. 137 * 138 * Returns: The file descriptor of @stream 139 * 140 * Since: 2.20 141 */ 142 public int getFd() 143 { 144 return g_unix_input_stream_get_fd(gUnixInputStream); 145 } 146 147 /** 148 * Sets whether the file descriptor of @stream shall be closed 149 * when the stream is closed. 150 * 151 * Params: 152 * closeFd = %TRUE to close the file descriptor when done 153 * 154 * Since: 2.20 155 */ 156 public void setCloseFd(bool closeFd) 157 { 158 g_unix_input_stream_set_close_fd(gUnixInputStream, closeFd); 159 } 160 }