[tracker/wip/carlosg/resources-as-cursors: 1/11] libtracker-sparql: Deprecate tracker_resource_print_turtle()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/resources-as-cursors: 1/11] libtracker-sparql: Deprecate tracker_resource_print_turtle()
- Date: Mon, 11 Jul 2022 19:10:46 +0000 (UTC)
commit 9e719f306797af9c9fe30b8c16c454b76efae51d
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Jul 2 20:09:41 2022 +0200
libtracker-sparql: Deprecate tracker_resource_print_turtle()
This function has been superseded by tracker_resource_print_rdf() which
allows turtle and other file formats.
src/libtracker-sparql/tracker-resource.c | 117 +------------------------------
src/libtracker-sparql/tracker-resource.h | 2 +-
2 files changed, 4 insertions(+), 115 deletions(-)
---
diff --git a/src/libtracker-sparql/tracker-resource.c b/src/libtracker-sparql/tracker-resource.c
index ff5cb4d92..a59d98ebb 100644
--- a/src/libtracker-sparql/tracker-resource.c
+++ b/src/libtracker-sparql/tracker-resource.c
@@ -1028,14 +1028,6 @@ maybe_intern_prefix_of_compact_uri (TrackerNamespaceManager *all_namespaces,
}
-typedef struct {
- TrackerNamespaceManager *all_namespaces, *our_namespaces;
- GString *string;
- GList *done_list;
-} GenerateTurtleData;
-
-static void generate_turtle (TrackerResource *resource, GenerateTurtleData *data);
-
static gboolean
is_blank_node (const char *uri_or_curie_or_blank)
{
@@ -1066,50 +1058,6 @@ is_builtin_class (const gchar *uri_or_curie,
return has_prefix;
}
-static void
-generate_nested_turtle_resource (TrackerResource *resource,
- GenerateTurtleData *data)
-{
- /* We don't need to produce turtle for builtin classes */
- if (is_builtin_class (tracker_resource_get_identifier (resource),
- data->all_namespaces))
- return;
-
- if (g_list_find (data->done_list, resource) == NULL) {
- data->done_list = g_list_prepend (data->done_list, resource);
- generate_turtle (resource, data);
- g_string_append (data->string, "\n");
- }
-}
-
-static void
-generate_turtle_resources_foreach (gpointer key,
- gpointer value_ptr,
- gpointer user_data)
-{
- const GValue *value = value_ptr;
- GenerateTurtleData *data = user_data;
- TrackerResource *resource;
- guint i;
-
- if (G_VALUE_HOLDS (value, TRACKER_TYPE_RESOURCE)) {
- resource = g_value_get_object (value);
- generate_nested_turtle_resource (resource, data);
- } else if (G_VALUE_HOLDS (value, G_TYPE_PTR_ARRAY)) {
- GPtrArray *array = g_value_get_boxed (value);
- const GValue *array_value;
-
- for (i = 0; i < array->len; i++) {
- array_value = g_ptr_array_index (array, i);
-
- if (G_VALUE_HOLDS (array_value, TRACKER_TYPE_RESOURCE)) {
- resource = g_value_get_object (array_value);
- generate_nested_turtle_resource (resource, data);
- }
- }
- }
-}
-
static void
generate_turtle_uri_value (const char *uri_or_curie_or_blank,
GString *string,
@@ -1233,39 +1181,6 @@ generate_turtle_property (const char *property,
}
}
-static void
-generate_turtle (TrackerResource *resource,
- GenerateTurtleData *data)
-{
- TrackerResourcePrivate *priv = GET_PRIVATE (resource);
- GHashTableIter iter;
- const char *property;
- const GValue *value;
-
- /* First we recurse to any relations that aren't already in the done list */
- g_hash_table_foreach (priv->properties, generate_turtle_resources_foreach, data);
-
- generate_turtle_uri_value (tracker_resource_get_identifier(resource),
- data->string, data->all_namespaces, data->our_namespaces);
- g_string_append (data->string, " ");
-
- g_hash_table_iter_init (&iter, priv->properties);
- if (g_hash_table_iter_next (&iter, (gpointer *)&property, (gpointer *)&value)) {
- while (TRUE) {
- generate_turtle_property (property, value, data->string, data->all_namespaces,
data->our_namespaces);
-
- maybe_intern_prefix_of_compact_uri (data->all_namespaces, data->our_namespaces,
property);
-
- if (g_hash_table_iter_next (&iter, (gpointer *)&property, (gpointer *)&value)) {
- g_string_append (data->string, " ;\n ");
- } else {
- g_string_append (data->string, " .\n");
- break;
- }
- }
- }
-}
-
/**
* tracker_resource_print_turtle:
* @self: a #TrackerResource
@@ -1282,46 +1197,20 @@ generate_turtle (TrackerResource *resource,
* from the connection that is the intended recipient of this data.
*
* Returns: a newly-allocated string
+ *
+ * Deprecated: 3.4: Use tracker_resource_print_rdf() instead.
*/
char *
tracker_resource_print_turtle (TrackerResource *self,
TrackerNamespaceManager *namespaces)
{
- TrackerResourcePrivate *priv;
- GenerateTurtleData context;
- char *prefixes;
-
g_return_val_if_fail (TRACKER_IS_RESOURCE (self), "");
- priv = GET_PRIVATE (self);
-
if (namespaces == NULL) {
namespaces = tracker_namespace_manager_get_default ();
}
- if (g_hash_table_size (priv->properties) == 0) {
- return g_strdup("");
- }
-
- context.all_namespaces = namespaces;
- context.our_namespaces = tracker_namespace_manager_new ();
- context.string = g_string_new ("");
- context.done_list = g_list_prepend (NULL, self);
-
- maybe_intern_prefix_of_compact_uri (context.all_namespaces, context.our_namespaces,
tracker_resource_get_identifier(self));
-
- generate_turtle (self, &context);
-
- prefixes = tracker_namespace_manager_print_turtle (context.our_namespaces);
- g_string_prepend (context.string, "\n");
- g_string_prepend (context.string, prefixes);
-
- g_object_unref (context.our_namespaces);
- g_free (prefixes);
-
- g_list_free (context.done_list);
-
- return g_string_free (context.string, FALSE);
+ return tracker_resource_print_rdf (self, namespaces, TRACKER_RDF_FORMAT_TURTLE, NULL);
}
typedef struct {
diff --git a/src/libtracker-sparql/tracker-resource.h b/src/libtracker-sparql/tracker-resource.h
index 420230470..710a8fed0 100644
--- a/src/libtracker-sparql/tracker-resource.h
+++ b/src/libtracker-sparql/tracker-resource.h
@@ -106,7 +106,7 @@ gint tracker_resource_identifier_compare_func (TrackerResource *resource, const
TRACKER_AVAILABLE_IN_ALL
GList *tracker_resource_get_properties (TrackerResource *resource);
-TRACKER_AVAILABLE_IN_ALL
+TRACKER_DEPRECATED_IN_3_4_FOR(tracker_resource_print_rdf)
char *tracker_resource_print_turtle(TrackerResource *self, TrackerNamespaceManager *namespaces);
TRACKER_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]