[PATCH 01/15] core: Added some helper functions to handle GValues
- From: gemont igalia com
- To: grilo-list gnome org
- Subject: [PATCH 01/15] core: Added some helper functions to handle GValues
- Date: Fri, 2 Dec 2011 18:36:27 +0100
From: Guillaume Emont <gemont igalia com>
---
src/Makefile.am | 4 ++-
src/grl-value-helper.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++
src/grl-value-helper.h | 44 ++++++++++++++++++++++++++++++++
3 files changed, 113 insertions(+), 1 deletions(-)
create mode 100644 src/grl-value-helper.c
create mode 100644 src/grl-value-helper.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 0c727f8..103d3f8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -50,6 +50,7 @@ lib@GRL_NAME@_la_SOURCES = \
grl-multiple.c \
grl-log.c grl-log-priv.h \
grl-sync.c \
+ grl-value-helper.c \
grilo.c
data_c_sources = \
@@ -79,7 +80,8 @@ lib@GRL_NAME@inc_HEADERS = \
grl-multiple.h \
grl-util.h \
grl-definitions.h \
- grl-operation.h
+ grl-operation.h \
+ grl-value-helper.h
data_h_headers = \
data/grl-data.h \
diff --git a/src/grl-value-helper.c b/src/grl-value-helper.c
new file mode 100644
index 0000000..bed8e54
--- /dev/null
+++ b/src/grl-value-helper.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * Contact: Iago Toral Quiroga <itoral igalia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+/**
+ * SECTION:grl-value-helper
+ * @short_description: helpers to use GValue
+ *
+ * This module provides helper functions to use GValues easily. Inspired by
+ * libsoup's soup-value-utils:
+ * http://git.gnome.org/browse/libsoup/tree/libsoup/soup-value-utils.c
+ *
+ */
+
+#include <grl-value-helper.h>
+
+GValue *
+grl_g_value_new (GType g_type)
+{
+ GValue *value;
+
+ value = g_slice_new0 (GValue);
+ g_value_init (value, g_type);
+
+ return value;
+}
+
+void
+grl_g_value_free (GValue *value)
+{
+ g_value_unset (value);
+ g_slice_free (GValue, value);
+}
+
+GHashTable *
+grl_g_value_hashtable_new (void)
+{
+ return g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify)grl_g_value_free);
+}
+
+GValue *
+grl_g_value_dup (const GValue *value)
+{
+ GValue *new_value = grl_g_value_new (G_VALUE_TYPE (value));
+ g_value_copy (value, new_value);
+
+ return new_value;
+}
diff --git a/src/grl-value-helper.h b/src/grl-value-helper.h
new file mode 100644
index 0000000..6079822
--- /dev/null
+++ b/src/grl-value-helper.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * Contact: Iago Toral Quiroga <itoral igalia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#if !defined (_GRILO_H_INSIDE_) && !defined (GRILO_COMPILATION)
+#error "Only <grilo.h> can be included directly."
+#endif
+
+#if !defined (_GRL_VALUE_HELPER_H_)
+#define _GRL_VALUE_HELPER_H_
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+GValue *grl_g_value_new (GType g_type);
+
+void grl_g_value_free (GValue *value);
+
+GHashTable *grl_g_value_hashtable_new (void);
+
+GValue *grl_g_value_dup (const GValue *value);
+
+G_END_DECLS
+
+#endif /* _GRL_VALUE_HELPER_H_ */
--
1.7.5.4
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]