[virt-tools-list] [libosinfo v2 3/8] Add enum param getter/setter helpers

Christophe Fergeau cfergeau at redhat.com
Mon Nov 12 10:14:47 UTC 2012


On Fri, Nov 09, 2012 at 04:14:19PM +0100, Zeeshan Ali (Khattak) wrote:
> From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>
> 
> Add:
> 
> * osinfo_entity_get_param_value_enum
> * osinfo_entity_set_param_enum
> ---
>  osinfo/libosinfo.syms  |  3 +++
>  osinfo/osinfo_entity.c | 39 +++++++++++++++++++++++++++++++++++++++
>  osinfo/osinfo_entity.h |  5 +++++
>  3 files changed, 47 insertions(+)
> 
> diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
> index 2d28388..d291d7e 100644
> --- a/osinfo/libosinfo.syms
> +++ b/osinfo/libosinfo.syms
> @@ -320,6 +320,9 @@ LIBOSINFO_0.2.2 {
>  	osinfo_install_config_param_policy_get_type;
>  	osinfo_media_error_get_type;
>  	osinfo_product_relationship_get_type;
> +
> +	osinfo_entity_get_param_value_enum;
> +	osinfo_entity_set_param_enum;
>  } LIBOSINFO_0.2.1;
>  
>  
> diff --git a/osinfo/osinfo_entity.c b/osinfo/osinfo_entity.c
> index 33c73ea..9fabc46 100644
> --- a/osinfo/osinfo_entity.c
> +++ b/osinfo/osinfo_entity.c
> @@ -211,6 +211,20 @@ void osinfo_entity_set_param_int64(OsinfoEntity *entity, const gchar *key, gint6
>      g_free(str);
>  }
>  
> +void osinfo_entity_set_param_enum(OsinfoEntity *entity, const gchar *key, gint value, GType enum_type)
> +{
> +    GEnumClass *enum_class;
> +    GEnumValue *enum_value;
> +
> +    g_return_if_fail(G_TYPE_IS_ENUM (enum_type));
> +
> +    enum_class = g_type_class_ref(enum_type);
> +    enum_value = g_enum_get_value(enum_class, value);
> +    g_type_class_unref(enum_class);
> +
> +    osinfo_entity_set_param(entity, key, enum_value->value_nick);

enum_value can be NULL if 'value' is not a valid 'enum_type' value.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20121112/7bfdbdb9/attachment.sig>


More information about the virt-tools-list mailing list