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

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

Initial release

File size: 5.0 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.BufferedOutputStream;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.FilterOutputStream;
26private import gio.OutputStream;
27private import gio.SeekableIF;
28private import gio.SeekableT;
29private import glib.ConstructionException;
30private import gobject.ObjectG;
31
32
33/**
34 * Buffered output stream implements #GFilterOutputStream and provides
35 * for buffered writes.
36 *
37 * By default, #GBufferedOutputStream's buffer size is set at 4 kilobytes.
38 *
39 * To create a buffered output stream, use g_buffered_output_stream_new(),
40 * or g_buffered_output_stream_new_sized() to specify the buffer's size
41 * at construction.
42 *
43 * To get the size of a buffer within a buffered input stream, use
44 * g_buffered_output_stream_get_buffer_size(). To change the size of a
45 * buffered output stream's buffer, use
46 * g_buffered_output_stream_set_buffer_size(). Note that the buffer's
47 * size cannot be reduced below the size of the data within the buffer.
48 */
49public class BufferedOutputStream : FilterOutputStream, SeekableIF
50{
51        /** the main Gtk struct */
52        protected GBufferedOutputStream* gBufferedOutputStream;
53
54        /** Get the main Gtk struct */
55        public GBufferedOutputStream* getBufferedOutputStreamStruct()
56        {
57                return gBufferedOutputStream;
58        }
59
60        /** the main Gtk struct as a void* */
61        protected override void* getStruct()
62        {
63                return cast(void*)gBufferedOutputStream;
64        }
65
66        protected override void setStruct(GObject* obj)
67        {
68                gBufferedOutputStream = cast(GBufferedOutputStream*)obj;
69                super.setStruct(obj);
70        }
71
72        /**
73         * Sets our main struct and passes it to the parent class.
74         */
75        public this (GBufferedOutputStream* gBufferedOutputStream, bool ownedRef = false)
76        {
77                this.gBufferedOutputStream = gBufferedOutputStream;
78                super(cast(GFilterOutputStream*)gBufferedOutputStream, ownedRef);
79        }
80
81        // add the Seekable capabilities
82        mixin SeekableT!(GBufferedOutputStream);
83
84
85        /** */
86        public static GType getType()
87        {
88                return g_buffered_output_stream_get_type();
89        }
90
91        /**
92         * Creates a new buffered output stream for a base stream.
93         *
94         * Params:
95         *     baseStream = a #GOutputStream.
96         *
97         * Returns: a #GOutputStream for the given @base_stream.
98         *
99         * Throws: ConstructionException GTK+ fails to create the object.
100         */
101        public this(OutputStream baseStream)
102        {
103                auto p = g_buffered_output_stream_new((baseStream is null) ? null : baseStream.getOutputStreamStruct());
104               
105                if(p is null)
106                {
107                        throw new ConstructionException("null returned by new");
108                }
109               
110                this(cast(GBufferedOutputStream*) p, true);
111        }
112
113        /**
114         * Creates a new buffered output stream with a given buffer size.
115         *
116         * Params:
117         *     baseStream = a #GOutputStream.
118         *     size = a #gsize.
119         *
120         * Returns: a #GOutputStream with an internal buffer set to @size.
121         *
122         * Throws: ConstructionException GTK+ fails to create the object.
123         */
124        public this(OutputStream baseStream, size_t size)
125        {
126                auto p = g_buffered_output_stream_new_sized((baseStream is null) ? null : baseStream.getOutputStreamStruct(), size);
127               
128                if(p is null)
129                {
130                        throw new ConstructionException("null returned by new_sized");
131                }
132               
133                this(cast(GBufferedOutputStream*) p, true);
134        }
135
136        /**
137         * Checks if the buffer automatically grows as data is added.
138         *
139         * Returns: %TRUE if the @stream's buffer automatically grows,
140         *     %FALSE otherwise.
141         */
142        public bool getAutoGrow()
143        {
144                return g_buffered_output_stream_get_auto_grow(gBufferedOutputStream) != 0;
145        }
146
147        /**
148         * Gets the size of the buffer in the @stream.
149         *
150         * Returns: the current size of the buffer.
151         */
152        public size_t getBufferSize()
153        {
154                return g_buffered_output_stream_get_buffer_size(gBufferedOutputStream);
155        }
156
157        /**
158         * Sets whether or not the @stream's buffer should automatically grow.
159         * If @auto_grow is true, then each write will just make the buffer
160         * larger, and you must manually flush the buffer to actually write out
161         * the data to the underlying stream.
162         *
163         * Params:
164         *     autoGrow = a #gboolean.
165         */
166        public void setAutoGrow(bool autoGrow)
167        {
168                g_buffered_output_stream_set_auto_grow(gBufferedOutputStream, autoGrow);
169        }
170
171        /**
172         * Sets the size of the internal buffer to @size.
173         *
174         * Params:
175         *     size = a #gsize.
176         */
177        public void setBufferSize(size_t size)
178        {
179                g_buffered_output_stream_set_buffer_size(gBufferedOutputStream, size);
180        }
181}
Note: See TracBrowser for help on using the repository browser.