[tracker/anonymous-file-nodes: 1/4] Add API to TrackerSparqlBuilder to add WHERE clauses.



commit 822d979210cf24522cafb3310b1a8c3cc8f154bd
Author: Carlos Garnacho <carlos lanedo com>
Date:   Thu Jan 21 15:26:37 2010 +0100

    Add API to TrackerSparqlBuilder to add WHERE clauses.
    
    where_open(), where_close() and subject_variable() have been added.

 src/libtracker-common/tracker-sparql-builder.vala |   27 +++++++++++++++++++-
 1 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-common/tracker-sparql-builder.vala b/src/libtracker-common/tracker-sparql-builder.vala
index c0d5e6d..98edadc 100644
--- a/src/libtracker-common/tracker-sparql-builder.vala
+++ b/src/libtracker-common/tracker-sparql-builder.vala
@@ -25,7 +25,8 @@ public class Tracker.SparqlBuilder : Object {
 		SUBJECT,
 		PREDICATE,
 		OBJECT,
-		BLANK
+		BLANK,
+		WHERE
 	}
 
 	public string result {
@@ -75,12 +76,34 @@ public class Tracker.SparqlBuilder : Object {
 		str.append ("}\n");
 	}
 
+	public void where_open ()
+		requires (state == State.UPDATE)
+	{
+		states += State.WHERE;
+		str.append ("WHERE {\n");
+	}
+
+	public void where_close ()
+		requires (state == State.WHERE || state == State.OBJECT)
+	{
+		if (state == State.OBJECT) {
+			str.append (" .\n");
+			states.length -= 3;
+		}
+		states.length--;
+		str.append ("}\n");
+	}
+
+	public void subject_variable (string var_name) {
+		subject ("?%s".printf (var_name));
+	}
+
 	public void subject_iri (string iri) {
 		subject ("<%s>".printf (iri));
 	}
 
 	public void subject (string s)
-		requires (state == State.INSERT || state == State.OBJECT)
+		requires (state == State.INSERT || state == State.OBJECT || state == State.WHERE)
 	{
 		if (state == State.OBJECT) {
 			str.append (" .\n");



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