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 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
24 #error "Only <gio/gio.h> can be included directly."
27 #ifndef __G_INPUT_STREAM_H__
28 #define __G_INPUT_STREAM_H__
30 #include <glib-object.h>
31 #include <gio/gioerror.h>
32 #include <gio/gcancellable.h>
33 #include <gio/gasyncresult.h>
37 #define G_TYPE_INPUT_STREAM (g_input_stream_get_type ())
38 #define G_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_INPUT_STREAM, GInputStream))
39 #define G_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_INPUT_STREAM, GInputStreamClass))
40 #define G_IS_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_INPUT_STREAM))
41 #define G_IS_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_INPUT_STREAM))
42 #define G_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_INPUT_STREAM, GInputStreamClass))
47 * Base class for streaming input operations.
49 typedef struct _GInputStream GInputStream;
50 typedef struct _GInputStreamClass GInputStreamClass;
51 typedef struct _GInputStreamPrivate GInputStreamPrivate;
55 GObject parent_instance;
58 GInputStreamPrivate *priv;
61 struct _GInputStreamClass
63 GObjectClass parent_class;
67 gssize (* read_fn) (GInputStream *stream,
70 GCancellable *cancellable,
72 gssize (* skip) (GInputStream *stream,
74 GCancellable *cancellable,
76 gboolean (* close_fn) (GInputStream *stream,
77 GCancellable *cancellable,
80 /* Async ops: (optional in derived classes) */
81 void (* read_async) (GInputStream *stream,
85 GCancellable *cancellable,
86 GAsyncReadyCallback callback,
88 gssize (* read_finish) (GInputStream *stream,
91 void (* skip_async) (GInputStream *stream,
94 GCancellable *cancellable,
95 GAsyncReadyCallback callback,
97 gssize (* skip_finish) (GInputStream *stream,
100 void (* close_async) (GInputStream *stream,
102 GCancellable *cancellable,
103 GAsyncReadyCallback callback,
105 gboolean (* close_finish)(GInputStream *stream,
106 GAsyncResult *result,
110 /* Padding for future expansion */
111 void (*_g_reserved1) (void);
112 void (*_g_reserved2) (void);
113 void (*_g_reserved3) (void);
114 void (*_g_reserved4) (void);
115 void (*_g_reserved5) (void);
118 GType g_input_stream_get_type (void) G_GNUC_CONST;
120 gssize g_input_stream_read (GInputStream *stream,
123 GCancellable *cancellable,
125 gboolean g_input_stream_read_all (GInputStream *stream,
129 GCancellable *cancellable,
131 gssize g_input_stream_skip (GInputStream *stream,
133 GCancellable *cancellable,
135 gboolean g_input_stream_close (GInputStream *stream,
136 GCancellable *cancellable,
138 void g_input_stream_read_async (GInputStream *stream,
142 GCancellable *cancellable,
143 GAsyncReadyCallback callback,
145 gssize g_input_stream_read_finish (GInputStream *stream,
146 GAsyncResult *result,
148 void g_input_stream_skip_async (GInputStream *stream,
151 GCancellable *cancellable,
152 GAsyncReadyCallback callback,
154 gssize g_input_stream_skip_finish (GInputStream *stream,
155 GAsyncResult *result,
157 void g_input_stream_close_async (GInputStream *stream,
159 GCancellable *cancellable,
160 GAsyncReadyCallback callback,
162 gboolean g_input_stream_close_finish (GInputStream *stream,
163 GAsyncResult *result,
166 /* For implementations: */
168 gboolean g_input_stream_is_closed (GInputStream *stream);
169 gboolean g_input_stream_has_pending (GInputStream *stream);
170 gboolean g_input_stream_set_pending (GInputStream *stream,
172 void g_input_stream_clear_pending (GInputStream *stream);
176 #endif /* __G_INPUT_STREAM_H__ */