1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2006-2007 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library 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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 * Author: Alexander Larsson <alexl@redhat.com>
21 #ifndef __G_OUTPUT_STREAM_H__
22 #define __G_OUTPUT_STREAM_H__
24 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
25 #error "Only <gio/gio.h> can be included directly."
28 #include <gio/giotypes.h>
32 #define G_TYPE_OUTPUT_STREAM (g_output_stream_get_type ())
33 #define G_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_OUTPUT_STREAM, GOutputStream))
34 #define G_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_OUTPUT_STREAM, GOutputStreamClass))
35 #define G_IS_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_OUTPUT_STREAM))
36 #define G_IS_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_OUTPUT_STREAM))
37 #define G_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_OUTPUT_STREAM, GOutputStreamClass))
42 * Base class for writing output.
44 * All classes derived from GOutputStream should implement synchronous
45 * writing, splicing, flushing and closing streams, but may implement
46 * asynchronous versions.
48 typedef struct _GOutputStreamClass GOutputStreamClass
;
49 typedef struct _GOutputStreamPrivate GOutputStreamPrivate
;
53 GObject parent_instance
;
56 GOutputStreamPrivate
*priv
;
60 struct _GOutputStreamClass
62 GObjectClass parent_class
;
66 gssize (* write_fn
) (GOutputStream
*stream
,
69 GCancellable
*cancellable
,
71 gssize (* splice
) (GOutputStream
*stream
,
73 GOutputStreamSpliceFlags flags
,
74 GCancellable
*cancellable
,
76 gboolean (* flush
) (GOutputStream
*stream
,
77 GCancellable
*cancellable
,
79 gboolean (* close_fn
) (GOutputStream
*stream
,
80 GCancellable
*cancellable
,
83 /* Async ops: (optional in derived classes) */
85 void (* write_async
) (GOutputStream
*stream
,
89 GCancellable
*cancellable
,
90 GAsyncReadyCallback callback
,
92 gssize (* write_finish
) (GOutputStream
*stream
,
95 void (* splice_async
) (GOutputStream
*stream
,
97 GOutputStreamSpliceFlags flags
,
99 GCancellable
*cancellable
,
100 GAsyncReadyCallback callback
,
102 gssize (* splice_finish
) (GOutputStream
*stream
,
103 GAsyncResult
*result
,
105 void (* flush_async
) (GOutputStream
*stream
,
107 GCancellable
*cancellable
,
108 GAsyncReadyCallback callback
,
110 gboolean (* flush_finish
) (GOutputStream
*stream
,
111 GAsyncResult
*result
,
113 void (* close_async
) (GOutputStream
*stream
,
115 GCancellable
*cancellable
,
116 GAsyncReadyCallback callback
,
118 gboolean (* close_finish
) (GOutputStream
*stream
,
119 GAsyncResult
*result
,
123 /* Padding for future expansion */
124 void (*_g_reserved1
) (void);
125 void (*_g_reserved2
) (void);
126 void (*_g_reserved3
) (void);
127 void (*_g_reserved4
) (void);
128 void (*_g_reserved5
) (void);
129 void (*_g_reserved6
) (void);
130 void (*_g_reserved7
) (void);
131 void (*_g_reserved8
) (void);
134 GLIB_AVAILABLE_IN_ALL
135 GType
g_output_stream_get_type (void) G_GNUC_CONST
;
137 GLIB_AVAILABLE_IN_ALL
138 gssize
g_output_stream_write (GOutputStream
*stream
,
141 GCancellable
*cancellable
,
143 GLIB_AVAILABLE_IN_ALL
144 gboolean
g_output_stream_write_all (GOutputStream
*stream
,
147 gsize
*bytes_written
,
148 GCancellable
*cancellable
,
150 GLIB_AVAILABLE_IN_2_40
151 gboolean
g_output_stream_printf (GOutputStream
*stream
,
152 gsize
*bytes_written
,
153 GCancellable
*cancellable
,
156 ...) G_GNUC_PRINTF (5, 6);
157 GLIB_AVAILABLE_IN_2_40
158 gboolean
g_output_stream_vprintf (GOutputStream
*stream
,
159 gsize
*bytes_written
,
160 GCancellable
*cancellable
,
163 va_list args
) G_GNUC_PRINTF (5, 0);
164 GLIB_AVAILABLE_IN_2_34
165 gssize
g_output_stream_write_bytes (GOutputStream
*stream
,
167 GCancellable
*cancellable
,
169 GLIB_AVAILABLE_IN_ALL
170 gssize
g_output_stream_splice (GOutputStream
*stream
,
171 GInputStream
*source
,
172 GOutputStreamSpliceFlags flags
,
173 GCancellable
*cancellable
,
175 GLIB_AVAILABLE_IN_ALL
176 gboolean
g_output_stream_flush (GOutputStream
*stream
,
177 GCancellable
*cancellable
,
179 GLIB_AVAILABLE_IN_ALL
180 gboolean
g_output_stream_close (GOutputStream
*stream
,
181 GCancellable
*cancellable
,
183 GLIB_AVAILABLE_IN_ALL
184 void g_output_stream_write_async (GOutputStream
*stream
,
188 GCancellable
*cancellable
,
189 GAsyncReadyCallback callback
,
191 GLIB_AVAILABLE_IN_ALL
192 gssize
g_output_stream_write_finish (GOutputStream
*stream
,
193 GAsyncResult
*result
,
196 GLIB_AVAILABLE_IN_2_44
197 void g_output_stream_write_all_async (GOutputStream
*stream
,
201 GCancellable
*cancellable
,
202 GAsyncReadyCallback callback
,
205 GLIB_AVAILABLE_IN_2_44
206 gboolean
g_output_stream_write_all_finish (GOutputStream
*stream
,
207 GAsyncResult
*result
,
208 gsize
*bytes_written
,
211 GLIB_AVAILABLE_IN_2_34
212 void g_output_stream_write_bytes_async (GOutputStream
*stream
,
215 GCancellable
*cancellable
,
216 GAsyncReadyCallback callback
,
218 GLIB_AVAILABLE_IN_2_34
219 gssize
g_output_stream_write_bytes_finish (GOutputStream
*stream
,
220 GAsyncResult
*result
,
222 GLIB_AVAILABLE_IN_ALL
223 void g_output_stream_splice_async (GOutputStream
*stream
,
224 GInputStream
*source
,
225 GOutputStreamSpliceFlags flags
,
227 GCancellable
*cancellable
,
228 GAsyncReadyCallback callback
,
230 GLIB_AVAILABLE_IN_ALL
231 gssize
g_output_stream_splice_finish (GOutputStream
*stream
,
232 GAsyncResult
*result
,
234 GLIB_AVAILABLE_IN_ALL
235 void g_output_stream_flush_async (GOutputStream
*stream
,
237 GCancellable
*cancellable
,
238 GAsyncReadyCallback callback
,
240 GLIB_AVAILABLE_IN_ALL
241 gboolean
g_output_stream_flush_finish (GOutputStream
*stream
,
242 GAsyncResult
*result
,
244 GLIB_AVAILABLE_IN_ALL
245 void g_output_stream_close_async (GOutputStream
*stream
,
247 GCancellable
*cancellable
,
248 GAsyncReadyCallback callback
,
250 GLIB_AVAILABLE_IN_ALL
251 gboolean
g_output_stream_close_finish (GOutputStream
*stream
,
252 GAsyncResult
*result
,
255 GLIB_AVAILABLE_IN_ALL
256 gboolean
g_output_stream_is_closed (GOutputStream
*stream
);
257 GLIB_AVAILABLE_IN_ALL
258 gboolean
g_output_stream_is_closing (GOutputStream
*stream
);
259 GLIB_AVAILABLE_IN_ALL
260 gboolean
g_output_stream_has_pending (GOutputStream
*stream
);
261 GLIB_AVAILABLE_IN_ALL
262 gboolean
g_output_stream_set_pending (GOutputStream
*stream
,
264 GLIB_AVAILABLE_IN_ALL
265 void g_output_stream_clear_pending (GOutputStream
*stream
);
270 #endif /* __G_OUTPUT_STREAM_H__ */