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