1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2006-2007 Red Hat, Inc.
5 * SPDX-License-Identifier: LGPL-2.1-or-later
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 * Author: Alexander Larsson <alexl@redhat.com>
23 #ifndef __G_OUTPUT_STREAM_H__
24 #define __G_OUTPUT_STREAM_H__
26 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
27 #error "Only <gio/gio.h> can be included directly."
30 #include <gio/giotypes.h>
34 #define G_TYPE_OUTPUT_STREAM (g_output_stream_get_type ())
35 #define G_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_OUTPUT_STREAM, GOutputStream))
36 #define G_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_OUTPUT_STREAM, GOutputStreamClass))
37 #define G_IS_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_OUTPUT_STREAM))
38 #define G_IS_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_OUTPUT_STREAM))
39 #define G_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_OUTPUT_STREAM, GOutputStreamClass))
44 * Base class for writing output.
46 * All classes derived from GOutputStream should implement synchronous
47 * writing, splicing, flushing and closing streams, but may implement
48 * asynchronous versions.
50 typedef struct _GOutputStreamClass GOutputStreamClass;
51 typedef struct _GOutputStreamPrivate GOutputStreamPrivate;
55 GObject parent_instance;
58 GOutputStreamPrivate *priv;
62 struct _GOutputStreamClass
64 GObjectClass parent_class;
68 gssize (* write_fn) (GOutputStream *stream,
71 GCancellable *cancellable,
73 gssize (* splice) (GOutputStream *stream,
75 GOutputStreamSpliceFlags flags,
76 GCancellable *cancellable,
78 gboolean (* flush) (GOutputStream *stream,
79 GCancellable *cancellable,
81 gboolean (* close_fn) (GOutputStream *stream,
82 GCancellable *cancellable,
85 /* Async ops: (optional in derived classes) */
87 void (* write_async) (GOutputStream *stream,
91 GCancellable *cancellable,
92 GAsyncReadyCallback callback,
94 gssize (* write_finish) (GOutputStream *stream,
97 void (* splice_async) (GOutputStream *stream,
99 GOutputStreamSpliceFlags flags,
101 GCancellable *cancellable,
102 GAsyncReadyCallback callback,
104 gssize (* splice_finish) (GOutputStream *stream,
105 GAsyncResult *result,
107 void (* flush_async) (GOutputStream *stream,
109 GCancellable *cancellable,
110 GAsyncReadyCallback callback,
112 gboolean (* flush_finish) (GOutputStream *stream,
113 GAsyncResult *result,
115 void (* close_async) (GOutputStream *stream,
117 GCancellable *cancellable,
118 GAsyncReadyCallback callback,
120 gboolean (* close_finish) (GOutputStream *stream,
121 GAsyncResult *result,
124 gboolean (* writev_fn) (GOutputStream *stream,
125 const GOutputVector *vectors,
127 gsize *bytes_written,
128 GCancellable *cancellable,
131 void (* writev_async) (GOutputStream *stream,
132 const GOutputVector *vectors,
135 GCancellable *cancellable,
136 GAsyncReadyCallback callback,
139 gboolean (* writev_finish) (GOutputStream *stream,
140 GAsyncResult *result,
141 gsize *bytes_written,
145 /* Padding for future expansion */
146 void (*_g_reserved4) (void);
147 void (*_g_reserved5) (void);
148 void (*_g_reserved6) (void);
149 void (*_g_reserved7) (void);
150 void (*_g_reserved8) (void);
154 GType g_output_stream_get_type (void) G_GNUC_CONST;
157 gssize g_output_stream_write (GOutputStream *stream,
160 GCancellable *cancellable,
163 gboolean g_output_stream_write_all (GOutputStream *stream,
166 gsize *bytes_written,
167 GCancellable *cancellable,
170 GIO_AVAILABLE_IN_2_60
171 gboolean g_output_stream_writev (GOutputStream *stream,
172 const GOutputVector *vectors,
174 gsize *bytes_written,
175 GCancellable *cancellable,
177 GIO_AVAILABLE_IN_2_60
178 gboolean g_output_stream_writev_all (GOutputStream *stream,
179 GOutputVector *vectors,
181 gsize *bytes_written,
182 GCancellable *cancellable,
185 GIO_AVAILABLE_IN_2_40
186 gboolean g_output_stream_printf (GOutputStream *stream,
187 gsize *bytes_written,
188 GCancellable *cancellable,
191 ...) G_GNUC_PRINTF (5, 6);
192 GIO_AVAILABLE_IN_2_40
193 gboolean g_output_stream_vprintf (GOutputStream *stream,
194 gsize *bytes_written,
195 GCancellable *cancellable,
198 va_list args) G_GNUC_PRINTF (5, 0);
199 GIO_AVAILABLE_IN_2_34
200 gssize g_output_stream_write_bytes (GOutputStream *stream,
202 GCancellable *cancellable,
205 gssize g_output_stream_splice (GOutputStream *stream,
206 GInputStream *source,
207 GOutputStreamSpliceFlags flags,
208 GCancellable *cancellable,
211 gboolean g_output_stream_flush (GOutputStream *stream,
212 GCancellable *cancellable,
215 gboolean g_output_stream_close (GOutputStream *stream,
216 GCancellable *cancellable,
219 void g_output_stream_write_async (GOutputStream *stream,
223 GCancellable *cancellable,
224 GAsyncReadyCallback callback,
227 gssize g_output_stream_write_finish (GOutputStream *stream,
228 GAsyncResult *result,
231 GIO_AVAILABLE_IN_2_44
232 void g_output_stream_write_all_async (GOutputStream *stream,
236 GCancellable *cancellable,
237 GAsyncReadyCallback callback,
240 GIO_AVAILABLE_IN_2_44
241 gboolean g_output_stream_write_all_finish (GOutputStream *stream,
242 GAsyncResult *result,
243 gsize *bytes_written,
246 GIO_AVAILABLE_IN_2_60
247 void g_output_stream_writev_async (GOutputStream *stream,
248 const GOutputVector *vectors,
251 GCancellable *cancellable,
252 GAsyncReadyCallback callback,
254 GIO_AVAILABLE_IN_2_60
255 gboolean g_output_stream_writev_finish (GOutputStream *stream,
256 GAsyncResult *result,
257 gsize *bytes_written,
260 GIO_AVAILABLE_IN_2_60
261 void g_output_stream_writev_all_async (GOutputStream *stream,
262 GOutputVector *vectors,
265 GCancellable *cancellable,
266 GAsyncReadyCallback callback,
269 GIO_AVAILABLE_IN_2_60
270 gboolean g_output_stream_writev_all_finish (GOutputStream *stream,
271 GAsyncResult *result,
272 gsize *bytes_written,
275 GIO_AVAILABLE_IN_2_34
276 void g_output_stream_write_bytes_async (GOutputStream *stream,
279 GCancellable *cancellable,
280 GAsyncReadyCallback callback,
282 GIO_AVAILABLE_IN_2_34
283 gssize g_output_stream_write_bytes_finish (GOutputStream *stream,
284 GAsyncResult *result,
287 void g_output_stream_splice_async (GOutputStream *stream,
288 GInputStream *source,
289 GOutputStreamSpliceFlags flags,
291 GCancellable *cancellable,
292 GAsyncReadyCallback callback,
295 gssize g_output_stream_splice_finish (GOutputStream *stream,
296 GAsyncResult *result,
299 void g_output_stream_flush_async (GOutputStream *stream,
301 GCancellable *cancellable,
302 GAsyncReadyCallback callback,
305 gboolean g_output_stream_flush_finish (GOutputStream *stream,
306 GAsyncResult *result,
309 void g_output_stream_close_async (GOutputStream *stream,
311 GCancellable *cancellable,
312 GAsyncReadyCallback callback,
315 gboolean g_output_stream_close_finish (GOutputStream *stream,
316 GAsyncResult *result,
320 gboolean g_output_stream_is_closed (GOutputStream *stream);
322 gboolean g_output_stream_is_closing (GOutputStream *stream);
324 gboolean g_output_stream_has_pending (GOutputStream *stream);
326 gboolean g_output_stream_set_pending (GOutputStream *stream,
329 void g_output_stream_clear_pending (GOutputStream *stream);
334 #endif /* __G_OUTPUT_STREAM_H__ */