You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

249 lines
6.6 KiB

  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, write to the
  16. * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  17. * Boston, MA 02111-1307, USA.
  18. */
  19. #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
  20. #error "Only <glib-object.h> can be included directly."
  21. #endif
  22. #ifndef __G_BOXED_H__
  23. #define __G_BOXED_H__
  24. #include <gobject/gtype.h>
  25. G_BEGIN_DECLS
  26. /* --- type macros --- */
  27. #define G_TYPE_IS_BOXED(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED)
  28. /**
  29. * G_VALUE_HOLDS_BOXED:
  30. * @value: a valid #GValue structure
  31. *
  32. * Checks whether the given #GValue can hold values derived from type %G_TYPE_BOXED.
  33. *
  34. * Returns: %TRUE on success.
  35. */
  36. #define G_VALUE_HOLDS_BOXED(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOXED))
  37. /* --- typedefs --- */
  38. /**
  39. * GBoxedCopyFunc:
  40. * @boxed: The boxed structure to be copied.
  41. *
  42. * This function is provided by the user and should produce a copy of the passed
  43. * in boxed structure.
  44. *
  45. * Returns: The newly created copy of the boxed structure.
  46. */
  47. typedef gpointer (*GBoxedCopyFunc) (gpointer boxed);
  48. /**
  49. * GBoxedFreeFunc:
  50. * @boxed: The boxed structure to be freed.
  51. *
  52. * This function is provided by the user and should free the boxed
  53. * structure passed.
  54. */
  55. typedef void (*GBoxedFreeFunc) (gpointer boxed);
  56. /* --- prototypes --- */
  57. gpointer g_boxed_copy (GType boxed_type,
  58. gconstpointer src_boxed);
  59. void g_boxed_free (GType boxed_type,
  60. gpointer boxed);
  61. void g_value_set_boxed (GValue *value,
  62. gconstpointer v_boxed);
  63. void g_value_set_static_boxed (GValue *value,
  64. gconstpointer v_boxed);
  65. gpointer g_value_get_boxed (const GValue *value);
  66. gpointer g_value_dup_boxed (const GValue *value);
  67. /* --- convenience --- */
  68. GType g_boxed_type_register_static (const gchar *name,
  69. GBoxedCopyFunc boxed_copy,
  70. GBoxedFreeFunc boxed_free);
  71. /* --- GLib boxed types --- */
  72. /**
  73. * G_TYPE_CLOSURE:
  74. *
  75. * The #GType for #GClosure.
  76. */
  77. #define G_TYPE_CLOSURE (g_closure_get_type ())
  78. /**
  79. * G_TYPE_VALUE:
  80. *
  81. * The type ID of the "GValue" type which is a boxed type,
  82. * used to pass around pointers to GValues.
  83. */
  84. #define G_TYPE_VALUE (g_value_get_type ())
  85. /**
  86. * G_TYPE_VALUE_ARRAY:
  87. *
  88. * The type ID of the "GValueArray" type which is a boxed type,
  89. * used to pass around pointers to GValueArrays.
  90. */
  91. #define G_TYPE_VALUE_ARRAY (g_value_array_get_type ())
  92. /**
  93. * G_TYPE_DATE:
  94. *
  95. * The #GType for #GDate.
  96. */
  97. #define G_TYPE_DATE (g_date_get_type ())
  98. /**
  99. * G_TYPE_STRV:
  100. *
  101. * The #GType for a boxed type holding a %NULL-terminated array of strings.
  102. *
  103. * The code fragments in the following example show the use of a property of
  104. * type #G_TYPE_STRV with g_object_class_install_property(), g_object_set()
  105. * and g_object_get().
  106. *
  107. * |[
  108. * g_object_class_install_property (object_class,
  109. * PROP_AUTHORS,
  110. * g_param_spec_boxed ("authors",
  111. * _("Authors"),
  112. * _("List of authors"),
  113. * G_TYPE_STRV,
  114. * G_PARAM_READWRITE));
  115. *
  116. *
  117. * gchar *authors[] = { "Owen", "Tim", NULL };
  118. * g_object_set (obj, "authors", authors, NULL);
  119. *
  120. *
  121. * gchar *writers[];
  122. * g_object_get (obj, "authors", &writers, NULL);
  123. * // do something with writers
  124. * g_strfreev (writers);
  125. * ]|
  126. *
  127. * Since: 2.4
  128. */
  129. #define G_TYPE_STRV (g_strv_get_type ())
  130. /**
  131. * G_TYPE_GSTRING:
  132. *
  133. * The #GType for #GString.
  134. */
  135. #define G_TYPE_GSTRING (g_gstring_get_type ())
  136. /**
  137. * G_TYPE_HASH_TABLE:
  138. *
  139. * The #GType for a boxed type holding a #GHashTable reference.
  140. *
  141. * Since: 2.10
  142. */
  143. #define G_TYPE_HASH_TABLE (g_hash_table_get_type ())
  144. /**
  145. * G_TYPE_REGEX:
  146. *
  147. * The #GType for a boxed type holding a #GRegex reference.
  148. *
  149. * Since: 2.14
  150. */
  151. #define G_TYPE_REGEX (g_regex_get_type ())
  152. /**
  153. * G_TYPE_ARRAY:
  154. *
  155. * The #GType for a boxed type holding a #GArray reference.
  156. *
  157. * Since: 2.22
  158. */
  159. #define G_TYPE_ARRAY (g_array_get_type ())
  160. /**
  161. * G_TYPE_BYTE_ARRAY:
  162. *
  163. * The #GType for a boxed type holding a #GByteArray reference.
  164. *
  165. * Since: 2.22
  166. */
  167. #define G_TYPE_BYTE_ARRAY (g_byte_array_get_type ())
  168. /**
  169. * G_TYPE_PTR_ARRAY:
  170. *
  171. * The #GType for a boxed type holding a #GPtrArray reference.
  172. *
  173. * Since: 2.22
  174. */
  175. #define G_TYPE_PTR_ARRAY (g_ptr_array_get_type ())
  176. /**
  177. * G_TYPE_VARIANT_TYPE:
  178. *
  179. * The #GType for a boxed type holding a #GVariantType.
  180. *
  181. * Since: 2.24
  182. */
  183. #define G_TYPE_VARIANT_TYPE (g_variant_type_get_gtype ())
  184. /**
  185. * G_TYPE_ERROR:
  186. *
  187. * The #GType for a boxed type holding a #GError.
  188. *
  189. * Since: 2.26
  190. */
  191. #define G_TYPE_ERROR (g_error_get_type ())
  192. /**
  193. * G_TYPE_DATE_TIME:
  194. *
  195. * The #GType for a boxed type holding a #GDateTime.
  196. *
  197. * Since: 2.26
  198. */
  199. #define G_TYPE_DATE_TIME (g_date_time_get_type ())
  200. void g_value_take_boxed (GValue *value,
  201. gconstpointer v_boxed);
  202. #ifndef G_DISABLE_DEPRECATED
  203. void g_value_set_boxed_take_ownership (GValue *value,
  204. gconstpointer v_boxed);
  205. #endif
  206. GType g_closure_get_type (void) G_GNUC_CONST;
  207. GType g_value_get_type (void) G_GNUC_CONST;
  208. GType g_value_array_get_type (void) G_GNUC_CONST;
  209. GType g_date_get_type (void) G_GNUC_CONST;
  210. GType g_strv_get_type (void) G_GNUC_CONST;
  211. GType g_gstring_get_type (void) G_GNUC_CONST;
  212. GType g_hash_table_get_type (void) G_GNUC_CONST;
  213. GType g_array_get_type (void) G_GNUC_CONST;
  214. GType g_byte_array_get_type (void) G_GNUC_CONST;
  215. GType g_ptr_array_get_type (void) G_GNUC_CONST;
  216. GType g_variant_type_get_gtype(void) G_GNUC_CONST;
  217. GType g_regex_get_type (void) G_GNUC_CONST;
  218. GType g_error_get_type (void) G_GNUC_CONST;
  219. GType g_date_time_get_type (void) G_GNUC_CONST;
  220. #ifndef G_DISABLE_DEPRECATED
  221. GType g_variant_get_gtype (void) G_GNUC_CONST;
  222. #endif
  223. /**
  224. * GStrv:
  225. *
  226. * A C representable type name for #G_TYPE_STRV.
  227. */
  228. typedef gchar** GStrv;
  229. G_END_DECLS
  230. #endif /* __G_BOXED_H__ */