gio/ docs/reference/gio Merged gio-standalone into glib.
[platform/upstream/glib.git] / gio / ginputstream.h
1 /* GIO - GLib Input, Output and Streaming Library
2  * 
3  * Copyright (C) 2006-2007 Red Hat, Inc.
4  *
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.
9  *
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.
14  *
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.
19  *
20  * Author: Alexander Larsson <alexl@redhat.com>
21  */
22
23 #ifndef __G_INPUT_STREAM_H__
24 #define __G_INPUT_STREAM_H__
25
26 #include <glib-object.h>
27 #include <gio/gioerror.h>
28 #include <gio/gcancellable.h>
29 #include <gio/gasyncresult.h>
30
31 G_BEGIN_DECLS
32
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))
39
40 typedef struct _GInputStream         GInputStream;
41 typedef struct _GInputStreamClass    GInputStreamClass;
42 typedef struct _GInputStreamPrivate  GInputStreamPrivate;
43
44 struct _GInputStream
45 {
46   GObject parent;
47
48   /*< private >*/
49   GInputStreamPrivate *priv;
50 };
51
52 struct _GInputStreamClass
53 {
54   GObjectClass parent_class;
55
56   /* Sync ops: */
57   
58   gssize   (* read)        (GInputStream *stream,
59                             void         *buffer,
60                             gsize         count,
61                             GCancellable *cancellable,
62                             GError      **error);
63   gssize   (* skip)        (GInputStream *stream,
64                             gsize         count,
65                             GCancellable *cancellable,
66                             GError      **error);
67   gboolean (* close)       (GInputStream *stream,
68                             GCancellable *cancellable,
69                             GError      **error);
70
71   /* Async ops: (optional in derived classes) */
72   void     (* read_async)  (GInputStream        *stream,
73                             void               *buffer,
74                             gsize               count,
75                             int                 io_priority,
76                             GCancellable       *cancellable,
77                             GAsyncReadyCallback callback,
78                             gpointer            user_data);
79   gssize   (* read_finish) (GInputStream       *stream,
80                             GAsyncResult       *result,
81                             GError            **error);
82   void     (* skip_async)  (GInputStream       *stream,
83                             gsize               count,
84                             int                 io_priority,
85                             GCancellable       *cancellable,
86                             GAsyncReadyCallback callback,
87                             gpointer            user_data);
88   gssize   (* skip_finish) (GInputStream        *stream,
89                             GAsyncResult       *result,
90                             GError            **error);
91   void     (* close_async) (GInputStream        *stream,
92                             int                  io_priority,
93                             GCancellable       *cancellable,
94                             GAsyncReadyCallback callback,
95                             gpointer            user_data);
96   gboolean (* close_finish)(GInputStream        *stream,
97                             GAsyncResult       *result,
98                             GError            **error);
99
100   /* Padding for future expansion */
101   void (*_g_reserved1) (void);
102   void (*_g_reserved2) (void);
103   void (*_g_reserved3) (void);
104   void (*_g_reserved4) (void);
105   void (*_g_reserved5) (void);
106 };
107
108 GType g_input_stream_get_type (void) G_GNUC_CONST;
109
110 gssize   g_input_stream_read         (GInputStream          *stream,
111                                       void                  *buffer,
112                                       gsize                  count,
113                                       GCancellable          *cancellable,
114                                       GError               **error);
115 gboolean g_input_stream_read_all     (GInputStream          *stream,
116                                       void                  *buffer,
117                                       gsize                  count,
118                                       gsize                 *bytes_read,
119                                       GCancellable          *cancellable,
120                                       GError               **error);
121 gssize   g_input_stream_skip         (GInputStream          *stream,
122                                       gsize                  count,
123                                       GCancellable          *cancellable,
124                                       GError               **error);
125 gboolean g_input_stream_close        (GInputStream          *stream,
126                                       GCancellable          *cancellable,
127                                       GError               **error);
128 void     g_input_stream_read_async   (GInputStream          *stream,
129                                       void                  *buffer,
130                                       gsize                  count,
131                                       int                    io_priority,
132                                       GCancellable          *cancellable,
133                                       GAsyncReadyCallback    callback,
134                                       gpointer               user_data);
135 gssize   g_input_stream_read_finish  (GInputStream          *stream,
136                                       GAsyncResult          *result,
137                                       GError               **error);
138 void     g_input_stream_skip_async   (GInputStream          *stream,
139                                       gsize                  count,
140                                       int                    io_priority,
141                                       GCancellable          *cancellable,
142                                       GAsyncReadyCallback    callback,
143                                       gpointer               user_data);
144 gssize   g_input_stream_skip_finish  (GInputStream          *stream,
145                                       GAsyncResult          *result,
146                                       GError               **error);
147 void     g_input_stream_close_async  (GInputStream          *stream,
148                                       int                    io_priority,
149                                       GCancellable          *cancellable,
150                                       GAsyncReadyCallback    callback,
151                                       gpointer               user_data);
152 gboolean g_input_stream_close_finish (GInputStream          *stream,
153                                       GAsyncResult          *result,
154                                       GError               **error);
155
156 /* For implementations: */
157
158 gboolean g_input_stream_is_closed    (GInputStream          *stream);
159 gboolean g_input_stream_has_pending  (GInputStream          *stream);
160 void     g_input_stream_set_pending  (GInputStream          *stream,
161                                       gboolean               pending);
162
163 G_END_DECLS
164
165 #endif /* __G_INPUT_STREAM_H__ */