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_INPUT_STREAM_H__
22 #define __G_INPUT_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_INPUT_STREAM (g_input_stream_get_type ())
33 #define G_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_INPUT_STREAM, GInputStream))
34 #define G_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_INPUT_STREAM, GInputStreamClass))
35 #define G_IS_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_INPUT_STREAM))
36 #define G_IS_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_INPUT_STREAM))
37 #define G_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_INPUT_STREAM, GInputStreamClass))
42 * Base class for streaming input operations.
44 typedef struct _GInputStreamClass GInputStreamClass
;
45 typedef struct _GInputStreamPrivate GInputStreamPrivate
;
49 GObject parent_instance
;
52 GInputStreamPrivate
*priv
;
55 struct _GInputStreamClass
57 GObjectClass parent_class
;
61 gssize (* read_fn
) (GInputStream
*stream
,
64 GCancellable
*cancellable
,
66 gssize (* skip
) (GInputStream
*stream
,
68 GCancellable
*cancellable
,
70 gboolean (* close_fn
) (GInputStream
*stream
,
71 GCancellable
*cancellable
,
74 /* Async ops: (optional in derived classes) */
75 void (* read_async
) (GInputStream
*stream
,
79 GCancellable
*cancellable
,
80 GAsyncReadyCallback callback
,
82 gssize (* read_finish
) (GInputStream
*stream
,
85 void (* skip_async
) (GInputStream
*stream
,
88 GCancellable
*cancellable
,
89 GAsyncReadyCallback callback
,
91 gssize (* skip_finish
) (GInputStream
*stream
,
94 void (* close_async
) (GInputStream
*stream
,
96 GCancellable
*cancellable
,
97 GAsyncReadyCallback callback
,
99 gboolean (* close_finish
) (GInputStream
*stream
,
100 GAsyncResult
*result
,
104 /* Padding for future expansion */
105 void (*_g_reserved1
) (void);
106 void (*_g_reserved2
) (void);
107 void (*_g_reserved3
) (void);
108 void (*_g_reserved4
) (void);
109 void (*_g_reserved5
) (void);
112 GLIB_AVAILABLE_IN_ALL
113 GType
g_input_stream_get_type (void) G_GNUC_CONST
;
115 GLIB_AVAILABLE_IN_ALL
116 gssize
g_input_stream_read (GInputStream
*stream
,
119 GCancellable
*cancellable
,
121 GLIB_AVAILABLE_IN_ALL
122 gboolean
g_input_stream_read_all (GInputStream
*stream
,
126 GCancellable
*cancellable
,
128 GLIB_AVAILABLE_IN_2_34
129 GBytes
*g_input_stream_read_bytes (GInputStream
*stream
,
131 GCancellable
*cancellable
,
133 GLIB_AVAILABLE_IN_ALL
134 gssize
g_input_stream_skip (GInputStream
*stream
,
136 GCancellable
*cancellable
,
138 GLIB_AVAILABLE_IN_ALL
139 gboolean
g_input_stream_close (GInputStream
*stream
,
140 GCancellable
*cancellable
,
142 GLIB_AVAILABLE_IN_ALL
143 void g_input_stream_read_async (GInputStream
*stream
,
147 GCancellable
*cancellable
,
148 GAsyncReadyCallback callback
,
150 GLIB_AVAILABLE_IN_ALL
151 gssize
g_input_stream_read_finish (GInputStream
*stream
,
152 GAsyncResult
*result
,
155 GLIB_AVAILABLE_IN_2_44
156 void g_input_stream_read_all_async (GInputStream
*stream
,
160 GCancellable
*cancellable
,
161 GAsyncReadyCallback callback
,
163 GLIB_AVAILABLE_IN_2_44
164 gboolean
g_input_stream_read_all_finish (GInputStream
*stream
,
165 GAsyncResult
*result
,
169 GLIB_AVAILABLE_IN_2_34
170 void g_input_stream_read_bytes_async (GInputStream
*stream
,
173 GCancellable
*cancellable
,
174 GAsyncReadyCallback callback
,
176 GLIB_AVAILABLE_IN_2_34
177 GBytes
*g_input_stream_read_bytes_finish (GInputStream
*stream
,
178 GAsyncResult
*result
,
180 GLIB_AVAILABLE_IN_ALL
181 void g_input_stream_skip_async (GInputStream
*stream
,
184 GCancellable
*cancellable
,
185 GAsyncReadyCallback callback
,
187 GLIB_AVAILABLE_IN_ALL
188 gssize
g_input_stream_skip_finish (GInputStream
*stream
,
189 GAsyncResult
*result
,
191 GLIB_AVAILABLE_IN_ALL
192 void g_input_stream_close_async (GInputStream
*stream
,
194 GCancellable
*cancellable
,
195 GAsyncReadyCallback callback
,
197 GLIB_AVAILABLE_IN_ALL
198 gboolean
g_input_stream_close_finish (GInputStream
*stream
,
199 GAsyncResult
*result
,
202 /* For implementations: */
204 GLIB_AVAILABLE_IN_ALL
205 gboolean
g_input_stream_is_closed (GInputStream
*stream
);
206 GLIB_AVAILABLE_IN_ALL
207 gboolean
g_input_stream_has_pending (GInputStream
*stream
);
208 GLIB_AVAILABLE_IN_ALL
209 gboolean
g_input_stream_set_pending (GInputStream
*stream
,
211 GLIB_AVAILABLE_IN_ALL
212 void g_input_stream_clear_pending (GInputStream
*stream
);
216 #endif /* __G_INPUT_STREAM_H__ */