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_INPUT_STREAM_H__
24 #define __G_INPUT_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_INPUT_STREAM (g_input_stream_get_type ())
35 #define G_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_INPUT_STREAM, GInputStream))
36 #define G_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_INPUT_STREAM, GInputStreamClass))
37 #define G_IS_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_INPUT_STREAM))
38 #define G_IS_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_INPUT_STREAM))
39 #define G_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_INPUT_STREAM, GInputStreamClass))
44 * Base class for streaming input operations.
46 typedef struct _GInputStreamClass GInputStreamClass;
47 typedef struct _GInputStreamPrivate GInputStreamPrivate;
51 GObject parent_instance;
54 GInputStreamPrivate *priv;
57 struct _GInputStreamClass
59 GObjectClass parent_class;
63 gssize (* read_fn) (GInputStream *stream,
66 GCancellable *cancellable,
68 gssize (* skip) (GInputStream *stream,
70 GCancellable *cancellable,
72 gboolean (* close_fn) (GInputStream *stream,
73 GCancellable *cancellable,
76 /* Async ops: (optional in derived classes) */
77 void (* read_async) (GInputStream *stream,
81 GCancellable *cancellable,
82 GAsyncReadyCallback callback,
84 gssize (* read_finish) (GInputStream *stream,
87 void (* skip_async) (GInputStream *stream,
90 GCancellable *cancellable,
91 GAsyncReadyCallback callback,
93 gssize (* skip_finish) (GInputStream *stream,
96 void (* close_async) (GInputStream *stream,
98 GCancellable *cancellable,
99 GAsyncReadyCallback callback,
101 gboolean (* close_finish) (GInputStream *stream,
102 GAsyncResult *result,
106 /* Padding for future expansion */
107 void (*_g_reserved1) (void);
108 void (*_g_reserved2) (void);
109 void (*_g_reserved3) (void);
110 void (*_g_reserved4) (void);
111 void (*_g_reserved5) (void);
114 GLIB_AVAILABLE_IN_ALL
115 GType g_input_stream_get_type (void) G_GNUC_CONST;
117 GLIB_AVAILABLE_IN_ALL
118 gssize g_input_stream_read (GInputStream *stream,
121 GCancellable *cancellable,
123 GLIB_AVAILABLE_IN_ALL
124 gboolean g_input_stream_read_all (GInputStream *stream,
128 GCancellable *cancellable,
130 GLIB_AVAILABLE_IN_2_34
131 GBytes *g_input_stream_read_bytes (GInputStream *stream,
133 GCancellable *cancellable,
135 GLIB_AVAILABLE_IN_ALL
136 gssize g_input_stream_skip (GInputStream *stream,
138 GCancellable *cancellable,
140 GLIB_AVAILABLE_IN_ALL
141 gboolean g_input_stream_close (GInputStream *stream,
142 GCancellable *cancellable,
144 GLIB_AVAILABLE_IN_ALL
145 void g_input_stream_read_async (GInputStream *stream,
149 GCancellable *cancellable,
150 GAsyncReadyCallback callback,
152 GLIB_AVAILABLE_IN_ALL
153 gssize g_input_stream_read_finish (GInputStream *stream,
154 GAsyncResult *result,
156 GLIB_AVAILABLE_IN_2_34
157 void g_input_stream_read_bytes_async (GInputStream *stream,
160 GCancellable *cancellable,
161 GAsyncReadyCallback callback,
163 GLIB_AVAILABLE_IN_2_34
164 GBytes *g_input_stream_read_bytes_finish (GInputStream *stream,
165 GAsyncResult *result,
167 GLIB_AVAILABLE_IN_ALL
168 void g_input_stream_skip_async (GInputStream *stream,
171 GCancellable *cancellable,
172 GAsyncReadyCallback callback,
174 GLIB_AVAILABLE_IN_ALL
175 gssize g_input_stream_skip_finish (GInputStream *stream,
176 GAsyncResult *result,
178 GLIB_AVAILABLE_IN_ALL
179 void g_input_stream_close_async (GInputStream *stream,
181 GCancellable *cancellable,
182 GAsyncReadyCallback callback,
184 GLIB_AVAILABLE_IN_ALL
185 gboolean g_input_stream_close_finish (GInputStream *stream,
186 GAsyncResult *result,
189 /* For implementations: */
191 GLIB_AVAILABLE_IN_ALL
192 gboolean g_input_stream_is_closed (GInputStream *stream);
193 GLIB_AVAILABLE_IN_ALL
194 gboolean g_input_stream_has_pending (GInputStream *stream);
195 GLIB_AVAILABLE_IN_ALL
196 gboolean g_input_stream_set_pending (GInputStream *stream,
198 GLIB_AVAILABLE_IN_ALL
199 void g_input_stream_clear_pending (GInputStream *stream);
203 #endif /* __G_INPUT_STREAM_H__ */