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 
66 private import glib.Bytes;
67 private import gio.SeekableT;
68 private import gio.SeekableIF;
69 
70 
71 
72 private import gio.InputStream;
73 
74 /**
75  * GMemoryInputStream is a class for using arbitrary
76  * memory chunks as input for GIO streaming input operations.
77  *
78  * As of GLib 2.34, GMemoryInputStream implements
79  * GPollableInputStream.
80  */
81 public class MemoryInputStream : InputStream, SeekableIF
82 {
83 	
84 	/** the main Gtk struct */
85 	protected GMemoryInputStream* gMemoryInputStream;
86 	
87 	
88 	public GMemoryInputStream* getMemoryInputStreamStruct()
89 	{
90 		return gMemoryInputStream;
91 	}
92 	
93 	
94 	/** the main Gtk struct as a void* */
95 	protected override void* getStruct()
96 	{
97 		return cast(void*)gMemoryInputStream;
98 	}
99 	
100 	/**
101 	 * Sets our main struct and passes it to the parent class
102 	 */
103 	public this (GMemoryInputStream* gMemoryInputStream)
104 	{
105 		super(cast(GInputStream*)gMemoryInputStream);
106 		this.gMemoryInputStream = gMemoryInputStream;
107 	}
108 	
109 	protected override void setStruct(GObject* obj)
110 	{
111 		super.setStruct(obj);
112 		gMemoryInputStream = cast(GMemoryInputStream*)obj;
113 	}
114 	
115 	// add the Seekable capabilities
116 	mixin SeekableT!(GMemoryInputStream);
117 	
118 	/**
119 	 */
120 	
121 	/**
122 	 * Creates a new empty GMemoryInputStream.
123 	 * Throws: ConstructionException GTK+ fails to create the object.
124 	 */
125 	public this ()
126 	{
127 		// GInputStream * g_memory_input_stream_new (void);
128 		auto p = g_memory_input_stream_new();
129 		if(p is null)
130 		{
131 			throw new ConstructionException("null returned by g_memory_input_stream_new()");
132 		}
133 		this(cast(GMemoryInputStream*) p);
134 	}
135 	
136 	/**
137 	 * Creates a new GMemoryInputStream with data in memory of a given size.
138 	 * Params:
139 	 * data = input data. [array length=len][element-type guint8][transfer full]
140 	 * len = length of the data, may be -1 if data is a nul-terminated string
141 	 * destroy = function that is called to free data, or NULL. [allow-none]
142 	 * Throws: ConstructionException GTK+ fails to create the object.
143 	 */
144 	public this (void* data, gssize len, GDestroyNotify destroy)
145 	{
146 		// GInputStream * g_memory_input_stream_new_from_data (const void *data,  gssize len,  GDestroyNotify destroy);
147 		auto p = g_memory_input_stream_new_from_data(data, len, destroy);
148 		if(p is null)
149 		{
150 			throw new ConstructionException("null returned by g_memory_input_stream_new_from_data(data, len, destroy)");
151 		}
152 		this(cast(GMemoryInputStream*) p);
153 	}
154 	
155 	/**
156 	 * Creates a new GMemoryInputStream with data from the given bytes.
157 	 * Since 2.34
158 	 * Params:
159 	 * bytes = a GBytes
160 	 * Throws: ConstructionException GTK+ fails to create the object.
161 	 */
162 	public this (Bytes bytes)
163 	{
164 		// GInputStream * g_memory_input_stream_new_from_bytes  (GBytes *bytes);
165 		auto p = g_memory_input_stream_new_from_bytes((bytes is null) ? null : bytes.getBytesStruct());
166 		if(p is null)
167 		{
168 			throw new ConstructionException("null returned by g_memory_input_stream_new_from_bytes((bytes is null) ? null : bytes.getBytesStruct())");
169 		}
170 		this(cast(GMemoryInputStream*) p);
171 	}
172 	
173 	/**
174 	 * Appends data to data that can be read from the input stream
175 	 * Params:
176 	 * data = input data. [array length=len][element-type guint8][transfer full]
177 	 * len = length of the data, may be -1 if data is a nul-terminated string
178 	 * destroy = function that is called to free data, or NULL. [allow-none]
179 	 */
180 	public void addData(void* data, gssize len, GDestroyNotify destroy)
181 	{
182 		// void g_memory_input_stream_add_data (GMemoryInputStream *stream,  const void *data,  gssize len,  GDestroyNotify destroy);
183 		g_memory_input_stream_add_data(gMemoryInputStream, data, len, destroy);
184 	}
185 	
186 	/**
187 	 * Appends bytes to data that can be read from the input stream.
188 	 * Since 2.34
189 	 * Params:
190 	 * bytes = input data
191 	 */
192 	public void addBytes(Bytes bytes)
193 	{
194 		// void g_memory_input_stream_add_bytes (GMemoryInputStream *stream,  GBytes *bytes);
195 		g_memory_input_stream_add_bytes(gMemoryInputStream, (bytes is null) ? null : bytes.getBytesStruct());
196 	}
197 }