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