[tracker/wip/carlosg/anonymous-nodes: 14/24] libtracker-data: Add TrackerToken API to hold blank nodes




commit ebb9f010217ec131da43fab7fb5272f1053d3707
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Sep 25 13:48:45 2021 +0200

    libtracker-data: Add TrackerToken API to hold blank nodes
    
    These should not be resolved as a URN string, but carried along
    as ROWIDs.

 src/libtracker-data/tracker-sparql-types.c | 17 +++++++++++++++++
 src/libtracker-data/tracker-sparql-types.h |  4 ++++
 2 files changed, 21 insertions(+)
---
diff --git a/src/libtracker-data/tracker-sparql-types.c b/src/libtracker-data/tracker-sparql-types.c
index d9ac2b5f4..9211ddbf2 100644
--- a/src/libtracker-data/tracker-sparql-types.c
+++ b/src/libtracker-data/tracker-sparql-types.c
@@ -28,6 +28,7 @@ enum {
        TOKEN_TYPE_VARIABLE,
        TOKEN_TYPE_PARAMETER,
        TOKEN_TYPE_PATH,
+       TOKEN_TYPE_BNODE,
 };
 
 /* Helper structs */
@@ -181,6 +182,14 @@ tracker_token_path_init (TrackerToken       *token,
        token->content.path = path;
 }
 
+void
+tracker_token_bnode_init (TrackerToken *token,
+                          gint64        bnode_id)
+{
+       token->type = TOKEN_TYPE_BNODE;
+       token->content.bnode = bnode_id;
+}
+
 void
 tracker_token_unset (TrackerToken *token)
 {
@@ -229,6 +238,14 @@ tracker_token_get_path (TrackerToken *token)
        return NULL;
 }
 
+gint64
+tracker_token_get_bnode (TrackerToken *token)
+{
+       if (token->type == TOKEN_TYPE_BNODE)
+               return token->content.bnode;
+       return 0;
+}
+
 const gchar *
 tracker_token_get_idstring (TrackerToken *token)
 {
diff --git a/src/libtracker-data/tracker-sparql-types.h b/src/libtracker-data/tracker-sparql-types.h
index 8f4e142ed..e676f3f02 100644
--- a/src/libtracker-data/tracker-sparql-types.h
+++ b/src/libtracker-data/tracker-sparql-types.h
@@ -139,6 +139,7 @@ struct _TrackerToken {
                gchar *parameter;
                TrackerVariable *var;
                TrackerPathElement *path;
+               gint64 bnode;
        } content;
 };
 
@@ -304,6 +305,8 @@ void tracker_token_parameter_init (TrackerToken   *token,
                                   const gchar    *parameter);
 void tracker_token_path_init      (TrackerToken       *token,
                                    TrackerPathElement *path_elem);
+void tracker_token_bnode_init     (TrackerToken *token,
+                                   gint64        bnode_id);
 void tracker_token_unset (TrackerToken *token);
 
 gboolean           tracker_token_is_empty     (TrackerToken *token);
@@ -312,6 +315,7 @@ TrackerVariable  * tracker_token_get_variable (TrackerToken *token);
 const gchar      * tracker_token_get_idstring (TrackerToken *token);
 const gchar      * tracker_token_get_parameter (TrackerToken *token);
 TrackerPathElement * tracker_token_get_path   (TrackerToken *token);
+gint64             tracker_token_get_bnode    (TrackerToken *token);
 
 /* Solution */
 TrackerSolution * tracker_solution_new       (guint            n_cols);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]