gboxed.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* GObject - GLib Type, Object, Parameter and Signal Library
  2. * Copyright (C) 2000-2001 Red Hat, Inc.
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General
  15. * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef __G_BOXED_H__
  18. #define __G_BOXED_H__
  19. #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
  20. #error "Only <glib-object.h> can be included directly."
  21. #endif
  22. #include <gobject/gtype.h>
  23. #ifndef __GI_SCANNER__
  24. #include <gobject/glib-types.h>
  25. #endif
  26. G_BEGIN_DECLS
  27. /* --- type macros --- */
  28. #define G_TYPE_IS_BOXED(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED)
  29. /**
  30. * G_VALUE_HOLDS_BOXED:
  31. * @value: a valid #GValue structure
  32. *
  33. * Checks whether the given #GValue can hold values derived
  34. * from type %G_TYPE_BOXED.
  35. *
  36. * Returns: %TRUE on success.
  37. */
  38. #define G_VALUE_HOLDS_BOXED(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOXED))
  39. /* --- typedefs --- */
  40. /**
  41. * GBoxedCopyFunc:
  42. * @boxed: The boxed structure to be copied.
  43. *
  44. * This function is provided by the user and should produce a copy
  45. * of the passed in boxed structure.
  46. *
  47. * Returns: The newly created copy of the boxed structure.
  48. */
  49. typedef gpointer (*GBoxedCopyFunc) (gpointer boxed);
  50. /**
  51. * GBoxedFreeFunc:
  52. * @boxed: The boxed structure to be freed.
  53. *
  54. * This function is provided by the user and should free the boxed
  55. * structure passed.
  56. */
  57. typedef void (*GBoxedFreeFunc) (gpointer boxed);
  58. /* --- prototypes --- */
  59. GLIB_AVAILABLE_IN_ALL
  60. gpointer g_boxed_copy (GType boxed_type,
  61. gconstpointer src_boxed);
  62. GLIB_AVAILABLE_IN_ALL
  63. void g_boxed_free (GType boxed_type,
  64. gpointer boxed);
  65. GLIB_AVAILABLE_IN_ALL
  66. void g_value_set_boxed (GValue *value,
  67. gconstpointer v_boxed);
  68. GLIB_AVAILABLE_IN_ALL
  69. void g_value_set_static_boxed (GValue *value,
  70. gconstpointer v_boxed);
  71. GLIB_AVAILABLE_IN_ALL
  72. void g_value_take_boxed (GValue *value,
  73. gconstpointer v_boxed);
  74. GLIB_DEPRECATED_FOR(g_value_take_boxed)
  75. void g_value_set_boxed_take_ownership (GValue *value,
  76. gconstpointer v_boxed);
  77. GLIB_AVAILABLE_IN_ALL
  78. gpointer g_value_get_boxed (const GValue *value);
  79. GLIB_AVAILABLE_IN_ALL
  80. gpointer g_value_dup_boxed (const GValue *value);
  81. /* --- convenience --- */
  82. GLIB_AVAILABLE_IN_ALL
  83. GType g_boxed_type_register_static (const gchar *name,
  84. GBoxedCopyFunc boxed_copy,
  85. GBoxedFreeFunc boxed_free);
  86. /* --- GObject boxed types --- */
  87. /**
  88. * G_TYPE_CLOSURE:
  89. *
  90. * The #GType for #GClosure.
  91. */
  92. #define G_TYPE_CLOSURE (g_closure_get_type ())
  93. /**
  94. * G_TYPE_VALUE:
  95. *
  96. * The type ID of the "GValue" type which is a boxed type,
  97. * used to pass around pointers to GValues.
  98. */
  99. #define G_TYPE_VALUE (g_value_get_type ())
  100. GLIB_AVAILABLE_IN_ALL
  101. GType g_closure_get_type (void) G_GNUC_CONST;
  102. GLIB_AVAILABLE_IN_ALL
  103. GType g_value_get_type (void) G_GNUC_CONST;
  104. G_END_DECLS
  105. #endif /* __G_BOXED_H__ */