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



commit f4c4eedd72e0bdc5bbcd88d7438125ca9262765f
Author: Carlos Garnacho <carlos lanedo com>
Date:   Tue Jan 26 12:04:20 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 |   23 +++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-common/tracker-sparql-builder.vala b/src/libtracker-common/tracker-sparql-builder.vala
index 5eda0de..298c8c7 100644
--- a/src/libtracker-common/tracker-sparql-builder.vala
+++ b/src/libtracker-common/tracker-sparql-builder.vala
@@ -26,6 +26,7 @@ public class Tracker.SparqlBuilder : Object {
 		PREDICATE,
 		OBJECT,
 		BLANK,
+		WHERE,
 		EMBEDDED_INSERT
 	}
 
@@ -84,6 +85,28 @@ public class Tracker.SparqlBuilder : Object {
 		}
 	}
 
+	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));
 	}



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