[tracker/wip/carlosg/ttl-parser-improvements: 4/6] libtracker-data: Add tracker_sparql_make_langstring()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/ttl-parser-improvements: 4/6] libtracker-data: Add tracker_sparql_make_langstring()
- Date: Sat, 10 Oct 2020 09:02:38 +0000 (UTC)
commit 539c2bc50fbc43772dbb35d65465de3a35dd0def
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Oct 6 21:27:02 2020 +0200
libtracker-data: Add tracker_sparql_make_langstring()
This function takes a string and langtag, and produces a GBytes as
the internals do expect it.
src/libtracker-data/tracker-sparql.c | 34 ++++++++++++++++++++++------------
src/libtracker-data/tracker-sparql.h | 3 +++
2 files changed, 25 insertions(+), 12 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 2ff43d045..3bee2b34f 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -8746,20 +8746,9 @@ translate_RDFLiteral (TrackerSparql *sparql,
if (is_parameter) {
binding = tracker_parameter_binding_new (str, NULL);
} else {
- GString *langstr;
GBytes *bytes;
- langstr = g_string_new (str);
-
- if (langtag) {
- g_string_append_c (langstr, '\0');
- g_string_append_printf (langstr, "%s", &langtag[1]);
- }
-
- bytes = g_bytes_new_take (langstr->str,
- langstr->len + 1);
- g_string_free (langstr, FALSE);
-
+ bytes = tracker_sparql_make_langstring (str, langtag);
binding = tracker_literal_binding_new (bytes, NULL);
g_bytes_unref (bytes);
}
@@ -9566,3 +9555,24 @@ tracker_sparql_execute_update (TrackerSparql *sparql,
return NULL;
}
+
+GBytes *
+tracker_sparql_make_langstring (const gchar *str,
+ const gchar *langtag)
+{
+ GString *langstr;
+ GBytes *bytes;
+
+ langstr = g_string_new (str);
+
+ if (langtag) {
+ g_string_append_c (langstr, '\0');
+ g_string_append_printf (langstr, "%s", &langtag[1]);
+ }
+
+ bytes = g_bytes_new_take (langstr->str,
+ langstr->len + 1);
+ g_string_free (langstr, FALSE);
+
+ return bytes;
+}
diff --git a/src/libtracker-data/tracker-sparql.h b/src/libtracker-data/tracker-sparql.h
index e86665c51..57651de1a 100644
--- a/src/libtracker-data/tracker-sparql.h
+++ b/src/libtracker-data/tracker-sparql.h
@@ -45,4 +45,7 @@ GVariant * tracker_sparql_execute_update (TrackerSparql *sparql,
gboolean blank,
GError **error);
+GBytes * tracker_sparql_make_langstring (const gchar *str,
+ const gchar *langtag);
+
#endif /* __TRACKER_SPARQL_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]