[tracker/wip/carlosg/ttl-parser-improvements: 3/6] libtracker-data: Forward langtag from TTL parser
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/ttl-parser-improvements: 3/6] libtracker-data: Forward langtag from TTL parser
- Date: Sat, 10 Oct 2020 09:02:38 +0000 (UTC)
commit 45943da0e4567c8cc8118cee1d0a24d74d5c6461
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Oct 6 21:17:40 2020 +0200
libtracker-data: Forward langtag from TTL parser
Pass this as an argument, unused so far.
docs/tools/ttl_loader.c | 4 ++--
src/libtracker-data/tracker-data-manager.c | 6 +++---
src/libtracker-data/tracker-data-update.c | 1 +
src/libtracker-data/tracker-turtle-reader.c | 16 +++++++++++-----
src/libtracker-data/tracker-turtle-reader.h | 1 +
5 files changed, 18 insertions(+), 10 deletions(-)
---
diff --git a/docs/tools/ttl_loader.c b/docs/tools/ttl_loader.c
index dfa9ce5db..08b634588 100644
--- a/docs/tools/ttl_loader.c
+++ b/docs/tools/ttl_loader.c
@@ -390,7 +390,7 @@ ttl_loader_load_ontology (Ontology *ontology,
while (inner_error == NULL &&
tracker_turtle_reader_next (reader,
&subject, &predicate, &object,
- NULL, &inner_error)) {
+ NULL, NULL, &inner_error)) {
load_in_memory (ontology, subject, predicate, object);
}
@@ -429,7 +429,7 @@ ttl_loader_load_description (GFile *file)
while (error == NULL &&
tracker_turtle_reader_next (reader,
&subject, &predicate, &object,
- NULL, &error)) {
+ NULL, NULL, &error)) {
load_description (desc, subject, predicate, object);
}
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index a5e077041..bbb4d2e0e 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -1781,7 +1781,7 @@ load_ontology_file (TrackerDataManager *manager,
while (tracker_turtle_reader_next (reader,
&subject, &predicate, &object,
- NULL, &ttl_error)) {
+ NULL, NULL, &ttl_error)) {
GError *ontology_error = NULL;
tracker_data_ontology_load_statement (manager, ontology_uri,
@@ -1829,7 +1829,7 @@ get_ontology_from_file (TrackerDataManager *manager,
while (tracker_turtle_reader_next (reader,
&subject, &predicate, &object,
- NULL, &error)) {
+ NULL, NULL, &error)) {
if (g_strcmp0 (predicate, RDF_TYPE) == 0) {
if (g_strcmp0 (object, TRACKER_PREFIX_NRL "Ontology") == 0) {
TrackerOntology *ontology;
@@ -2007,7 +2007,7 @@ import_ontology_file (TrackerDataManager *manager,
while (tracker_turtle_reader_next (reader,
&subject, &predicate, &object,
- NULL, &error)) {
+ NULL, NULL, &error)) {
tracker_data_ontology_process_statement (manager,
subject, predicate, object,
in_update);
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 86a707dde..d6725cd03 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -2685,6 +2685,7 @@ tracker_data_load_turtle_file (TrackerData *data,
&subject,
&predicate,
&object_str,
+ NULL,
&object_is_uri,
&inner_error)) {
GBytes *object;
diff --git a/src/libtracker-data/tracker-turtle-reader.c b/src/libtracker-data/tracker-turtle-reader.c
index f5b3abc97..50cde79b4 100644
--- a/src/libtracker-data/tracker-turtle-reader.c
+++ b/src/libtracker-data/tracker-turtle-reader.c
@@ -55,6 +55,7 @@ struct _TrackerTurtleReader {
gchar *subject;
gchar *predicate;
gchar *object;
+ gchar *object_lang;
gboolean object_is_uri;
ParserState state;
};
@@ -229,6 +230,7 @@ pop_stack (TrackerTurtleReader *reader)
/* Restore the old subject as current object */
reader->object = s;
reader->object_is_uri = TRUE;
+ g_clear_pointer (&reader->object_lang, g_free);
s = NULL;
} else if (reader->state == STATE_SUBJECT) {
g_clear_pointer (&reader->subject, g_free);
@@ -486,7 +488,7 @@ tracker_turtle_reader_iterate_next (TrackerTurtleReader *reader,
GError **error)
{
while (TRUE) {
- gchar *str;
+ gchar *str, *lang;
advance_whitespace (reader);
@@ -565,6 +567,7 @@ tracker_turtle_reader_iterate_next (TrackerTurtleReader *reader,
break;
case STATE_OBJECT:
g_clear_pointer (&reader->object, g_free);
+ g_clear_pointer (&reader->object_lang, g_free);
reader->object_is_uri = FALSE;
if (parse_token (reader, "[")) {
@@ -591,16 +594,18 @@ tracker_turtle_reader_iterate_next (TrackerTurtleReader *reader,
parse_terminal (reader, terminal_STRING_LITERAL_LONG2, 3, &str)) {
reader->object = g_strcompress (str);
g_free (str);
- if (!parse_terminal (reader, terminal_LANGTAG, 0, NULL)) {
- if (!handle_type_cast (reader, error))
+ if (parse_terminal (reader, terminal_LANGTAG, 0, &lang)) {
+ reader->object_lang = lang;
+ } else if (!handle_type_cast (reader, error)) {
return FALSE;
}
} else if (parse_terminal (reader, terminal_STRING_LITERAL1, 1, &str) ||
parse_terminal (reader, terminal_STRING_LITERAL2, 1, &str)) {
reader->object = g_strcompress (str);
g_free (str);
- if (!parse_terminal (reader, terminal_LANGTAG, 0, NULL)) {
- if (!handle_type_cast (reader, error))
+ if (parse_terminal (reader, terminal_LANGTAG, 0, &lang)) {
+ reader->object_lang = lang;
+ } else if (!handle_type_cast (reader, error)) {
return FALSE;
}
} else if (parse_terminal (reader, terminal_DOUBLE, 0, &str) ||
@@ -664,6 +669,7 @@ tracker_turtle_reader_next (TrackerTurtleReader *reader,
const gchar **subject,
const gchar **predicate,
const gchar **object,
+ const gchar **object_lang,
gboolean *object_is_uri,
GError **error)
{
diff --git a/src/libtracker-data/tracker-turtle-reader.h b/src/libtracker-data/tracker-turtle-reader.h
index 892d2c46a..2d7846bf0 100644
--- a/src/libtracker-data/tracker-turtle-reader.h
+++ b/src/libtracker-data/tracker-turtle-reader.h
@@ -38,6 +38,7 @@ gboolean tracker_turtle_reader_next (TrackerTurtleReader *reader,
const gchar **subject,
const gchar **predicate,
const gchar **object,
+ const gchar **object_lang,
gboolean *object_is_uri,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]