source: appstream-generator/build/girepo/gio/MemoryInputStream.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 4.6 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.MemoryInputStream;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.InputStream;
26private import gio.PollableInputStreamIF;
27private import gio.PollableInputStreamT;
28private import gio.SeekableIF;
29private import gio.SeekableT;
30private import glib.Bytes;
31private import glib.ConstructionException;
32private import gobject.ObjectG;
33
34
35/**
36 * #GMemoryInputStream is a class for using arbitrary
37 * memory chunks as input for GIO streaming input operations.
38 *
39 * As of GLib 2.34, #GMemoryInputStream implements
40 * #GPollableInputStream.
41 */
42public class MemoryInputStream : InputStream, PollableInputStreamIF, SeekableIF
43{
44        /** the main Gtk struct */
45        protected GMemoryInputStream* gMemoryInputStream;
46
47        /** Get the main Gtk struct */
48        public GMemoryInputStream* getMemoryInputStreamStruct()
49        {
50                return gMemoryInputStream;
51        }
52
53        /** the main Gtk struct as a void* */
54        protected override void* getStruct()
55        {
56                return cast(void*)gMemoryInputStream;
57        }
58
59        protected override void setStruct(GObject* obj)
60        {
61                gMemoryInputStream = cast(GMemoryInputStream*)obj;
62                super.setStruct(obj);
63        }
64
65        /**
66         * Sets our main struct and passes it to the parent class.
67         */
68        public this (GMemoryInputStream* gMemoryInputStream, bool ownedRef = false)
69        {
70                this.gMemoryInputStream = gMemoryInputStream;
71                super(cast(GInputStream*)gMemoryInputStream, ownedRef);
72        }
73
74        // add the PollableInputStream capabilities
75        mixin PollableInputStreamT!(GMemoryInputStream);
76
77        // add the Seekable capabilities
78        mixin SeekableT!(GMemoryInputStream);
79
80
81        /** */
82        public static GType getType()
83        {
84                return g_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        public this()
95        {
96                auto p = g_memory_input_stream_new();
97               
98                if(p is null)
99                {
100                        throw new ConstructionException("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        public this(Bytes bytes)
119        {
120                auto p = g_memory_input_stream_new_from_bytes((bytes is null) ? null : bytes.getBytesStruct());
121               
122                if(p is null)
123                {
124                        throw new ConstructionException("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         *     len = length of the data, may be -1 if @data is a nul-terminated string
136         *     destroy = function that is called to free @data, or %NULL
137         *
138         * Returns: new #GInputStream read from @data of @len bytes.
139         *
140         * Throws: ConstructionException GTK+ fails to create the object.
141         */
142        public this(ubyte[] data, GDestroyNotify destroy)
143        {
144                auto p = g_memory_input_stream_new_from_data(data.ptr, cast(ptrdiff_t)data.length, destroy);
145               
146                if(p is null)
147                {
148                        throw new ConstructionException("null returned by new_from_data");
149                }
150               
151                this(cast(GMemoryInputStream*) p, true);
152        }
153
154        /**
155         * Appends @bytes to data that can be read from the input stream.
156         *
157         * Params:
158         *     bytes = input data
159         *
160         * Since: 2.34
161         */
162        public void addBytes(Bytes bytes)
163        {
164                g_memory_input_stream_add_bytes(gMemoryInputStream, (bytes is null) ? null : bytes.getBytesStruct());
165        }
166
167        /**
168         * Appends @data to data that can be read from the input stream
169         *
170         * Params:
171         *     data = input data
172         *     len = length of the data, may be -1 if @data is a nul-terminated string
173         *     destroy = function that is called to free @data, or %NULL
174         */
175        public void addData(ubyte[] data, GDestroyNotify destroy)
176        {
177                g_memory_input_stream_add_data(gMemoryInputStream, data.ptr, cast(ptrdiff_t)data.length, destroy);
178        }
179}
Note: See TracBrowser for help on using the repository browser.