Merge branch '976-disable-assert-checks' into 'master'
[glib.git] / gio / ginputstream.h
blob53b14e38702cfe228b17f8ad0a0071d7fb080c83
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."
26 #endif
28 #include <gio/giotypes.h>
30 G_BEGIN_DECLS
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))
39 /**
40 * GInputStream:
42 * Base class for streaming input operations.
43 **/
44 typedef struct _GInputStreamClass GInputStreamClass;
45 typedef struct _GInputStreamPrivate GInputStreamPrivate;
47 struct _GInputStream
49 GObject parent_instance;
51 /*< private >*/
52 GInputStreamPrivate *priv;
55 struct _GInputStreamClass
57 GObjectClass parent_class;
59 /* Sync ops: */
61 gssize (* read_fn) (GInputStream *stream,
62 void *buffer,
63 gsize count,
64 GCancellable *cancellable,
65 GError **error);
66 gssize (* skip) (GInputStream *stream,
67 gsize count,
68 GCancellable *cancellable,
69 GError **error);
70 gboolean (* close_fn) (GInputStream *stream,
71 GCancellable *cancellable,
72 GError **error);
74 /* Async ops: (optional in derived classes) */
75 void (* read_async) (GInputStream *stream,
76 void *buffer,
77 gsize count,
78 int io_priority,
79 GCancellable *cancellable,
80 GAsyncReadyCallback callback,
81 gpointer user_data);
82 gssize (* read_finish) (GInputStream *stream,
83 GAsyncResult *result,
84 GError **error);
85 void (* skip_async) (GInputStream *stream,
86 gsize count,
87 int io_priority,
88 GCancellable *cancellable,
89 GAsyncReadyCallback callback,
90 gpointer user_data);
91 gssize (* skip_finish) (GInputStream *stream,
92 GAsyncResult *result,
93 GError **error);
94 void (* close_async) (GInputStream *stream,
95 int io_priority,
96 GCancellable *cancellable,
97 GAsyncReadyCallback callback,
98 gpointer user_data);
99 gboolean (* close_finish) (GInputStream *stream,
100 GAsyncResult *result,
101 GError **error);
103 /*< private >*/
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,
117 void *buffer,
118 gsize count,
119 GCancellable *cancellable,
120 GError **error);
121 GLIB_AVAILABLE_IN_ALL
122 gboolean g_input_stream_read_all (GInputStream *stream,
123 void *buffer,
124 gsize count,
125 gsize *bytes_read,
126 GCancellable *cancellable,
127 GError **error);
128 GLIB_AVAILABLE_IN_2_34
129 GBytes *g_input_stream_read_bytes (GInputStream *stream,
130 gsize count,
131 GCancellable *cancellable,
132 GError **error);
133 GLIB_AVAILABLE_IN_ALL
134 gssize g_input_stream_skip (GInputStream *stream,
135 gsize count,
136 GCancellable *cancellable,
137 GError **error);
138 GLIB_AVAILABLE_IN_ALL
139 gboolean g_input_stream_close (GInputStream *stream,
140 GCancellable *cancellable,
141 GError **error);
142 GLIB_AVAILABLE_IN_ALL
143 void g_input_stream_read_async (GInputStream *stream,
144 void *buffer,
145 gsize count,
146 int io_priority,
147 GCancellable *cancellable,
148 GAsyncReadyCallback callback,
149 gpointer user_data);
150 GLIB_AVAILABLE_IN_ALL
151 gssize g_input_stream_read_finish (GInputStream *stream,
152 GAsyncResult *result,
153 GError **error);
155 GLIB_AVAILABLE_IN_2_44
156 void g_input_stream_read_all_async (GInputStream *stream,
157 void *buffer,
158 gsize count,
159 int io_priority,
160 GCancellable *cancellable,
161 GAsyncReadyCallback callback,
162 gpointer user_data);
163 GLIB_AVAILABLE_IN_2_44
164 gboolean g_input_stream_read_all_finish (GInputStream *stream,
165 GAsyncResult *result,
166 gsize *bytes_read,
167 GError **error);
169 GLIB_AVAILABLE_IN_2_34
170 void g_input_stream_read_bytes_async (GInputStream *stream,
171 gsize count,
172 int io_priority,
173 GCancellable *cancellable,
174 GAsyncReadyCallback callback,
175 gpointer user_data);
176 GLIB_AVAILABLE_IN_2_34
177 GBytes *g_input_stream_read_bytes_finish (GInputStream *stream,
178 GAsyncResult *result,
179 GError **error);
180 GLIB_AVAILABLE_IN_ALL
181 void g_input_stream_skip_async (GInputStream *stream,
182 gsize count,
183 int io_priority,
184 GCancellable *cancellable,
185 GAsyncReadyCallback callback,
186 gpointer user_data);
187 GLIB_AVAILABLE_IN_ALL
188 gssize g_input_stream_skip_finish (GInputStream *stream,
189 GAsyncResult *result,
190 GError **error);
191 GLIB_AVAILABLE_IN_ALL
192 void g_input_stream_close_async (GInputStream *stream,
193 int io_priority,
194 GCancellable *cancellable,
195 GAsyncReadyCallback callback,
196 gpointer user_data);
197 GLIB_AVAILABLE_IN_ALL
198 gboolean g_input_stream_close_finish (GInputStream *stream,
199 GAsyncResult *result,
200 GError **error);
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,
210 GError **error);
211 GLIB_AVAILABLE_IN_ALL
212 void g_input_stream_clear_pending (GInputStream *stream);
214 G_END_DECLS
216 #endif /* __G_INPUT_STREAM_H__ */