gbufferedinputstream.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /* GIO - GLib Input, Output and Streaming Library
  2. *
  3. * Copyright (C) 2006-2007 Red Hat, Inc.
  4. *
  5. * SPDX-License-Identifier: LGPL-2.1-or-later
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General
  18. * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  19. *
  20. * Author: Christian Kellner <gicmo@gnome.org>
  21. */
  22. #ifndef __G_BUFFERED_INPUT_STREAM_H__
  23. #define __G_BUFFERED_INPUT_STREAM_H__
  24. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  25. #error "Only <gio/gio.h> can be included directly."
  26. #endif
  27. #include <gio/gfilterinputstream.h>
  28. G_BEGIN_DECLS
  29. #define G_TYPE_BUFFERED_INPUT_STREAM (g_buffered_input_stream_get_type ())
  30. #define G_BUFFERED_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_BUFFERED_INPUT_STREAM, GBufferedInputStream))
  31. #define G_BUFFERED_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_BUFFERED_INPUT_STREAM, GBufferedInputStreamClass))
  32. #define G_IS_BUFFERED_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_BUFFERED_INPUT_STREAM))
  33. #define G_IS_BUFFERED_INPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_BUFFERED_INPUT_STREAM))
  34. #define G_BUFFERED_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_BUFFERED_INPUT_STREAM, GBufferedInputStreamClass))
  35. typedef struct _GBufferedInputStreamClass GBufferedInputStreamClass;
  36. typedef struct _GBufferedInputStreamPrivate GBufferedInputStreamPrivate;
  37. struct _GBufferedInputStream
  38. {
  39. GFilterInputStream parent_instance;
  40. /*< private >*/
  41. GBufferedInputStreamPrivate *priv;
  42. };
  43. struct _GBufferedInputStreamClass
  44. {
  45. GFilterInputStreamClass parent_class;
  46. gssize (* fill) (GBufferedInputStream *stream,
  47. gssize count,
  48. GCancellable *cancellable,
  49. GError **error);
  50. /* Async ops: (optional in derived classes) */
  51. void (* fill_async) (GBufferedInputStream *stream,
  52. gssize count,
  53. int io_priority,
  54. GCancellable *cancellable,
  55. GAsyncReadyCallback callback,
  56. gpointer user_data);
  57. gssize (* fill_finish) (GBufferedInputStream *stream,
  58. GAsyncResult *result,
  59. GError **error);
  60. /*< private >*/
  61. /* Padding for future expansion */
  62. void (*_g_reserved1) (void);
  63. void (*_g_reserved2) (void);
  64. void (*_g_reserved3) (void);
  65. void (*_g_reserved4) (void);
  66. void (*_g_reserved5) (void);
  67. };
  68. GIO_AVAILABLE_IN_ALL
  69. GType g_buffered_input_stream_get_type (void) G_GNUC_CONST;
  70. GIO_AVAILABLE_IN_ALL
  71. GInputStream* g_buffered_input_stream_new (GInputStream *base_stream);
  72. GIO_AVAILABLE_IN_ALL
  73. GInputStream* g_buffered_input_stream_new_sized (GInputStream *base_stream,
  74. gsize size);
  75. GIO_AVAILABLE_IN_ALL
  76. gsize g_buffered_input_stream_get_buffer_size (GBufferedInputStream *stream);
  77. GIO_AVAILABLE_IN_ALL
  78. void g_buffered_input_stream_set_buffer_size (GBufferedInputStream *stream,
  79. gsize size);
  80. GIO_AVAILABLE_IN_ALL
  81. gsize g_buffered_input_stream_get_available (GBufferedInputStream *stream);
  82. GIO_AVAILABLE_IN_ALL
  83. gsize g_buffered_input_stream_peek (GBufferedInputStream *stream,
  84. void *buffer,
  85. gsize offset,
  86. gsize count);
  87. GIO_AVAILABLE_IN_ALL
  88. const void* g_buffered_input_stream_peek_buffer (GBufferedInputStream *stream,
  89. gsize *count);
  90. GIO_AVAILABLE_IN_ALL
  91. gssize g_buffered_input_stream_fill (GBufferedInputStream *stream,
  92. gssize count,
  93. GCancellable *cancellable,
  94. GError **error);
  95. GIO_AVAILABLE_IN_ALL
  96. void g_buffered_input_stream_fill_async (GBufferedInputStream *stream,
  97. gssize count,
  98. int io_priority,
  99. GCancellable *cancellable,
  100. GAsyncReadyCallback callback,
  101. gpointer user_data);
  102. GIO_AVAILABLE_IN_ALL
  103. gssize g_buffered_input_stream_fill_finish (GBufferedInputStream *stream,
  104. GAsyncResult *result,
  105. GError **error);
  106. GIO_AVAILABLE_IN_ALL
  107. int g_buffered_input_stream_read_byte (GBufferedInputStream *stream,
  108. GCancellable *cancellable,
  109. GError **error);
  110. G_END_DECLS
  111. #endif /* __G_BUFFERED_INPUT_STREAM_H__ */