|
Packit |
67b98c |
/*
|
|
Packit |
67b98c |
* Copyright (C) 2011 Igalia S.L.
|
|
Packit |
67b98c |
*
|
|
Packit |
67b98c |
* Contact: Iago Toral Quiroga <itoral@igalia.com>
|
|
Packit |
67b98c |
*
|
|
Packit |
67b98c |
* This library is free software; you can redistribute it and/or
|
|
Packit |
67b98c |
* modify it under the terms of the GNU Lesser General Public License
|
|
Packit |
67b98c |
* as published by the Free Software Foundation; version 2.1 of
|
|
Packit |
67b98c |
* the License, or (at your option) any later version.
|
|
Packit |
67b98c |
*
|
|
Packit |
67b98c |
* This library is distributed in the hope that it will be useful, but
|
|
Packit |
67b98c |
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
67b98c |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
67b98c |
* Lesser General Public License for more details.
|
|
Packit |
67b98c |
*
|
|
Packit |
67b98c |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit |
67b98c |
* License along with this library; if not, write to the Free Software
|
|
Packit |
67b98c |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
Packit |
67b98c |
* 02110-1301 USA
|
|
Packit |
67b98c |
*
|
|
Packit |
67b98c |
*/
|
|
Packit |
67b98c |
|
|
Packit |
67b98c |
/*
|
|
Packit |
67b98c |
* This module provides helper functions to use GValues easily. Inspired by
|
|
Packit |
67b98c |
* libsoup's soup-value-utils:
|
|
Packit |
67b98c |
* http://git.gnome.org/browse/libsoup/tree/libsoup/soup-value-utils.c
|
|
Packit |
67b98c |
*
|
|
Packit |
67b98c |
*/
|
|
Packit |
67b98c |
|
|
Packit |
67b98c |
#include <grl-value-helper.h>
|
|
Packit |
67b98c |
|
|
Packit |
67b98c |
|
|
Packit |
67b98c |
GValue *
|
|
Packit |
67b98c |
grl_g_value_new (GType g_type)
|
|
Packit |
67b98c |
{
|
|
Packit |
67b98c |
GValue *value;
|
|
Packit |
67b98c |
|
|
Packit |
67b98c |
value = g_slice_new0 (GValue);
|
|
Packit |
67b98c |
g_value_init (value, g_type);
|
|
Packit |
67b98c |
|
|
Packit |
67b98c |
return value;
|
|
Packit |
67b98c |
}
|
|
Packit |
67b98c |
|
|
Packit |
67b98c |
void
|
|
Packit |
67b98c |
grl_g_value_free (GValue *value)
|
|
Packit |
67b98c |
{
|
|
Packit |
67b98c |
g_value_unset (value);
|
|
Packit |
67b98c |
g_slice_free (GValue, value);
|
|
Packit |
67b98c |
}
|
|
Packit |
67b98c |
|
|
Packit |
67b98c |
/**
|
|
Packit |
67b98c |
* grl_g_value_hashtable_new:
|
|
Packit |
67b98c |
*
|
|
Packit |
67b98c |
* Returns: (element-type utf8 GValue) (transfer full): a new hash table made to contain GValues.
|
|
Packit |
67b98c |
*/
|
|
Packit |
67b98c |
GHashTable *
|
|
Packit |
67b98c |
grl_g_value_hashtable_new (void)
|
|
Packit |
67b98c |
{
|
|
Packit |
67b98c |
return g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)grl_g_value_free);
|
|
Packit |
67b98c |
}
|
|
Packit |
67b98c |
|
|
Packit |
67b98c |
/**
|
|
Packit |
67b98c |
* grl_g_value_hashtable_new_direct:
|
|
Packit |
67b98c |
*
|
|
Packit |
67b98c |
* Returns: (element-type gpointer GValue) (transfer full): a new hash table made to contain GValues.
|
|
Packit |
67b98c |
*/
|
|
Packit |
67b98c |
GHashTable *
|
|
Packit |
67b98c |
grl_g_value_hashtable_new_direct (void)
|
|
Packit |
67b98c |
{
|
|
Packit |
67b98c |
return g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify)grl_g_value_free);
|
|
Packit |
67b98c |
}
|
|
Packit |
67b98c |
|
|
Packit |
67b98c |
/**
|
|
Packit |
67b98c |
* grl_g_value_dup:
|
|
Packit |
67b98c |
* @value: the #GValue to copy
|
|
Packit |
67b98c |
*
|
|
Packit |
67b98c |
* Returns: (transfer full): a duplicated #GValue
|
|
Packit |
67b98c |
*/
|
|
Packit |
67b98c |
GValue *
|
|
Packit |
67b98c |
grl_g_value_dup (const GValue *value)
|
|
Packit |
67b98c |
{
|
|
Packit |
67b98c |
GValue *new_value = grl_g_value_new (G_VALUE_TYPE (value));
|
|
Packit |
67b98c |
g_value_copy (value, new_value);
|
|
Packit |
67b98c |
|
|
Packit |
67b98c |
return new_value;
|
|
Packit |
67b98c |
}
|