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  = GMemoryInputStream.html
27  * outPack = gio
28  * outFile = MemoryInputStream
29  * strct   = GMemoryInputStream
30  * realStrct=
31  * ctorStrct=GInputStream
32  * clss    = MemoryInputStream
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- SeekableIF
40  * prefixes:
41  * 	- g_memory_input_stream_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Bytes
48  * 	- gio.SeekableT
49  * 	- gio.SeekableIF
50  * structWrap:
51  * 	- GBytes* -> Bytes
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module gio.MemoryInputStream;
58 
59 public  import gtkc.giotypes;
60 
61 private import gtkc.gio;
62 private import glib.ConstructionException;
63 private import gobject.ObjectG;
64 
65 private import glib.Bytes;
66 private import gio.SeekableT;
67 private import gio.SeekableIF;
68 
69 
70 private import gio.InputStream;
71 
72 /**
73  * GMemoryInputStream is a class for using arbitrary
74  * memory chunks as input for GIO streaming input operations.
75  *
76  * As of GLib 2.34, GMemoryInputStream implements
77  * GPollableInputStream.
78  */
79 public class MemoryInputStream : InputStream, SeekableIF
80 {
81 	
82 	/** the main Gtk struct */
83 	protected GMemoryInputStream* gMemoryInputStream;
84 	
85 	
86 	/** Get the main Gtk struct */
87 	public GMemoryInputStream* getMemoryInputStreamStruct()
88 	{
89 		return gMemoryInputStream;
90 	}
91 	
92 	
93 	/** the main Gtk struct as a void* */
94 	protected override void* getStruct()
95 	{
96 		return cast(void*)gMemoryInputStream;
97 	}
98 	
99 	/**
100 	 * Sets our main struct and passes it to the parent class
101 	 */
102 	public this (GMemoryInputStream* gMemoryInputStream)
103 	{
104 		super(cast(GInputStream*)gMemoryInputStream);
105 		this.gMemoryInputStream = gMemoryInputStream;
106 	}
107 	
108 	protected override void setStruct(GObject* obj)
109 	{
110 		super.setStruct(obj);
111 		gMemoryInputStream = cast(GMemoryInputStream*)obj;
112 	}
113 	
114 	// add the Seekable capabilities
115 	mixin SeekableT!(GMemoryInputStream);
116 	
117 	/**
118 	 */
119 	
120 	/**
121 	 * Creates a new empty GMemoryInputStream.
122 	 * Throws: ConstructionException GTK+ fails to create the object.
123 	 */
124 	public this ()
125 	{
126 		// GInputStream * g_memory_input_stream_new (void);
127 		auto p = g_memory_input_stream_new();
128 		if(p is null)
129 		{
130 			throw new ConstructionException("null returned by g_memory_input_stream_new()");
131 		}
132 		this(cast(GMemoryInputStream*) p);
133 	}
134 	
135 	/**
136 	 * Creates a new GMemoryInputStream with data in memory of a given size.
137 	 * Params:
138 	 * data = input data. [array length=len][element-type guint8][transfer full]
139 	 * len = length of the data, may be -1 if data is a nul-terminated string
140 	 * destroy = function that is called to free data, or NULL. [allow-none]
141 	 * Throws: ConstructionException GTK+ fails to create the object.
142 	 */
143 	public this (void* data, gssize len, GDestroyNotify destroy)
144 	{
145 		// GInputStream * g_memory_input_stream_new_from_data (const void *data,  gssize len,  GDestroyNotify destroy);
146 		auto p = g_memory_input_stream_new_from_data(data, len, destroy);
147 		if(p is null)
148 		{
149 			throw new ConstructionException("null returned by g_memory_input_stream_new_from_data(data, len, destroy)");
150 		}
151 		this(cast(GMemoryInputStream*) p);
152 	}
153 	
154 	/**
155 	 * Creates a new GMemoryInputStream with data from the given bytes.
156 	 * Since 2.34
157 	 * Params:
158 	 * bytes = a GBytes
159 	 * Throws: ConstructionException GTK+ fails to create the object.
160 	 */
161 	public this (Bytes bytes)
162 	{
163 		// GInputStream * g_memory_input_stream_new_from_bytes  (GBytes *bytes);
164 		auto p = g_memory_input_stream_new_from_bytes((bytes is null) ? null : bytes.getBytesStruct());
165 		if(p is null)
166 		{
167 			throw new ConstructionException("null returned by g_memory_input_stream_new_from_bytes((bytes is null) ? null : bytes.getBytesStruct())");
168 		}
169 		this(cast(GMemoryInputStream*) p);
170 	}
171 	
172 	/**
173 	 * Appends data to data that can be read from the input stream
174 	 * Params:
175 	 * data = input data. [array length=len][element-type guint8][transfer full]
176 	 * len = length of the data, may be -1 if data is a nul-terminated string
177 	 * destroy = function that is called to free data, or NULL. [allow-none]
178 	 */
179 	public void addData(void* data, gssize len, GDestroyNotify destroy)
180 	{
181 		// void g_memory_input_stream_add_data (GMemoryInputStream *stream,  const void *data,  gssize len,  GDestroyNotify destroy);
182 		g_memory_input_stream_add_data(gMemoryInputStream, data, len, destroy);
183 	}
184 	
185 	/**
186 	 * Appends bytes to data that can be read from the input stream.
187 	 * Since 2.34
188 	 * Params:
189 	 * bytes = input data
190 	 */
191 	public void addBytes(Bytes bytes)
192 	{
193 		// void g_memory_input_stream_add_bytes (GMemoryInputStream *stream,  GBytes *bytes);
194 		g_memory_input_stream_add_bytes(gMemoryInputStream, (bytes is null) ? null : bytes.getBytesStruct());
195 	}
196 }