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