GApplication: add --gapplication-service switch
[platform/upstream/glib.git] / gio / goutputstream.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_OUTPUT_STREAM_H__
24 #define __G_OUTPUT_STREAM_H__
25
26 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
27 #error "Only <gio/gio.h> can be included directly."
28 #endif
29
30 #include <gio/giotypes.h>
31
32 G_BEGIN_DECLS
33
34 #define G_TYPE_OUTPUT_STREAM         (g_output_stream_get_type ())
35 #define G_OUTPUT_STREAM(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_OUTPUT_STREAM, GOutputStream))
36 #define G_OUTPUT_STREAM_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_OUTPUT_STREAM, GOutputStreamClass))
37 #define G_IS_OUTPUT_STREAM(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_OUTPUT_STREAM))
38 #define G_IS_OUTPUT_STREAM_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_OUTPUT_STREAM))
39 #define G_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_OUTPUT_STREAM, GOutputStreamClass))
40
41 /**
42  * GOutputStream:
43  *
44  * Base class for writing output.
45  *
46  * All classes derived from GOutputStream should implement synchronous
47  * writing, splicing, flushing and closing streams, but may implement
48  * asynchronous versions.
49  **/
50 typedef struct _GOutputStreamClass    GOutputStreamClass;
51 typedef struct _GOutputStreamPrivate  GOutputStreamPrivate;
52
53 struct _GOutputStream
54 {
55   GObject parent_instance;
56
57   /*< private >*/
58   GOutputStreamPrivate *priv;
59 };
60
61
62 struct _GOutputStreamClass
63 {
64   GObjectClass parent_class;
65
66   /* Sync ops: */
67
68   gssize      (* write_fn)      (GOutputStream            *stream,
69                                  const void               *buffer,
70                                  gsize                     count,
71                                  GCancellable             *cancellable,
72                                  GError                  **error);
73   gssize      (* splice)        (GOutputStream            *stream,
74                                  GInputStream             *source,
75                                  GOutputStreamSpliceFlags  flags,
76                                  GCancellable             *cancellable,
77                                  GError                  **error);
78   gboolean    (* flush)         (GOutputStream            *stream,
79                                  GCancellable             *cancellable,
80                                  GError                  **error);
81   gboolean    (* close_fn)      (GOutputStream            *stream,
82                                  GCancellable             *cancellable,
83                                  GError                  **error);
84
85   /* Async ops: (optional in derived classes) */
86
87   void        (* write_async)   (GOutputStream            *stream,
88                                  const void               *buffer,
89                                  gsize                     count,
90                                  int                       io_priority,
91                                  GCancellable             *cancellable,
92                                  GAsyncReadyCallback       callback,
93                                  gpointer                  user_data);
94   gssize      (* write_finish)  (GOutputStream            *stream,
95                                  GAsyncResult             *result,
96                                  GError                  **error);
97   void        (* splice_async)  (GOutputStream            *stream,
98                                  GInputStream             *source,
99                                  GOutputStreamSpliceFlags  flags,
100                                  int                       io_priority,
101                                  GCancellable             *cancellable,
102                                  GAsyncReadyCallback       callback,
103                                  gpointer                  user_data);
104   gssize      (* splice_finish) (GOutputStream            *stream,
105                                  GAsyncResult             *result,
106                                  GError                  **error);
107   void        (* flush_async)   (GOutputStream            *stream,
108                                  int                       io_priority,
109                                  GCancellable             *cancellable,
110                                  GAsyncReadyCallback       callback,
111                                  gpointer                  user_data);
112   gboolean    (* flush_finish)  (GOutputStream            *stream,
113                                  GAsyncResult             *result,
114                                  GError                  **error);
115   void        (* close_async)   (GOutputStream            *stream,
116                                  int                       io_priority,
117                                  GCancellable             *cancellable,
118                                  GAsyncReadyCallback       callback,
119                                  gpointer                  user_data);
120   gboolean    (* close_finish)  (GOutputStream            *stream,
121                                  GAsyncResult             *result,
122                                  GError                  **error);
123
124   /*< private >*/
125   /* Padding for future expansion */
126   void (*_g_reserved1) (void);
127   void (*_g_reserved2) (void);
128   void (*_g_reserved3) (void);
129   void (*_g_reserved4) (void);
130   void (*_g_reserved5) (void);
131   void (*_g_reserved6) (void);
132   void (*_g_reserved7) (void);
133   void (*_g_reserved8) (void);
134 };
135
136 GLIB_AVAILABLE_IN_ALL
137 GType    g_output_stream_get_type      (void) G_GNUC_CONST;
138
139 GLIB_AVAILABLE_IN_ALL
140 gssize   g_output_stream_write         (GOutputStream             *stream,
141                                         const void                *buffer,
142                                         gsize                      count,
143                                         GCancellable              *cancellable,
144                                         GError                   **error);
145 GLIB_AVAILABLE_IN_ALL
146 gboolean g_output_stream_write_all     (GOutputStream             *stream,
147                                         const void                *buffer,
148                                         gsize                      count,
149                                         gsize                     *bytes_written,
150                                         GCancellable              *cancellable,
151                                         GError                   **error);
152 GLIB_AVAILABLE_IN_2_40
153 gboolean g_output_stream_printf        (GOutputStream             *stream,
154                                         gsize                     *bytes_written,
155                                         GCancellable              *cancellable,
156                                         GError                   **error,
157                                         const gchar               *format,
158                                         ...) G_GNUC_PRINTF (5, 6);
159 GLIB_AVAILABLE_IN_2_40
160 gboolean g_output_stream_vprintf       (GOutputStream             *stream,
161                                         gsize                     *bytes_written,
162                                         GCancellable              *cancellable,
163                                         GError                   **error,
164                                         const gchar               *format,
165                                         va_list                    args) G_GNUC_PRINTF (5, 0);
166 GLIB_AVAILABLE_IN_2_34
167 gssize   g_output_stream_write_bytes   (GOutputStream             *stream,
168                                         GBytes                    *bytes,
169                                         GCancellable              *cancellable,
170                                         GError                   **error);
171 GLIB_AVAILABLE_IN_ALL
172 gssize   g_output_stream_splice        (GOutputStream             *stream,
173                                         GInputStream              *source,
174                                         GOutputStreamSpliceFlags   flags,
175                                         GCancellable              *cancellable,
176                                         GError                   **error);
177 GLIB_AVAILABLE_IN_ALL
178 gboolean g_output_stream_flush         (GOutputStream             *stream,
179                                         GCancellable              *cancellable,
180                                         GError                   **error);
181 GLIB_AVAILABLE_IN_ALL
182 gboolean g_output_stream_close         (GOutputStream             *stream,
183                                         GCancellable              *cancellable,
184                                         GError                   **error);
185 GLIB_AVAILABLE_IN_ALL
186 void     g_output_stream_write_async   (GOutputStream             *stream,
187                                         const void                *buffer,
188                                         gsize                      count,
189                                         int                        io_priority,
190                                         GCancellable              *cancellable,
191                                         GAsyncReadyCallback        callback,
192                                         gpointer                   user_data);
193 GLIB_AVAILABLE_IN_ALL
194 gssize   g_output_stream_write_finish  (GOutputStream             *stream,
195                                         GAsyncResult              *result,
196                                         GError                   **error);
197 GLIB_AVAILABLE_IN_2_34
198 void     g_output_stream_write_bytes_async  (GOutputStream             *stream,
199                                              GBytes                    *bytes,
200                                              int                        io_priority,
201                                              GCancellable              *cancellable,
202                                              GAsyncReadyCallback        callback,
203                                              gpointer                   user_data);
204 GLIB_AVAILABLE_IN_2_34
205 gssize   g_output_stream_write_bytes_finish (GOutputStream             *stream,
206                                              GAsyncResult              *result,
207                                              GError                   **error);
208 GLIB_AVAILABLE_IN_ALL
209 void     g_output_stream_splice_async  (GOutputStream             *stream,
210                                         GInputStream              *source,
211                                         GOutputStreamSpliceFlags   flags,
212                                         int                        io_priority,
213                                         GCancellable              *cancellable,
214                                         GAsyncReadyCallback        callback,
215                                         gpointer                   user_data);
216 GLIB_AVAILABLE_IN_ALL
217 gssize   g_output_stream_splice_finish (GOutputStream             *stream,
218                                         GAsyncResult              *result,
219                                         GError                   **error);
220 GLIB_AVAILABLE_IN_ALL
221 void     g_output_stream_flush_async   (GOutputStream             *stream,
222                                         int                        io_priority,
223                                         GCancellable              *cancellable,
224                                         GAsyncReadyCallback        callback,
225                                         gpointer                   user_data);
226 GLIB_AVAILABLE_IN_ALL
227 gboolean g_output_stream_flush_finish  (GOutputStream             *stream,
228                                         GAsyncResult              *result,
229                                         GError                   **error);
230 GLIB_AVAILABLE_IN_ALL
231 void     g_output_stream_close_async   (GOutputStream             *stream,
232                                         int                        io_priority,
233                                         GCancellable              *cancellable,
234                                         GAsyncReadyCallback        callback,
235                                         gpointer                   user_data);
236 GLIB_AVAILABLE_IN_ALL
237 gboolean g_output_stream_close_finish  (GOutputStream             *stream,
238                                         GAsyncResult              *result,
239                                         GError                   **error);
240
241 GLIB_AVAILABLE_IN_ALL
242 gboolean g_output_stream_is_closed     (GOutputStream             *stream);
243 GLIB_AVAILABLE_IN_ALL
244 gboolean g_output_stream_is_closing    (GOutputStream             *stream);
245 GLIB_AVAILABLE_IN_ALL
246 gboolean g_output_stream_has_pending   (GOutputStream             *stream);
247 GLIB_AVAILABLE_IN_ALL
248 gboolean g_output_stream_set_pending   (GOutputStream             *stream,
249                                         GError                   **error);
250 GLIB_AVAILABLE_IN_ALL
251 void     g_output_stream_clear_pending (GOutputStream             *stream);
252
253
254 G_END_DECLS
255
256 #endif /* __G_OUTPUT_STREAM_H__ */