gboxed.h 4.0 KB

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