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 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, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
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
,
125 /* Padding for future expansion */
126 void (*_g_reserved1
) (void);
127 void (*_g_reserved2
) (void);
128 void (*_g_reserved3
) (void);
129 void (*_g_reserved4
) (void);
130 void (*_g_reserved5
) (void);
131 void (*_g_reserved6
) (void);
132 void (*_g_reserved7
) (void);
133 void (*_g_reserved8
) (void);
136 GLIB_AVAILABLE_IN_ALL
137 GType
g_output_stream_get_type (void) G_GNUC_CONST
;
139 GLIB_AVAILABLE_IN_ALL
140 gssize
g_output_stream_write (GOutputStream
*stream
,
143 GCancellable
*cancellable
,
145 GLIB_AVAILABLE_IN_ALL
146 gboolean
g_output_stream_write_all (GOutputStream
*stream
,
149 gsize
*bytes_written
,
150 GCancellable
*cancellable
,
152 GLIB_AVAILABLE_IN_2_34
153 gssize
g_output_stream_write_bytes (GOutputStream
*stream
,
155 GCancellable
*cancellable
,
157 GLIB_AVAILABLE_IN_ALL
158 gssize
g_output_stream_splice (GOutputStream
*stream
,
159 GInputStream
*source
,
160 GOutputStreamSpliceFlags flags
,
161 GCancellable
*cancellable
,
163 GLIB_AVAILABLE_IN_ALL
164 gboolean
g_output_stream_flush (GOutputStream
*stream
,
165 GCancellable
*cancellable
,
167 GLIB_AVAILABLE_IN_ALL
168 gboolean
g_output_stream_close (GOutputStream
*stream
,
169 GCancellable
*cancellable
,
171 GLIB_AVAILABLE_IN_ALL
172 void g_output_stream_write_async (GOutputStream
*stream
,
176 GCancellable
*cancellable
,
177 GAsyncReadyCallback callback
,
179 GLIB_AVAILABLE_IN_ALL
180 gssize
g_output_stream_write_finish (GOutputStream
*stream
,
181 GAsyncResult
*result
,
183 GLIB_AVAILABLE_IN_2_34
184 void g_output_stream_write_bytes_async (GOutputStream
*stream
,
187 GCancellable
*cancellable
,
188 GAsyncReadyCallback callback
,
190 GLIB_AVAILABLE_IN_2_34
191 gssize
g_output_stream_write_bytes_finish (GOutputStream
*stream
,
192 GAsyncResult
*result
,
194 GLIB_AVAILABLE_IN_ALL
195 void g_output_stream_splice_async (GOutputStream
*stream
,
196 GInputStream
*source
,
197 GOutputStreamSpliceFlags flags
,
199 GCancellable
*cancellable
,
200 GAsyncReadyCallback callback
,
202 GLIB_AVAILABLE_IN_ALL
203 gssize
g_output_stream_splice_finish (GOutputStream
*stream
,
204 GAsyncResult
*result
,
206 GLIB_AVAILABLE_IN_ALL
207 void g_output_stream_flush_async (GOutputStream
*stream
,
209 GCancellable
*cancellable
,
210 GAsyncReadyCallback callback
,
212 GLIB_AVAILABLE_IN_ALL
213 gboolean
g_output_stream_flush_finish (GOutputStream
*stream
,
214 GAsyncResult
*result
,
216 GLIB_AVAILABLE_IN_ALL
217 void g_output_stream_close_async (GOutputStream
*stream
,
219 GCancellable
*cancellable
,
220 GAsyncReadyCallback callback
,
222 GLIB_AVAILABLE_IN_ALL
223 gboolean
g_output_stream_close_finish (GOutputStream
*stream
,
224 GAsyncResult
*result
,
227 GLIB_AVAILABLE_IN_ALL
228 gboolean
g_output_stream_is_closed (GOutputStream
*stream
);
229 GLIB_AVAILABLE_IN_ALL
230 gboolean
g_output_stream_is_closing (GOutputStream
*stream
);
231 GLIB_AVAILABLE_IN_ALL
232 gboolean
g_output_stream_has_pending (GOutputStream
*stream
);
233 GLIB_AVAILABLE_IN_ALL
234 gboolean
g_output_stream_set_pending (GOutputStream
*stream
,
236 GLIB_AVAILABLE_IN_ALL
237 void g_output_stream_clear_pending (GOutputStream
*stream
);
242 #endif /* __G_OUTPUT_STREAM_H__ */