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 #include <glib-object.h>
27 #include <gio/gioerror.h>
28 #include <gio/gcancellable.h>
29 #include <gio/gasyncresult.h>
33 #define G_TYPE_INPUT_STREAM (g_input_stream_get_type ())
34 #define G_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_INPUT_STREAM, GInputStream))
35 #define G_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_INPUT_STREAM, GInputStreamClass))
36 #define G_IS_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_INPUT_STREAM))
37 #define G_IS_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_INPUT_STREAM))
38 #define G_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_INPUT_STREAM, GInputStreamClass))
43 * Base class for streaming input operations.
45 typedef struct _GInputStream GInputStream;
46 typedef struct _GInputStreamClass GInputStreamClass;
47 typedef struct _GInputStreamPrivate GInputStreamPrivate;
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 GType g_input_stream_get_type (void) G_GNUC_CONST;
116 gssize g_input_stream_read (GInputStream *stream,
119 GCancellable *cancellable,
121 gboolean g_input_stream_read_all (GInputStream *stream,
125 GCancellable *cancellable,
127 gssize g_input_stream_skip (GInputStream *stream,
129 GCancellable *cancellable,
131 gboolean g_input_stream_close (GInputStream *stream,
132 GCancellable *cancellable,
134 void g_input_stream_read_async (GInputStream *stream,
138 GCancellable *cancellable,
139 GAsyncReadyCallback callback,
141 gssize g_input_stream_read_finish (GInputStream *stream,
142 GAsyncResult *result,
144 void g_input_stream_skip_async (GInputStream *stream,
147 GCancellable *cancellable,
148 GAsyncReadyCallback callback,
150 gssize g_input_stream_skip_finish (GInputStream *stream,
151 GAsyncResult *result,
153 void g_input_stream_close_async (GInputStream *stream,
155 GCancellable *cancellable,
156 GAsyncReadyCallback callback,
158 gboolean g_input_stream_close_finish (GInputStream *stream,
159 GAsyncResult *result,
162 /* For implementations: */
164 gboolean g_input_stream_is_closed (GInputStream *stream);
165 gboolean g_input_stream_has_pending (GInputStream *stream);
166 gboolean g_input_stream_set_pending (GInputStream *stream,
168 void g_input_stream_clear_pending (GInputStream *stream);
172 #endif /* __G_INPUT_STREAM_H__ */