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 #include <glib-object.h>
27 #include <gio/gioerror.h>
28 #include <gio/gasyncresult.h>
29 #include <gio/gcancellable.h>
30 #include <gio/ginputstream.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))
42 * GOutputStreamSpliceFlags:
43 * @G_OUTPUT_STREAM_SPLICE_FLAGS_NONE:
44 * @G_OUTPUT_STREAM_SPLICE_FLAGS_CLOSE_SOURCE:
45 * @G_OUTPUT_STREAM_SPLICE_FLAGS_CLOSE_TARGET:
50 G_OUTPUT_STREAM_SPLICE_FLAGS_NONE = 0,
51 G_OUTPUT_STREAM_SPLICE_FLAGS_CLOSE_SOURCE = 1 << 0,
52 G_OUTPUT_STREAM_SPLICE_FLAGS_CLOSE_TARGET = 1 << 1
53 } GOutputStreamSpliceFlags;
58 * Base class for writing output.
60 * All classes derived from GOutputStream should implement synchronous
61 * writing, splicing, flushing and closing streams, but may implement
62 * asynchronous versions.
64 typedef struct _GOutputStream GOutputStream;
65 typedef struct _GOutputStreamClass GOutputStreamClass;
66 typedef struct _GOutputStreamPrivate GOutputStreamPrivate;
73 GOutputStreamPrivate *priv;
77 struct _GOutputStreamClass
79 GObjectClass parent_class;
83 gssize (* write) (GOutputStream *stream,
86 GCancellable *cancellable,
88 gssize (* splice) (GOutputStream *stream,
90 GOutputStreamSpliceFlags flags,
91 GCancellable *cancellable,
93 gboolean (* flush) (GOutputStream *stream,
94 GCancellable *cancellable,
96 gboolean (* close) (GOutputStream *stream,
97 GCancellable *cancellable,
100 /* Async ops: (optional in derived classes) */
102 void (* write_async) (GOutputStream *stream,
106 GCancellable *cancellable,
107 GAsyncReadyCallback callback,
109 gssize (* write_finish) (GOutputStream *stream,
110 GAsyncResult *result,
112 void (* splice_async) (GOutputStream *stream,
113 GInputStream *source,
114 GOutputStreamSpliceFlags flags,
116 GCancellable *cancellable,
117 GAsyncReadyCallback callback,
119 gssize (* splice_finish)(GOutputStream *stream,
120 GAsyncResult *result,
122 void (* flush_async) (GOutputStream *stream,
124 GCancellable *cancellable,
125 GAsyncReadyCallback callback,
127 gboolean (* flush_finish) (GOutputStream *stream,
128 GAsyncResult *result,
130 void (* close_async) (GOutputStream *stream,
132 GCancellable *cancellable,
133 GAsyncReadyCallback callback,
135 gboolean (* close_finish) (GOutputStream *stream,
136 GAsyncResult *result,
140 /* Padding for future expansion */
141 void (*_g_reserved1) (void);
142 void (*_g_reserved2) (void);
143 void (*_g_reserved3) (void);
144 void (*_g_reserved4) (void);
145 void (*_g_reserved5) (void);
146 void (*_g_reserved6) (void);
147 void (*_g_reserved7) (void);
148 void (*_g_reserved8) (void);
151 GType g_output_stream_get_type (void) G_GNUC_CONST;
153 gssize g_output_stream_write (GOutputStream *stream,
156 GCancellable *cancellable,
158 gboolean g_output_stream_write_all (GOutputStream *stream,
161 gsize *bytes_written,
162 GCancellable *cancellable,
164 gssize g_output_stream_splice (GOutputStream *stream,
165 GInputStream *source,
166 GOutputStreamSpliceFlags flags,
167 GCancellable *cancellable,
169 gboolean g_output_stream_flush (GOutputStream *stream,
170 GCancellable *cancellable,
172 gboolean g_output_stream_close (GOutputStream *stream,
173 GCancellable *cancellable,
175 void g_output_stream_write_async (GOutputStream *stream,
179 GCancellable *cancellable,
180 GAsyncReadyCallback callback,
182 gssize g_output_stream_write_finish (GOutputStream *stream,
183 GAsyncResult *result,
185 void g_output_stream_splice_async (GOutputStream *stream,
186 GInputStream *source,
187 GOutputStreamSpliceFlags flags,
189 GCancellable *cancellable,
190 GAsyncReadyCallback callback,
192 gssize g_output_stream_splice_finish (GOutputStream *stream,
193 GAsyncResult *result,
195 void g_output_stream_flush_async (GOutputStream *stream,
197 GCancellable *cancellable,
198 GAsyncReadyCallback callback,
200 gboolean g_output_stream_flush_finish (GOutputStream *stream,
201 GAsyncResult *result,
203 void g_output_stream_close_async (GOutputStream *stream,
205 GCancellable *cancellable,
206 GAsyncReadyCallback callback,
208 gboolean g_output_stream_close_finish (GOutputStream *stream,
209 GAsyncResult *result,
212 gboolean g_output_stream_is_closed (GOutputStream *stream);
213 gboolean g_output_stream_has_pending (GOutputStream *stream);
214 void g_output_stream_set_pending (GOutputStream *stream,
220 #endif /* __G_OUTPUT_STREAM_H__ */