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 change21 // find conversion definition on APILookup.txt22 // implement new conversion functionalities on the wrap.utils pakage23 24 25 modulegio.MemoryInputStream;
26 27 privateimportgio.InputStream;
28 privateimportgio.PollableInputStreamIF;
29 privateimportgio.PollableInputStreamT;
30 privateimportgio.SeekableIF;
31 privateimportgio.SeekableT;
32 privateimportgio.c.functions;
33 publicimportgio.c.types;
34 privateimportglib.Bytes;
35 privateimportglib.ConstructionException;
36 privateimportgobject.ObjectG;
37 38 39 /**
40 * #GMemoryInputStream is a class for using arbitrary
41 * memory chunks as input for GIO streaming input operations.
42 *
43 * As of GLib 2.34, #GMemoryInputStream implements
44 * #GPollableInputStream.
45 */46 publicclassMemoryInputStream : InputStream, PollableInputStreamIF, SeekableIF47 {
48 /** the main Gtk struct */49 protectedGMemoryInputStream* gMemoryInputStream;
50 51 /** Get the main Gtk struct */52 publicGMemoryInputStream* getMemoryInputStreamStruct(booltransferOwnership = false)
53 {
54 if (transferOwnership)
55 ownedRef = false;
56 returngMemoryInputStream;
57 }
58 59 /** the main Gtk struct as a void* */60 protectedoverridevoid* getStruct()
61 {
62 returncast(void*)gMemoryInputStream;
63 }
64 65 /**
66 * Sets our main struct and passes it to the parent class.
67 */68 publicthis (GMemoryInputStream* gMemoryInputStream, boolownedRef = false)
69 {
70 this.gMemoryInputStream = gMemoryInputStream;
71 super(cast(GInputStream*)gMemoryInputStream, ownedRef);
72 }
73 74 // add the PollableInputStream capabilities75 mixinPollableInputStreamT!(GMemoryInputStream);
76 77 // add the Seekable capabilities78 mixinSeekableT!(GMemoryInputStream);
79 80 81 /** */82 publicstaticGTypegetType()
83 {
84 returng_memory_input_stream_get_type();
85 }
86 87 /**
88 * Creates a new empty #GMemoryInputStream.
89 *
90 * Returns: a new #GInputStream
91 *
92 * Throws: ConstructionException GTK+ fails to create the object.
93 */94 publicthis()
95 {
96 auto__p = g_memory_input_stream_new();
97 98 if(__pisnull)
99 {
100 thrownewConstructionException("null returned by new");
101 }
102 103 this(cast(GMemoryInputStream*) __p, true);
104 }
105 106 /**
107 * Creates a new #GMemoryInputStream with data from the given @bytes.
108 *
109 * Params:
110 * bytes = a #GBytes
111 *
112 * Returns: new #GInputStream read from @bytes
113 *
114 * Since: 2.34
115 *
116 * Throws: ConstructionException GTK+ fails to create the object.
117 */118 publicthis(Bytesbytes)
119 {
120 auto__p = g_memory_input_stream_new_from_bytes((bytesisnull) ? null : bytes.getBytesStruct());
121 122 if(__pisnull)
123 {
124 thrownewConstructionException("null returned by new_from_bytes");
125 }
126 127 this(cast(GMemoryInputStream*) __p, true);
128 }
129 130 /**
131 * Creates a new #GMemoryInputStream with data in memory of a given size.
132 *
133 * Params:
134 * data = input data
135 * destroy = function that is called to free @data, or %NULL
136 *
137 * Returns: new #GInputStream read from @data of @len bytes.
138 *
139 * Throws: ConstructionException GTK+ fails to create the object.
140 */141 publicthis(ubyte[] data, GDestroyNotifydestroy)
142 {
143 auto__p = g_memory_input_stream_new_from_data(data.ptr, cast(ptrdiff_t)data.length, destroy);
144 145 if(__pisnull)
146 {
147 thrownewConstructionException("null returned by new_from_data");
148 }
149 150 this(cast(GMemoryInputStream*) __p, true);
151 }
152 153 /**
154 * Appends @bytes to data that can be read from the input stream.
155 *
156 * Params:
157 * bytes = input data
158 *
159 * Since: 2.34
160 */161 publicvoidaddBytes(Bytesbytes)
162 {
163 g_memory_input_stream_add_bytes(gMemoryInputStream, (bytesisnull) ? null : bytes.getBytesStruct());
164 }
165 166 /**
167 * Appends @data to data that can be read from the input stream
168 *
169 * Params:
170 * data = input data
171 * destroy = function that is called to free @data, or %NULL
172 */173 publicvoidaddData(ubyte[] data, GDestroyNotifydestroy)
174 {
175 g_memory_input_stream_add_data(gMemoryInputStream, data.ptr, cast(ptrdiff_t)data.length, destroy);
176 }
177 }