Use g_set_error_literal where appropriate. Patch from bug #535947.
[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 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
24 #error "Only <gio/gio.h> can be included directly."
25 #endif
26
27 #ifndef __G_INPUT_STREAM_H__
28 #define __G_INPUT_STREAM_H__
29
30 #include <glib-object.h>
31 #include <gio/gioerror.h>
32 #include <gio/gcancellable.h>
33 #include <gio/gasyncresult.h>
34
35 G_BEGIN_DECLS
36
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))
43
44 /**
45  * GInputStream:
46  * 
47  * Base class for streaming input operations.
48  **/
49 typedef struct _GInputStream         GInputStream;
50 typedef struct _GInputStreamClass    GInputStreamClass;
51 typedef struct _GInputStreamPrivate  GInputStreamPrivate;
52
53 struct _GInputStream
54 {
55   GObject parent_instance;
56
57   /*< private >*/
58   GInputStreamPrivate *priv;
59 };
60
61 struct _GInputStreamClass
62 {
63   GObjectClass parent_class;
64
65   /* Sync ops: */
66   
67   gssize   (* read_fn)     (GInputStream *stream,
68                             void         *buffer,
69                             gsize         count,
70                             GCancellable *cancellable,
71                             GError      **error);
72   gssize   (* skip)        (GInputStream *stream,
73                             gsize         count,
74                             GCancellable *cancellable,
75                             GError      **error);
76   gboolean (* close_fn)    (GInputStream *stream,
77                             GCancellable *cancellable,
78                             GError      **error);
79
80   /* Async ops: (optional in derived classes) */
81   void     (* read_async)  (GInputStream        *stream,
82                             void               *buffer,
83                             gsize               count,
84                             int                 io_priority,
85                             GCancellable       *cancellable,
86                             GAsyncReadyCallback callback,
87                             gpointer            user_data);
88   gssize   (* read_finish) (GInputStream       *stream,
89                             GAsyncResult       *result,
90                             GError            **error);
91   void     (* skip_async)  (GInputStream       *stream,
92                             gsize               count,
93                             int                 io_priority,
94                             GCancellable       *cancellable,
95                             GAsyncReadyCallback callback,
96                             gpointer            user_data);
97   gssize   (* skip_finish) (GInputStream        *stream,
98                             GAsyncResult       *result,
99                             GError            **error);
100   void     (* close_async) (GInputStream        *stream,
101                             int                  io_priority,
102                             GCancellable       *cancellable,
103                             GAsyncReadyCallback callback,
104                             gpointer            user_data);
105   gboolean (* close_finish)(GInputStream        *stream,
106                             GAsyncResult       *result,
107                             GError            **error);
108
109   /*< private >*/
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);
116 };
117
118 GType g_input_stream_get_type (void) G_GNUC_CONST;
119
120 gssize   g_input_stream_read          (GInputStream          *stream,
121                                        void                  *buffer,
122                                        gsize                  count,
123                                        GCancellable          *cancellable,
124                                        GError               **error);
125 gboolean g_input_stream_read_all      (GInputStream          *stream,
126                                        void                  *buffer,
127                                        gsize                  count,
128                                        gsize                 *bytes_read,
129                                        GCancellable          *cancellable,
130                                        GError               **error);
131 gssize   g_input_stream_skip          (GInputStream          *stream,
132                                        gsize                  count,
133                                        GCancellable          *cancellable,
134                                        GError               **error);
135 gboolean g_input_stream_close         (GInputStream          *stream,
136                                        GCancellable          *cancellable,
137                                        GError               **error);
138 void     g_input_stream_read_async    (GInputStream          *stream,
139                                        void                  *buffer,
140                                        gsize                  count,
141                                        int                    io_priority,
142                                        GCancellable          *cancellable,
143                                        GAsyncReadyCallback    callback,
144                                        gpointer               user_data);
145 gssize   g_input_stream_read_finish   (GInputStream          *stream,
146                                        GAsyncResult          *result,
147                                        GError               **error);
148 void     g_input_stream_skip_async    (GInputStream          *stream,
149                                        gsize                  count,
150                                        int                    io_priority,
151                                        GCancellable          *cancellable,
152                                        GAsyncReadyCallback    callback,
153                                        gpointer               user_data);
154 gssize   g_input_stream_skip_finish   (GInputStream          *stream,
155                                        GAsyncResult          *result,
156                                        GError               **error);
157 void     g_input_stream_close_async   (GInputStream          *stream,
158                                        int                    io_priority,
159                                        GCancellable          *cancellable,
160                                        GAsyncReadyCallback    callback,
161                                        gpointer               user_data);
162 gboolean g_input_stream_close_finish  (GInputStream          *stream,
163                                        GAsyncResult          *result,
164                                        GError               **error);
165
166 /* For implementations: */
167
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,
171                                        GError               **error);
172 void     g_input_stream_clear_pending (GInputStream          *stream);
173
174 G_END_DECLS
175
176 #endif /* __G_INPUT_STREAM_H__ */