Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

160 řádky
4.6 KiB

  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, write to the
  16. * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  17. * Boston, MA 02111-1307, USA.
  18. *
  19. * gvalue.h: generic GValue functions
  20. */
  21. #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
  22. #error "Only <glib-object.h> can be included directly."
  23. #endif
  24. #ifndef __G_VALUE_H__
  25. #define __G_VALUE_H__
  26. #include <gobject/gtype.h>
  27. G_BEGIN_DECLS
  28. /* --- type macros --- */
  29. /**
  30. * G_TYPE_IS_VALUE:
  31. * @type: A #GType value.
  32. *
  33. * Checks whether the passed in type ID can be used for g_value_init().
  34. * That is, this macro checks whether this type provides an implementation
  35. * of the #GTypeValueTable functions required for a type to create a #GValue of.
  36. *
  37. * Returns: Whether @type is suitable as a #GValue type.
  38. */
  39. #define G_TYPE_IS_VALUE(type) (g_type_check_is_value_type (type))
  40. /**
  41. * G_IS_VALUE:
  42. * @value: A #GValue structure.
  43. *
  44. * Checks if @value is a valid and initialized #GValue structure.
  45. *
  46. * Returns: %TRUE on success.
  47. */
  48. #define G_IS_VALUE(value) (G_TYPE_CHECK_VALUE (value))
  49. /**
  50. * G_VALUE_TYPE:
  51. * @value: A #GValue structure.
  52. *
  53. * Get the type identifier of @value.
  54. *
  55. * Returns: the #GType.
  56. */
  57. #define G_VALUE_TYPE(value) (((GValue*) (value))->g_type)
  58. /**
  59. * G_VALUE_TYPE_NAME:
  60. * @value: A #GValue structure.
  61. *
  62. * Gets the the type name of @value.
  63. *
  64. * Returns: the type name.
  65. */
  66. #define G_VALUE_TYPE_NAME(value) (g_type_name (G_VALUE_TYPE (value)))
  67. /**
  68. * G_VALUE_HOLDS:
  69. * @value: A #GValue structure.
  70. * @type: A #GType value.
  71. *
  72. * Checks if @value holds (or contains) a value of @type.
  73. * This macro will also check for @value != %NULL and issue a
  74. * warning if the check fails.
  75. *
  76. * Returns: %TRUE if @value holds the @type.
  77. */
  78. #define G_VALUE_HOLDS(value,type) (G_TYPE_CHECK_VALUE_TYPE ((value), (type)))
  79. /* --- typedefs & structures --- */
  80. /**
  81. * GValueTransform:
  82. * @src_value: Source value.
  83. * @dest_value: Target value.
  84. *
  85. * The type of value transformation functions which can be registered with
  86. * g_value_register_transform_func().
  87. */
  88. typedef void (*GValueTransform) (const GValue *src_value,
  89. GValue *dest_value);
  90. /**
  91. * GValue:
  92. *
  93. * An opaque structure used to hold different types of values.
  94. * The data within the structure has protected scope: it is accessible only
  95. * to functions within a #GTypeValueTable structure, or implementations of
  96. * the g_value_*() API. That is, code portions which implement new fundamental
  97. * types.
  98. * #GValue users can not make any assumptions about how data is stored
  99. * within the 2 element @data union, and the @g_type member should
  100. * only be accessed through the G_VALUE_TYPE() macro.
  101. */
  102. struct _GValue
  103. {
  104. /*< private >*/
  105. GType g_type;
  106. /* public for GTypeValueTable methods */
  107. union {
  108. gint v_int;
  109. guint v_uint;
  110. glong v_long;
  111. gulong v_ulong;
  112. gint64 v_int64;
  113. guint64 v_uint64;
  114. gfloat v_float;
  115. gdouble v_double;
  116. gpointer v_pointer;
  117. } data[2];
  118. };
  119. /* --- prototypes --- */
  120. GValue* g_value_init (GValue *value,
  121. GType g_type);
  122. void g_value_copy (const GValue *src_value,
  123. GValue *dest_value);
  124. GValue* g_value_reset (GValue *value);
  125. void g_value_unset (GValue *value);
  126. void g_value_set_instance (GValue *value,
  127. gpointer instance);
  128. /* --- private --- */
  129. gboolean g_value_fits_pointer (const GValue *value);
  130. gpointer g_value_peek_pointer (const GValue *value);
  131. /* --- implementation details --- */
  132. gboolean g_value_type_compatible (GType src_type,
  133. GType dest_type);
  134. gboolean g_value_type_transformable (GType src_type,
  135. GType dest_type);
  136. gboolean g_value_transform (const GValue *src_value,
  137. GValue *dest_value);
  138. void g_value_register_transform_func (GType src_type,
  139. GType dest_type,
  140. GValueTransform transform_func);
  141. #define G_VALUE_NOCOPY_CONTENTS (1 << 27)
  142. G_END_DECLS
  143. #endif /* __G_VALUE_H__ */