1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/glib/gobject/genums.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,261 @@
1.4 +/* GObject - GLib Type, Object, Parameter and Signal Library
1.5 + * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
1.6 + * Portions copyright (c) 2006-2009 Nokia Corporation. All rights reserved.
1.7 + * This library is free software; you can redistribute it and/or
1.8 + * modify it under the terms of the GNU Lesser General Public
1.9 + * License as published by the Free Software Foundation; either
1.10 + * version 2 of the License, or (at your option) any later version.
1.11 + *
1.12 + * This library is distributed in the hope that it will be useful,
1.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.15 + * Lesser General Public License for more details.
1.16 + *
1.17 + * You should have received a copy of the GNU Lesser General
1.18 + * Public License along with this library; if not, write to the
1.19 + * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
1.20 + * Boston, MA 02111-1307, USA.
1.21 + */
1.22 +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
1.23 +#error "Only <glib-object.h> can be included directly."
1.24 +#endif
1.25 +
1.26 +#ifndef __G_ENUMS_H__
1.27 +#define __G_ENUMS_H__
1.28 +
1.29 +#include <gobject/gtype.h>
1.30 +
1.31 +G_BEGIN_DECLS
1.32 +
1.33 +/* --- type macros --- */
1.34 +/**
1.35 + * G_TYPE_IS_ENUM:
1.36 + * @type: a #GType ID.
1.37 + *
1.38 + * Checks whether @type "is a" %G_TYPE_ENUM.
1.39 + *
1.40 + * Returns: %TRUE if @type "is a" %G_TYPE_ENUM.
1.41 + */
1.42 +#define G_TYPE_IS_ENUM(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_ENUM)
1.43 +/**
1.44 + * G_ENUM_CLASS:
1.45 + * @class: a valid #GEnumClass
1.46 + *
1.47 + * Casts a derived #GEnumClass structure into a #GEnumClass structure.
1.48 + */
1.49 +#define G_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_ENUM, GEnumClass))
1.50 +/**
1.51 + * G_IS_ENUM_CLASS:
1.52 + * @class: a #GEnumClass
1.53 + *
1.54 + * Checks whether @class "is a" valid #GEnumClass structure of type %G_TYPE_ENUM
1.55 + * or derived.
1.56 + */
1.57 +#define G_IS_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_ENUM))
1.58 +/**
1.59 + * G_ENUM_CLASS_TYPE:
1.60 + * @class: a #GEnumClass
1.61 + *
1.62 + * Get the type identifier from a given #GEnumClass structure.
1.63 + *
1.64 + * Returns: the #GType
1.65 + */
1.66 +#define G_ENUM_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
1.67 +/**
1.68 + * G_ENUM_CLASS_TYPE_NAME:
1.69 + * @class: a #GEnumClass
1.70 + *
1.71 + * Get the static type name from a given #GEnumClass structure.
1.72 + *
1.73 + * Returns: the type name.
1.74 + */
1.75 +#define G_ENUM_CLASS_TYPE_NAME(class) (g_type_name (G_ENUM_CLASS_TYPE (class)))
1.76 +
1.77 +
1.78 +/**
1.79 + * G_TYPE_IS_FLAGS:
1.80 + * @type: a #GType ID.
1.81 + *
1.82 + * Checks whether @type "is a" %G_TYPE_FLAGS.
1.83 + *
1.84 + * Returns: %TRUE if @type "is a" %G_TYPE_FLAGS.
1.85 + */
1.86 +#define G_TYPE_IS_FLAGS(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS)
1.87 +/**
1.88 + * G_FLAGS_CLASS:
1.89 + * @class: a valid #GFlagsClass
1.90 + *
1.91 + * Casts a derived #GFlagsClass structure into a #GFlagsClass structure.
1.92 + */
1.93 +#define G_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_FLAGS, GFlagsClass))
1.94 +/**
1.95 + * G_IS_FLAGS_CLASS:
1.96 + * @class: a #GFlagsClass
1.97 + *
1.98 + * Checks whether @class "is a" valid #GFlagsClass structure of type %G_TYPE_FLAGS
1.99 + * or derived.
1.100 + */
1.101 +#define G_IS_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_FLAGS))
1.102 +/**
1.103 + * G_FLAGS_CLASS_TYPE:
1.104 + * @class: a #GFlagsClass
1.105 + *
1.106 + * Get the type identifier from a given #GFlagsClass structure.
1.107 + *
1.108 + * Returns: the #GType
1.109 + */
1.110 +#define G_FLAGS_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
1.111 +/**
1.112 + * G_FLAGS_CLASS_TYPE_NAME:
1.113 + * @class: a #GFlagsClass
1.114 + *
1.115 + * Get the static type name from a given #GFlagsClass structure.
1.116 + *
1.117 + * Returns: the type name.
1.118 + */
1.119 +#define G_FLAGS_CLASS_TYPE_NAME(class) (g_type_name (G_FLAGS_CLASS_TYPE (class)))
1.120 +
1.121 +
1.122 +/**
1.123 + * G_VALUE_HOLDS_ENUM:
1.124 + * @value: a valid #GValue structure
1.125 + *
1.126 + * Checks whether the given #GValue can hold values derived from type %G_TYPE_ENUM.
1.127 + *
1.128 + * Returns: %TRUE on success.
1.129 + */
1.130 +#define G_VALUE_HOLDS_ENUM(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ENUM))
1.131 +/**
1.132 + * G_VALUE_HOLDS_FLAGS:
1.133 + * @value: a valid #GValue structure
1.134 + *
1.135 + * Checks whether the given #GValue can hold values derived from type %G_TYPE_FLAGS.
1.136 + *
1.137 + * Returns: %TRUE on success.
1.138 + */
1.139 +#define G_VALUE_HOLDS_FLAGS(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLAGS))
1.140 +
1.141 +
1.142 +/* --- enum/flag values & classes --- */
1.143 +typedef struct _GEnumClass GEnumClass;
1.144 +typedef struct _GFlagsClass GFlagsClass;
1.145 +typedef struct _GEnumValue GEnumValue;
1.146 +typedef struct _GFlagsValue GFlagsValue;
1.147 +
1.148 +/**
1.149 + * GEnumClass:
1.150 + * @g_type_class: the parent class
1.151 + * @minimum: the smallest possible value.
1.152 + * @maximum: the largest possible value.
1.153 + * @n_values: the number of possible values.
1.154 + * @values: an array of #GEnumValue structs describing the
1.155 + * individual values.
1.156 + *
1.157 + * The class of an enumeration type holds information about its
1.158 + * possible values.
1.159 + */
1.160 +struct _GEnumClass
1.161 +{
1.162 + GTypeClass g_type_class;
1.163 +
1.164 + /*< public >*/
1.165 + gint minimum;
1.166 + gint maximum;
1.167 + guint n_values;
1.168 + GEnumValue *values;
1.169 +};
1.170 +/**
1.171 + * GFlagsClass:
1.172 + * @g_type_class: the parent class
1.173 + * @mask: a mask covering all possible values.
1.174 + * @n_values: the number of possible values.
1.175 + * @values: an array of #GFlagsValue structs describing the
1.176 + * individual values.
1.177 + *
1.178 + * The class of a flags type holds information about its
1.179 + * possible values.
1.180 + */
1.181 +struct _GFlagsClass
1.182 +{
1.183 + GTypeClass g_type_class;
1.184 +
1.185 + /*< public >*/
1.186 + guint mask;
1.187 + guint n_values;
1.188 + GFlagsValue *values;
1.189 +};
1.190 +/**
1.191 + * GEnumValue:
1.192 + * @value: the enum value
1.193 + * @value_name: the name of the value
1.194 + * @value_nick: the nickname of the value
1.195 + *
1.196 + * A structure which contains a single enum value, its name, and its
1.197 + * nickname.
1.198 + */
1.199 +struct _GEnumValue
1.200 +{
1.201 + gint value;
1.202 + const gchar *value_name;
1.203 + const gchar *value_nick;
1.204 +};
1.205 +/**
1.206 + * GFlagsValue:
1.207 + * @value: the flags value
1.208 + * @value_name: the name of the value
1.209 + * @value_nick: the nickname of the value
1.210 + *
1.211 + * A structure which contains a single flags value, its name, and its
1.212 + * nickname.
1.213 + */
1.214 +struct _GFlagsValue
1.215 +{
1.216 + guint value;
1.217 + const gchar *value_name;
1.218 + const gchar *value_nick;
1.219 +};
1.220 +
1.221 +
1.222 +/* --- prototypes --- */
1.223 +IMPORT_C GEnumValue* g_enum_get_value (GEnumClass *enum_class,
1.224 + gint value);
1.225 +IMPORT_C GEnumValue* g_enum_get_value_by_name (GEnumClass *enum_class,
1.226 + const gchar *name);
1.227 +IMPORT_C GEnumValue* g_enum_get_value_by_nick (GEnumClass *enum_class,
1.228 + const gchar *nick);
1.229 +IMPORT_C GFlagsValue* g_flags_get_first_value (GFlagsClass *flags_class,
1.230 + guint value);
1.231 +IMPORT_C GFlagsValue* g_flags_get_value_by_name (GFlagsClass *flags_class,
1.232 + const gchar *name);
1.233 +IMPORT_C GFlagsValue* g_flags_get_value_by_nick (GFlagsClass *flags_class,
1.234 + const gchar *nick);
1.235 +IMPORT_C void g_value_set_enum (GValue *value,
1.236 + gint v_enum);
1.237 +IMPORT_C gint g_value_get_enum (const GValue *value);
1.238 +IMPORT_C void g_value_set_flags (GValue *value,
1.239 + guint v_flags);
1.240 +IMPORT_C guint g_value_get_flags (const GValue *value);
1.241 +
1.242 +
1.243 +
1.244 +/* --- registration functions --- */
1.245 +/* const_static_values is a NULL terminated array of enum/flags
1.246 + * values that is taken over!
1.247 + */
1.248 +IMPORT_C GType g_enum_register_static (const gchar *name,
1.249 + const GEnumValue *const_static_values);
1.250 +IMPORT_C GType g_flags_register_static (const gchar *name,
1.251 + const GFlagsValue *const_static_values);
1.252 +/* functions to complete the type information
1.253 + * for enums/flags implemented by plugins
1.254 + */
1.255 +IMPORT_C void g_enum_complete_type_info (GType g_enum_type,
1.256 + GTypeInfo *info,
1.257 + const GEnumValue *const_values);
1.258 +IMPORT_C void g_flags_complete_type_info (GType g_flags_type,
1.259 + GTypeInfo *info,
1.260 + const GFlagsValue *const_values);
1.261 +
1.262 +G_END_DECLS
1.263 +
1.264 +#endif /* __G_ENUMS_H__ */