ginputstream.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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_INPUT_STREAM_H__
  21. #define __G_INPUT_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_INPUT_STREAM (g_input_stream_get_type ())
  28. #define G_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_INPUT_STREAM, GInputStream))
  29. #define G_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_INPUT_STREAM, GInputStreamClass))
  30. #define G_IS_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_INPUT_STREAM))
  31. #define G_IS_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_INPUT_STREAM))
  32. #define G_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_INPUT_STREAM, GInputStreamClass))
  33. /**
  34. * GInputStream:
  35. *
  36. * Base class for streaming input operations.
  37. **/
  38. typedef struct _GInputStreamClass GInputStreamClass;
  39. typedef struct _GInputStreamPrivate GInputStreamPrivate;
  40. struct _GInputStream
  41. {
  42. GObject parent_instance;
  43. /*< private >*/
  44. GInputStreamPrivate *priv;
  45. };
  46. struct _GInputStreamClass
  47. {
  48. GObjectClass parent_class;
  49. /* Sync ops: */
  50. gssize (* read_fn) (GInputStream *stream,
  51. void *buffer,
  52. gsize count,
  53. GCancellable *cancellable,
  54. GError **error);
  55. gssize (* skip) (GInputStream *stream,
  56. gsize count,
  57. GCancellable *cancellable,
  58. GError **error);
  59. gboolean (* close_fn) (GInputStream *stream,
  60. GCancellable *cancellable,
  61. GError **error);
  62. /* Async ops: (optional in derived classes) */
  63. void (* read_async) (GInputStream *stream,
  64. void *buffer,
  65. gsize count,
  66. int io_priority,
  67. GCancellable *cancellable,
  68. GAsyncReadyCallback callback,
  69. gpointer user_data);
  70. gssize (* read_finish) (GInputStream *stream,
  71. GAsyncResult *result,
  72. GError **error);
  73. void (* skip_async) (GInputStream *stream,
  74. gsize count,
  75. int io_priority,
  76. GCancellable *cancellable,
  77. GAsyncReadyCallback callback,
  78. gpointer user_data);
  79. gssize (* skip_finish) (GInputStream *stream,
  80. GAsyncResult *result,
  81. GError **error);
  82. void (* close_async) (GInputStream *stream,
  83. int io_priority,
  84. GCancellable *cancellable,
  85. GAsyncReadyCallback callback,
  86. gpointer user_data);
  87. gboolean (* close_finish) (GInputStream *stream,
  88. GAsyncResult *result,
  89. GError **error);
  90. /*< private >*/
  91. /* Padding for future expansion */
  92. void (*_g_reserved1) (void);
  93. void (*_g_reserved2) (void);
  94. void (*_g_reserved3) (void);
  95. void (*_g_reserved4) (void);
  96. void (*_g_reserved5) (void);
  97. };
  98. GLIB_AVAILABLE_IN_ALL
  99. GType g_input_stream_get_type (void) G_GNUC_CONST;
  100. GLIB_AVAILABLE_IN_ALL
  101. gssize g_input_stream_read (GInputStream *stream,
  102. void *buffer,
  103. gsize count,
  104. GCancellable *cancellable,
  105. GError **error);
  106. GLIB_AVAILABLE_IN_ALL
  107. gboolean g_input_stream_read_all (GInputStream *stream,
  108. void *buffer,
  109. gsize count,
  110. gsize *bytes_read,
  111. GCancellable *cancellable,
  112. GError **error);
  113. GLIB_AVAILABLE_IN_2_34
  114. GBytes *g_input_stream_read_bytes (GInputStream *stream,
  115. gsize count,
  116. GCancellable *cancellable,
  117. GError **error);
  118. GLIB_AVAILABLE_IN_ALL
  119. gssize g_input_stream_skip (GInputStream *stream,
  120. gsize count,
  121. GCancellable *cancellable,
  122. GError **error);
  123. GLIB_AVAILABLE_IN_ALL
  124. gboolean g_input_stream_close (GInputStream *stream,
  125. GCancellable *cancellable,
  126. GError **error);
  127. GLIB_AVAILABLE_IN_ALL
  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. GLIB_AVAILABLE_IN_ALL
  136. gssize g_input_stream_read_finish (GInputStream *stream,
  137. GAsyncResult *result,
  138. GError **error);
  139. GLIB_AVAILABLE_IN_2_34
  140. void g_input_stream_read_bytes_async (GInputStream *stream,
  141. gsize count,
  142. int io_priority,
  143. GCancellable *cancellable,
  144. GAsyncReadyCallback callback,
  145. gpointer user_data);
  146. GLIB_AVAILABLE_IN_2_34
  147. GBytes *g_input_stream_read_bytes_finish (GInputStream *stream,
  148. GAsyncResult *result,
  149. GError **error);
  150. GLIB_AVAILABLE_IN_ALL
  151. void g_input_stream_skip_async (GInputStream *stream,
  152. gsize count,
  153. int io_priority,
  154. GCancellable *cancellable,
  155. GAsyncReadyCallback callback,
  156. gpointer user_data);
  157. GLIB_AVAILABLE_IN_ALL
  158. gssize g_input_stream_skip_finish (GInputStream *stream,
  159. GAsyncResult *result,
  160. GError **error);
  161. GLIB_AVAILABLE_IN_ALL
  162. void g_input_stream_close_async (GInputStream *stream,
  163. int io_priority,
  164. GCancellable *cancellable,
  165. GAsyncReadyCallback callback,
  166. gpointer user_data);
  167. GLIB_AVAILABLE_IN_ALL
  168. gboolean g_input_stream_close_finish (GInputStream *stream,
  169. GAsyncResult *result,
  170. GError **error);
  171. /* For implementations: */
  172. GLIB_AVAILABLE_IN_ALL
  173. gboolean g_input_stream_is_closed (GInputStream *stream);
  174. GLIB_AVAILABLE_IN_ALL
  175. gboolean g_input_stream_has_pending (GInputStream *stream);
  176. GLIB_AVAILABLE_IN_ALL
  177. gboolean g_input_stream_set_pending (GInputStream *stream,
  178. GError **error);
  179. GLIB_AVAILABLE_IN_ALL
  180. void g_input_stream_clear_pending (GInputStream *stream);
  181. G_END_DECLS
  182. #endif /* __G_INPUT_STREAM_H__ */