goutputstream.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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, see <http://www.gnu.org/licenses/>.
  17. *
  18. * Author: Alexander Larsson <[email protected]>
  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. /*< private >*/
  108. /* Padding for future expansion */
  109. void (*_g_reserved1) (void);
  110. void (*_g_reserved2) (void);
  111. void (*_g_reserved3) (void);
  112. void (*_g_reserved4) (void);
  113. void (*_g_reserved5) (void);
  114. void (*_g_reserved6) (void);
  115. void (*_g_reserved7) (void);
  116. void (*_g_reserved8) (void);
  117. };
  118. GLIB_AVAILABLE_IN_ALL
  119. GType g_output_stream_get_type (void) G_GNUC_CONST;
  120. GLIB_AVAILABLE_IN_ALL
  121. gssize g_output_stream_write (GOutputStream *stream,
  122. const void *buffer,
  123. gsize count,
  124. GCancellable *cancellable,
  125. GError **error);
  126. GLIB_AVAILABLE_IN_ALL
  127. gboolean g_output_stream_write_all (GOutputStream *stream,
  128. const void *buffer,
  129. gsize count,
  130. gsize *bytes_written,
  131. GCancellable *cancellable,
  132. GError **error);
  133. GLIB_AVAILABLE_IN_2_40
  134. gboolean g_output_stream_printf (GOutputStream *stream,
  135. gsize *bytes_written,
  136. GCancellable *cancellable,
  137. GError **error,
  138. const gchar *format,
  139. ...) G_GNUC_PRINTF (5, 6);
  140. GLIB_AVAILABLE_IN_2_40
  141. gboolean g_output_stream_vprintf (GOutputStream *stream,
  142. gsize *bytes_written,
  143. GCancellable *cancellable,
  144. GError **error,
  145. const gchar *format,
  146. va_list args) G_GNUC_PRINTF (5, 0);
  147. GLIB_AVAILABLE_IN_2_34
  148. gssize g_output_stream_write_bytes (GOutputStream *stream,
  149. GBytes *bytes,
  150. GCancellable *cancellable,
  151. GError **error);
  152. GLIB_AVAILABLE_IN_ALL
  153. gssize g_output_stream_splice (GOutputStream *stream,
  154. GInputStream *source,
  155. GOutputStreamSpliceFlags flags,
  156. GCancellable *cancellable,
  157. GError **error);
  158. GLIB_AVAILABLE_IN_ALL
  159. gboolean g_output_stream_flush (GOutputStream *stream,
  160. GCancellable *cancellable,
  161. GError **error);
  162. GLIB_AVAILABLE_IN_ALL
  163. gboolean g_output_stream_close (GOutputStream *stream,
  164. GCancellable *cancellable,
  165. GError **error);
  166. GLIB_AVAILABLE_IN_ALL
  167. void g_output_stream_write_async (GOutputStream *stream,
  168. const void *buffer,
  169. gsize count,
  170. int io_priority,
  171. GCancellable *cancellable,
  172. GAsyncReadyCallback callback,
  173. gpointer user_data);
  174. GLIB_AVAILABLE_IN_ALL
  175. gssize g_output_stream_write_finish (GOutputStream *stream,
  176. GAsyncResult *result,
  177. GError **error);
  178. GLIB_AVAILABLE_IN_2_34
  179. void g_output_stream_write_bytes_async (GOutputStream *stream,
  180. GBytes *bytes,
  181. int io_priority,
  182. GCancellable *cancellable,
  183. GAsyncReadyCallback callback,
  184. gpointer user_data);
  185. GLIB_AVAILABLE_IN_2_34
  186. gssize g_output_stream_write_bytes_finish (GOutputStream *stream,
  187. GAsyncResult *result,
  188. GError **error);
  189. GLIB_AVAILABLE_IN_ALL
  190. void g_output_stream_splice_async (GOutputStream *stream,
  191. GInputStream *source,
  192. GOutputStreamSpliceFlags flags,
  193. int io_priority,
  194. GCancellable *cancellable,
  195. GAsyncReadyCallback callback,
  196. gpointer user_data);
  197. GLIB_AVAILABLE_IN_ALL
  198. gssize g_output_stream_splice_finish (GOutputStream *stream,
  199. GAsyncResult *result,
  200. GError **error);
  201. GLIB_AVAILABLE_IN_ALL
  202. void g_output_stream_flush_async (GOutputStream *stream,
  203. int io_priority,
  204. GCancellable *cancellable,
  205. GAsyncReadyCallback callback,
  206. gpointer user_data);
  207. GLIB_AVAILABLE_IN_ALL
  208. gboolean g_output_stream_flush_finish (GOutputStream *stream,
  209. GAsyncResult *result,
  210. GError **error);
  211. GLIB_AVAILABLE_IN_ALL
  212. void g_output_stream_close_async (GOutputStream *stream,
  213. int io_priority,
  214. GCancellable *cancellable,
  215. GAsyncReadyCallback callback,
  216. gpointer user_data);
  217. GLIB_AVAILABLE_IN_ALL
  218. gboolean g_output_stream_close_finish (GOutputStream *stream,
  219. GAsyncResult *result,
  220. GError **error);
  221. GLIB_AVAILABLE_IN_ALL
  222. gboolean g_output_stream_is_closed (GOutputStream *stream);
  223. GLIB_AVAILABLE_IN_ALL
  224. gboolean g_output_stream_is_closing (GOutputStream *stream);
  225. GLIB_AVAILABLE_IN_ALL
  226. gboolean g_output_stream_has_pending (GOutputStream *stream);
  227. GLIB_AVAILABLE_IN_ALL
  228. gboolean g_output_stream_set_pending (GOutputStream *stream,
  229. GError **error);
  230. GLIB_AVAILABLE_IN_ALL
  231. void g_output_stream_clear_pending (GOutputStream *stream);
  232. G_END_DECLS
  233. #endif /* __G_OUTPUT_STREAM_H__ */