diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2022-07-02 20:09:41 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2022-07-11 21:22:24 +0200 |
commit | 502ef55c61a8388d3b3e00f4e6d5fc9a58ab743b (patch) | |
tree | 2ce14858f429b94a237cabc2bc490f1a3e717a72 /src/libtracker-sparql/tracker-resource.c | |
parent | 233881062d2181df5e3dd826c354ae846d512f3d (diff) | |
download | tracker-502ef55c61a8388d3b3e00f4e6d5fc9a58ab743b.tar.gz |
libtracker-sparql: Deprecate tracker_resource_print_turtle()
This function has been superseded by tracker_resource_print_rdf() which
allows turtle and other file formats.
Diffstat (limited to 'src/libtracker-sparql/tracker-resource.c')
-rw-r--r-- | src/libtracker-sparql/tracker-resource.c | 117 |
1 files changed, 3 insertions, 114 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) { @@ -1067,50 +1059,6 @@ is_builtin_class (const gchar *uri_or_curie, } 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, TrackerNamespaceManager *all_namespaces, @@ -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 { |