gvaluetypes.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. /* GObject - GLib Type, Object, Parameter and Signal Library
  2. * Copyright (C) 1997-1999, 2000-2001 Tim Janik and 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. * gvaluetypes.h: GLib default values
  18. */
  19. #ifndef __G_VALUETYPES_H__
  20. #define __G_VALUETYPES_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/gvalue.h>
  25. G_BEGIN_DECLS
  26. /* --- type macros --- */
  27. /**
  28. * G_VALUE_HOLDS_CHAR:
  29. * @value: a valid #GValue structure
  30. *
  31. * Checks whether the given #GValue can hold values of type %G_TYPE_CHAR.
  32. *
  33. * Returns: %TRUE on success.
  34. */
  35. #define G_VALUE_HOLDS_CHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_CHAR))
  36. /**
  37. * G_VALUE_HOLDS_UCHAR:
  38. * @value: a valid #GValue structure
  39. *
  40. * Checks whether the given #GValue can hold values of type %G_TYPE_UCHAR.
  41. *
  42. * Returns: %TRUE on success.
  43. */
  44. #define G_VALUE_HOLDS_UCHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UCHAR))
  45. /**
  46. * G_VALUE_HOLDS_BOOLEAN:
  47. * @value: a valid #GValue structure
  48. *
  49. * Checks whether the given #GValue can hold values of type %G_TYPE_BOOLEAN.
  50. *
  51. * Returns: %TRUE on success.
  52. */
  53. #define G_VALUE_HOLDS_BOOLEAN(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOOLEAN))
  54. /**
  55. * G_VALUE_HOLDS_INT:
  56. * @value: a valid #GValue structure
  57. *
  58. * Checks whether the given #GValue can hold values of type %G_TYPE_INT.
  59. *
  60. * Returns: %TRUE on success.
  61. */
  62. #define G_VALUE_HOLDS_INT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT))
  63. /**
  64. * G_VALUE_HOLDS_UINT:
  65. * @value: a valid #GValue structure
  66. *
  67. * Checks whether the given #GValue can hold values of type %G_TYPE_UINT.
  68. *
  69. * Returns: %TRUE on success.
  70. */
  71. #define G_VALUE_HOLDS_UINT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT))
  72. /**
  73. * G_VALUE_HOLDS_LONG:
  74. * @value: a valid #GValue structure
  75. *
  76. * Checks whether the given #GValue can hold values of type %G_TYPE_LONG.
  77. *
  78. * Returns: %TRUE on success.
  79. */
  80. #define G_VALUE_HOLDS_LONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_LONG))
  81. /**
  82. * G_VALUE_HOLDS_ULONG:
  83. * @value: a valid #GValue structure
  84. *
  85. * Checks whether the given #GValue can hold values of type %G_TYPE_ULONG.
  86. *
  87. * Returns: %TRUE on success.
  88. */
  89. #define G_VALUE_HOLDS_ULONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ULONG))
  90. /**
  91. * G_VALUE_HOLDS_INT64:
  92. * @value: a valid #GValue structure
  93. *
  94. * Checks whether the given #GValue can hold values of type %G_TYPE_INT64.
  95. *
  96. * Returns: %TRUE on success.
  97. */
  98. #define G_VALUE_HOLDS_INT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT64))
  99. /**
  100. * G_VALUE_HOLDS_UINT64:
  101. * @value: a valid #GValue structure
  102. *
  103. * Checks whether the given #GValue can hold values of type %G_TYPE_UINT64.
  104. *
  105. * Returns: %TRUE on success.
  106. */
  107. #define G_VALUE_HOLDS_UINT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT64))
  108. /**
  109. * G_VALUE_HOLDS_FLOAT:
  110. * @value: a valid #GValue structure
  111. *
  112. * Checks whether the given #GValue can hold values of type %G_TYPE_FLOAT.
  113. *
  114. * Returns: %TRUE on success.
  115. */
  116. #define G_VALUE_HOLDS_FLOAT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLOAT))
  117. /**
  118. * G_VALUE_HOLDS_DOUBLE:
  119. * @value: a valid #GValue structure
  120. *
  121. * Checks whether the given #GValue can hold values of type %G_TYPE_DOUBLE.
  122. *
  123. * Returns: %TRUE on success.
  124. */
  125. #define G_VALUE_HOLDS_DOUBLE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_DOUBLE))
  126. /**
  127. * G_VALUE_HOLDS_STRING:
  128. * @value: a valid #GValue structure
  129. *
  130. * Checks whether the given #GValue can hold values of type %G_TYPE_STRING.
  131. *
  132. * Returns: %TRUE on success.
  133. */
  134. #define G_VALUE_HOLDS_STRING(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_STRING))
  135. /**
  136. * G_VALUE_HOLDS_POINTER:
  137. * @value: a valid #GValue structure
  138. *
  139. * Checks whether the given #GValue can hold values of type %G_TYPE_POINTER.
  140. *
  141. * Returns: %TRUE on success.
  142. */
  143. #define G_VALUE_HOLDS_POINTER(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_POINTER))
  144. /**
  145. * G_TYPE_GTYPE:
  146. *
  147. * The type for #GType.
  148. */
  149. #define G_TYPE_GTYPE (g_gtype_get_type())
  150. /**
  151. * G_VALUE_HOLDS_GTYPE:
  152. * @value: a valid #GValue structure
  153. *
  154. * Checks whether the given #GValue can hold values of type %G_TYPE_GTYPE.
  155. *
  156. * Since: 2.12
  157. * Returns: %TRUE on success.
  158. */
  159. #define G_VALUE_HOLDS_GTYPE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_GTYPE))
  160. /**
  161. * G_VALUE_HOLDS_VARIANT:
  162. * @value: a valid #GValue structure
  163. *
  164. * Checks whether the given #GValue can hold values of type %G_TYPE_VARIANT.
  165. *
  166. * Returns: %TRUE on success.
  167. *
  168. * Since: 2.26
  169. */
  170. #define G_VALUE_HOLDS_VARIANT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_VARIANT))
  171. /* --- prototypes --- */
  172. GLIB_DEPRECATED_IN_2_32_FOR(g_value_set_schar)
  173. void g_value_set_char (GValue *value,
  174. gchar v_char);
  175. GLIB_DEPRECATED_IN_2_32_FOR(g_value_get_schar)
  176. gchar g_value_get_char (const GValue *value);
  177. GLIB_AVAILABLE_IN_ALL
  178. void g_value_set_schar (GValue *value,
  179. gint8 v_char);
  180. GLIB_AVAILABLE_IN_ALL
  181. gint8 g_value_get_schar (const GValue *value);
  182. GLIB_AVAILABLE_IN_ALL
  183. void g_value_set_uchar (GValue *value,
  184. guchar v_uchar);
  185. GLIB_AVAILABLE_IN_ALL
  186. guchar g_value_get_uchar (const GValue *value);
  187. GLIB_AVAILABLE_IN_ALL
  188. void g_value_set_boolean (GValue *value,
  189. gboolean v_boolean);
  190. GLIB_AVAILABLE_IN_ALL
  191. gboolean g_value_get_boolean (const GValue *value);
  192. GLIB_AVAILABLE_IN_ALL
  193. void g_value_set_int (GValue *value,
  194. gint v_int);
  195. GLIB_AVAILABLE_IN_ALL
  196. gint g_value_get_int (const GValue *value);
  197. GLIB_AVAILABLE_IN_ALL
  198. void g_value_set_uint (GValue *value,
  199. guint v_uint);
  200. GLIB_AVAILABLE_IN_ALL
  201. guint g_value_get_uint (const GValue *value);
  202. GLIB_AVAILABLE_IN_ALL
  203. void g_value_set_long (GValue *value,
  204. glong v_long);
  205. GLIB_AVAILABLE_IN_ALL
  206. glong g_value_get_long (const GValue *value);
  207. GLIB_AVAILABLE_IN_ALL
  208. void g_value_set_ulong (GValue *value,
  209. gulong v_ulong);
  210. GLIB_AVAILABLE_IN_ALL
  211. gulong g_value_get_ulong (const GValue *value);
  212. GLIB_AVAILABLE_IN_ALL
  213. void g_value_set_int64 (GValue *value,
  214. gint64 v_int64);
  215. GLIB_AVAILABLE_IN_ALL
  216. gint64 g_value_get_int64 (const GValue *value);
  217. GLIB_AVAILABLE_IN_ALL
  218. void g_value_set_uint64 (GValue *value,
  219. guint64 v_uint64);
  220. GLIB_AVAILABLE_IN_ALL
  221. guint64 g_value_get_uint64 (const GValue *value);
  222. GLIB_AVAILABLE_IN_ALL
  223. void g_value_set_float (GValue *value,
  224. gfloat v_float);
  225. GLIB_AVAILABLE_IN_ALL
  226. gfloat g_value_get_float (const GValue *value);
  227. GLIB_AVAILABLE_IN_ALL
  228. void g_value_set_double (GValue *value,
  229. gdouble v_double);
  230. GLIB_AVAILABLE_IN_ALL
  231. gdouble g_value_get_double (const GValue *value);
  232. GLIB_AVAILABLE_IN_ALL
  233. void g_value_set_string (GValue *value,
  234. const gchar *v_string);
  235. GLIB_AVAILABLE_IN_ALL
  236. void g_value_set_static_string (GValue *value,
  237. const gchar *v_string);
  238. GLIB_AVAILABLE_IN_ALL
  239. const gchar * g_value_get_string (const GValue *value);
  240. GLIB_AVAILABLE_IN_ALL
  241. gchar* g_value_dup_string (const GValue *value);
  242. GLIB_AVAILABLE_IN_ALL
  243. void g_value_set_pointer (GValue *value,
  244. gpointer v_pointer);
  245. GLIB_AVAILABLE_IN_ALL
  246. gpointer g_value_get_pointer (const GValue *value);
  247. GLIB_AVAILABLE_IN_ALL
  248. GType g_gtype_get_type (void);
  249. GLIB_AVAILABLE_IN_ALL
  250. void g_value_set_gtype (GValue *value,
  251. GType v_gtype);
  252. GLIB_AVAILABLE_IN_ALL
  253. GType g_value_get_gtype (const GValue *value);
  254. GLIB_AVAILABLE_IN_ALL
  255. void g_value_set_variant (GValue *value,
  256. GVariant *variant);
  257. GLIB_AVAILABLE_IN_ALL
  258. void g_value_take_variant (GValue *value,
  259. GVariant *variant);
  260. GLIB_AVAILABLE_IN_ALL
  261. GVariant* g_value_get_variant (const GValue *value);
  262. GLIB_AVAILABLE_IN_ALL
  263. GVariant* g_value_dup_variant (const GValue *value);
  264. /* Convenience for registering new pointer types */
  265. GLIB_AVAILABLE_IN_ALL
  266. GType g_pointer_type_register_static (const gchar *name);
  267. /* debugging aid, describe value contents as string */
  268. GLIB_AVAILABLE_IN_ALL
  269. gchar* g_strdup_value_contents (const GValue *value);
  270. GLIB_AVAILABLE_IN_ALL
  271. void g_value_take_string (GValue *value,
  272. gchar *v_string);
  273. GLIB_DEPRECATED_FOR(g_value_take_string)
  274. void g_value_set_string_take_ownership (GValue *value,
  275. gchar *v_string);
  276. /* humpf, need a C representable type name for G_TYPE_STRING */
  277. /**
  278. * gchararray:
  279. *
  280. * A C representable type name for #G_TYPE_STRING.
  281. */
  282. typedef gchar* gchararray;
  283. G_END_DECLS
  284. #endif /* __G_VALUETYPES_H__ */