|
|
|||
File indexing completed on 2025-12-16 10:17:40
0001 /* GObject - GLib Type, Object, Parameter and Signal Library 0002 * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc. 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-or-later 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Lesser General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2.1 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Lesser General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Lesser General 0017 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>. 0018 * 0019 * gvalue.h: generic GValue functions 0020 */ 0021 #ifndef __G_VALUE_H__ 0022 #define __G_VALUE_H__ 0023 0024 #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) 0025 #error "Only <glib-object.h> can be included directly." 0026 #endif 0027 0028 #include <gobject/gtype.h> 0029 0030 G_BEGIN_DECLS 0031 0032 /* --- type macros --- */ 0033 /** 0034 * G_TYPE_IS_VALUE: 0035 * @type: A #GType value. 0036 * 0037 * Checks whether the passed in type ID can be used for g_value_init(). 0038 * 0039 * That is, this macro checks whether this type provides an implementation 0040 * of the #GTypeValueTable functions required for a type to create a #GValue of. 0041 * 0042 * Returns: Whether @type is suitable as a #GValue type. 0043 */ 0044 #define G_TYPE_IS_VALUE(type) (g_type_check_is_value_type (type)) 0045 /** 0046 * G_IS_VALUE: 0047 * @value: A #GValue structure. 0048 * 0049 * Checks if @value is a valid and initialized #GValue structure. 0050 * 0051 * Returns: %TRUE on success. 0052 */ 0053 #define G_IS_VALUE(value) (G_TYPE_CHECK_VALUE (value)) 0054 /** 0055 * G_VALUE_TYPE: 0056 * @value: A #GValue structure. 0057 * 0058 * Get the type identifier of @value. 0059 * 0060 * Returns: the #GType. 0061 */ 0062 #define G_VALUE_TYPE(value) (((GValue*) (value))->g_type) 0063 /** 0064 * G_VALUE_TYPE_NAME: 0065 * @value: A #GValue structure. 0066 * 0067 * Gets the type name of @value. 0068 * 0069 * Returns: the type name. 0070 */ 0071 #define G_VALUE_TYPE_NAME(value) (g_type_name (G_VALUE_TYPE (value))) 0072 /** 0073 * G_VALUE_HOLDS: 0074 * @value: A #GValue structure. 0075 * @type: A #GType value. 0076 * 0077 * Checks if @value holds (or contains) a value of @type. 0078 * This macro will also check for @value != %NULL and issue a 0079 * warning if the check fails. 0080 * 0081 * Returns: %TRUE if @value holds the @type. 0082 */ 0083 #define G_VALUE_HOLDS(value,type) (G_TYPE_CHECK_VALUE_TYPE ((value), (type))) 0084 0085 0086 /* --- typedefs & structures --- */ 0087 /** 0088 * GValueTransform: 0089 * @src_value: Source value. 0090 * @dest_value: Target value. 0091 * 0092 * The type of value transformation functions which can be registered with 0093 * g_value_register_transform_func(). 0094 * 0095 * @dest_value will be initialized to the correct destination type. 0096 */ 0097 typedef void (*GValueTransform) (const GValue *src_value, 0098 GValue *dest_value); 0099 /** 0100 * GValue: 0101 * 0102 * An opaque structure used to hold different types of values. 0103 * 0104 * The data within the structure has protected scope: it is accessible only 0105 * to functions within a #GTypeValueTable structure, or implementations of 0106 * the g_value_*() API. That is, code portions which implement new fundamental 0107 * types. 0108 * 0109 * #GValue users cannot make any assumptions about how data is stored 0110 * within the 2 element @data union, and the @g_type member should 0111 * only be accessed through the G_VALUE_TYPE() macro. 0112 */ 0113 struct _GValue 0114 { 0115 /*< private >*/ 0116 GType g_type; 0117 0118 /* public for GTypeValueTable methods */ 0119 union { 0120 gint v_int; 0121 guint v_uint; 0122 glong v_long; 0123 gulong v_ulong; 0124 gint64 v_int64; 0125 guint64 v_uint64; 0126 gfloat v_float; 0127 gdouble v_double; 0128 gpointer v_pointer; 0129 } data[2]; 0130 }; 0131 0132 0133 /* --- prototypes --- */ 0134 GOBJECT_AVAILABLE_IN_ALL 0135 GValue* g_value_init (GValue *value, 0136 GType g_type); 0137 GOBJECT_AVAILABLE_IN_ALL 0138 void g_value_copy (const GValue *src_value, 0139 GValue *dest_value); 0140 GOBJECT_AVAILABLE_IN_ALL 0141 GValue* g_value_reset (GValue *value); 0142 GOBJECT_AVAILABLE_IN_ALL 0143 void g_value_unset (GValue *value); 0144 GOBJECT_AVAILABLE_IN_ALL 0145 void g_value_set_instance (GValue *value, 0146 gpointer instance); 0147 GOBJECT_AVAILABLE_IN_2_42 0148 void g_value_init_from_instance (GValue *value, 0149 gpointer instance); 0150 0151 0152 /* --- private --- */ 0153 GOBJECT_AVAILABLE_IN_ALL 0154 gboolean g_value_fits_pointer (const GValue *value); 0155 GOBJECT_AVAILABLE_IN_ALL 0156 gpointer g_value_peek_pointer (const GValue *value); 0157 0158 0159 /* --- implementation details --- */ 0160 GOBJECT_AVAILABLE_IN_ALL 0161 gboolean g_value_type_compatible (GType src_type, 0162 GType dest_type); 0163 GOBJECT_AVAILABLE_IN_ALL 0164 gboolean g_value_type_transformable (GType src_type, 0165 GType dest_type); 0166 GOBJECT_AVAILABLE_IN_ALL 0167 gboolean g_value_transform (const GValue *src_value, 0168 GValue *dest_value); 0169 GOBJECT_AVAILABLE_IN_ALL 0170 void g_value_register_transform_func (GType src_type, 0171 GType dest_type, 0172 GValueTransform transform_func); 0173 0174 /** 0175 * G_VALUE_NOCOPY_CONTENTS: 0176 * 0177 * If passed to G_VALUE_COLLECT(), allocated data won't be copied 0178 * but used verbatim. This does not affect ref-counted types like 0179 * objects. This does not affect usage of g_value_copy(), the data will 0180 * be copied if it is not ref-counted. 0181 */ 0182 #define G_VALUE_NOCOPY_CONTENTS (1 << 27) 0183 0184 /** 0185 * G_VALUE_INTERNED_STRING: 0186 * 0187 * For string values, indicates that the string contained is canonical and will 0188 * exist for the duration of the process. See g_value_set_interned_string(). 0189 * 0190 * Since: 2.66 0191 */ 0192 #define G_VALUE_INTERNED_STRING (1 << 28) GOBJECT_AVAILABLE_MACRO_IN_2_66 0193 0194 /** 0195 * G_VALUE_INIT: 0196 * 0197 * A #GValue must be initialized before it can be used. This macro can 0198 * be used as initializer instead of an explicit `{ 0 }` when declaring 0199 * a variable, but it cannot be assigned to a variable. 0200 * 0201 * |[<!-- language="C" --> 0202 * GValue value = G_VALUE_INIT; 0203 * ]| 0204 * 0205 * Since: 2.30 0206 */ 0207 #define G_VALUE_INIT { 0, { { 0 } } } 0208 0209 0210 G_END_DECLS 0211 0212 #endif /* __G_VALUE_H__ */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|