gmemoryoutputstream.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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: Christian Kellner <[email protected]>
  19. */
  20. #ifndef __G_MEMORY_OUTPUT_STREAM_H__
  21. #define __G_MEMORY_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/goutputstream.h>
  26. G_BEGIN_DECLS
  27. #define G_TYPE_MEMORY_OUTPUT_STREAM (g_memory_output_stream_get_type ())
  28. #define G_MEMORY_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_MEMORY_OUTPUT_STREAM, GMemoryOutputStream))
  29. #define G_MEMORY_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_MEMORY_OUTPUT_STREAM, GMemoryOutputStreamClass))
  30. #define G_IS_MEMORY_OUTPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_MEMORY_OUTPUT_STREAM))
  31. #define G_IS_MEMORY_OUTPUT_STREAM_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_MEMORY_OUTPUT_STREAM))
  32. #define G_MEMORY_OUTPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_MEMORY_OUTPUT_STREAM, GMemoryOutputStreamClass))
  33. /**
  34. * GMemoryOutputStream:
  35. *
  36. * Implements #GOutputStream for arbitrary memory chunks.
  37. **/
  38. typedef struct _GMemoryOutputStreamClass GMemoryOutputStreamClass;
  39. typedef struct _GMemoryOutputStreamPrivate GMemoryOutputStreamPrivate;
  40. struct _GMemoryOutputStream
  41. {
  42. GOutputStream parent_instance;
  43. /*< private >*/
  44. GMemoryOutputStreamPrivate *priv;
  45. };
  46. struct _GMemoryOutputStreamClass
  47. {
  48. GOutputStreamClass parent_class;
  49. /*< private >*/
  50. /* Padding for future expansion */
  51. void (*_g_reserved1) (void);
  52. void (*_g_reserved2) (void);
  53. void (*_g_reserved3) (void);
  54. void (*_g_reserved4) (void);
  55. void (*_g_reserved5) (void);
  56. };
  57. /**
  58. * GReallocFunc:
  59. * @data: memory block to reallocate
  60. * @size: size to reallocate @data to
  61. *
  62. * Changes the size of the memory block pointed to by @data to
  63. * @size bytes.
  64. *
  65. * The function should have the same semantics as realloc().
  66. *
  67. * Returns: a pointer to the reallocated memory
  68. */
  69. typedef gpointer (* GReallocFunc) (gpointer data,
  70. gsize size);
  71. GLIB_AVAILABLE_IN_ALL
  72. GType g_memory_output_stream_get_type (void) G_GNUC_CONST;
  73. GLIB_AVAILABLE_IN_ALL
  74. GOutputStream *g_memory_output_stream_new (gpointer data,
  75. gsize size,
  76. GReallocFunc realloc_function,
  77. GDestroyNotify destroy_function);
  78. GLIB_AVAILABLE_IN_2_36
  79. GOutputStream *g_memory_output_stream_new_resizable (void);
  80. GLIB_AVAILABLE_IN_ALL
  81. gpointer g_memory_output_stream_get_data (GMemoryOutputStream *ostream);
  82. GLIB_AVAILABLE_IN_ALL
  83. gsize g_memory_output_stream_get_size (GMemoryOutputStream *ostream);
  84. GLIB_AVAILABLE_IN_ALL
  85. gsize g_memory_output_stream_get_data_size (GMemoryOutputStream *ostream);
  86. GLIB_AVAILABLE_IN_ALL
  87. gpointer g_memory_output_stream_steal_data (GMemoryOutputStream *ostream);
  88. GLIB_AVAILABLE_IN_2_34
  89. GBytes * g_memory_output_stream_steal_as_bytes (GMemoryOutputStream *ostream);
  90. G_END_DECLS
  91. #endif /* __G_MEMORY_OUTPUT_STREAM_H__ */