goutputstream.h 15 KB

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