[tracker/wip/carlosg/tracker-3.0-api-breaks: 48/63] libtracker-sparql: Add tracker_sparql_statement_clear_bindings()



commit 2e112a510116eb7121e1a5eeb85a388e1927f6bf
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Dec 30 18:53:46 2019 +0100

    libtracker-sparql: Add tracker_sparql_statement_clear_bindings()
    
    This function may be useful to reset a TrackerSparqlStatement to its
    initial state. It may also be useful to create reusable queries with
    IN() filters, where we may pass <= the number of placeholder values.

 .../reference/libtracker-sparql/libtracker-sparql-sections.txt |  1 +
 src/libtracker-direct/tracker-direct-statement.c               | 10 ++++++++++
 src/libtracker-sparql/tracker-statement.vala                   | 10 ++++++++++
 3 files changed, 21 insertions(+)
---
diff --git a/docs/reference/libtracker-sparql/libtracker-sparql-sections.txt 
b/docs/reference/libtracker-sparql/libtracker-sparql-sections.txt
index c789762a6..91b0ab2e3 100644
--- a/docs/reference/libtracker-sparql/libtracker-sparql-sections.txt
+++ b/docs/reference/libtracker-sparql/libtracker-sparql-sections.txt
@@ -150,6 +150,7 @@ tracker_sparql_statement_bind_int
 tracker_sparql_statement_bind_double
 tracker_sparql_statement_bind_string
 tracker_sparql_statement_bind_boolean
+tracker_sparql_statement_clear_bindings
 tracker_sparql_statement_get_connection
 tracker_sparql_statement_set_connection
 tracker_sparql_statement_get_sparql
diff --git a/src/libtracker-direct/tracker-direct-statement.c 
b/src/libtracker-direct/tracker-direct-statement.c
index 68ede258f..0628b1fb5 100644
--- a/src/libtracker-direct/tracker-direct-statement.c
+++ b/src/libtracker-direct/tracker-direct-statement.c
@@ -128,6 +128,15 @@ tracker_direct_statement_bind_string (TrackerSparqlStatement *stmt,
        g_value_set_string (gvalue, value);
 }
 
+static void
+tracker_direct_statement_clear_bindings (TrackerSparqlStatement *stmt)
+{
+       TrackerDirectStatementPrivate *priv;
+
+       priv = tracker_direct_statement_get_instance_private (TRACKER_DIRECT_STATEMENT (stmt));
+       g_hash_table_remove_all (priv->values);
+}
+
 static TrackerSparqlCursor *
 tracker_direct_statement_execute (TrackerSparqlStatement  *stmt,
                                   GCancellable            *cancellable,
@@ -239,6 +248,7 @@ tracker_direct_statement_class_init (TrackerDirectStatementClass *klass)
        stmt_class->bind_boolean = tracker_direct_statement_bind_boolean;
        stmt_class->bind_double = tracker_direct_statement_bind_double;
        stmt_class->bind_string = tracker_direct_statement_bind_string;
+       stmt_class->clear_bindings = tracker_direct_statement_clear_bindings;
        stmt_class->execute = tracker_direct_statement_execute;
        stmt_class->execute_async = tracker_direct_statement_execute_async;
        stmt_class->execute_finish = tracker_direct_statement_execute_finish;
diff --git a/src/libtracker-sparql/tracker-statement.vala b/src/libtracker-sparql/tracker-statement.vala
index 10569f697..2cae06144 100644
--- a/src/libtracker-sparql/tracker-statement.vala
+++ b/src/libtracker-sparql/tracker-statement.vala
@@ -85,6 +85,16 @@ public abstract class Tracker.Sparql.Statement : Object {
         */
        public abstract void bind_double (string name, double value);
 
+        /**
+         * tracker_sparql_statement_clear_bindings:
+         * @self: a #TrackerSparqlStatement
+         *
+         * Clears all boolean/string/integer/double bindings.
+         *
+         * Since: 3.0
+         */
+       public abstract void clear_bindings ();
+
        /**
         * tracker_sparql_statement_execute:
         * @self: a #TrackerSparqlStatement


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