[tracker/direct-access: 24/38] Move SparqlError from libtracker-data to libtracker-sparql



commit 8e824a779a5151f0b63d64c4e3fe4b9f891deffe
Author: Jürg Billeter <j bitron ch>
Date:   Wed Jul 21 15:55:05 2010 +0200

    Move SparqlError from libtracker-data to libtracker-sparql

 src/libtracker-data/Makefile.am                    |    2 +-
 src/libtracker-data/tracker-sparql-expression.vala |   70 +++++++++---------
 src/libtracker-data/tracker-sparql-pattern.vala    |   46 ++++++------
 src/libtracker-data/tracker-sparql-query.vala      |   75 +++++++++-----------
 src/libtracker-data/tracker-sparql-scanner.vala    |   18 +++---
 src/libtracker-data/tracker-turtle-reader.vala     |   16 ++--
 src/libtracker-direct/tracker-direct.vala          |   18 +++--
 src/tracker-store/Makefile.am                      |    1 +
 tests/libtracker-data/Makefile.am                  |    2 +
 tests/libtracker-fts/Makefile.am                   |    2 +
 10 files changed, 126 insertions(+), 124 deletions(-)
---
diff --git a/src/libtracker-data/Makefile.am b/src/libtracker-data/Makefile.am
index b691983..d458fbe 100644
--- a/src/libtracker-data/Makefile.am
+++ b/src/libtracker-data/Makefile.am
@@ -6,7 +6,7 @@ INCLUDES =								\
 	-DTRACKER_COMPILATION						\
 	-I$(top_srcdir)/src						\
 	-I$(top_builddir)/src						\
-	-I$(top_builddir)/src/libtracker-client				\
+	-I$(top_builddir)/src/libtracker-sparql				\
 	$(WARN_CFLAGS)							\
 	$(GLIB2_CFLAGS)							\
 	$(DBUS_CFLAGS)							\
diff --git a/src/libtracker-data/tracker-sparql-expression.vala b/src/libtracker-data/tracker-sparql-expression.vala
index 30fff1c..064217b 100644
--- a/src/libtracker-data/tracker-sparql-expression.vala
+++ b/src/libtracker-data/tracker-sparql-expression.vala
@@ -37,7 +37,7 @@ class Tracker.Sparql.Expression : Object {
 		get { return query.pattern; }
 	}
 
-	inline bool next () throws SparqlError {
+	inline bool next () throws Sparql.Error {
 		return query.next ();
 	}
 
@@ -49,15 +49,15 @@ class Tracker.Sparql.Expression : Object {
 		return query.last ();
 	}
 
-	inline bool accept (SparqlTokenType type) throws SparqlError {
+	inline bool accept (SparqlTokenType type) throws Sparql.Error {
 		return query.accept (type);
 	}
 
-	SparqlError get_error (string msg) {
+	Sparql.Error get_error (string msg) {
 		return query.get_error (msg);
 	}
 
-	bool expect (SparqlTokenType type) throws SparqlError {
+	bool expect (SparqlTokenType type) throws Sparql.Error {
 		return query.expect (type);
 	}
 
@@ -73,7 +73,7 @@ class Tracker.Sparql.Expression : Object {
 		return (type == PropertyType.INTEGER || type == PropertyType.DOUBLE || type == PropertyType.DATETIME || type == PropertyType.UNKNOWN);
 	}
 
-	void skip_bracketted_expression () throws SparqlError {
+	void skip_bracketted_expression () throws Sparql.Error {
 		expect (SparqlTokenType.OPEN_PARENS);
 		while (true) {
 			switch (current ()) {
@@ -93,7 +93,7 @@ class Tracker.Sparql.Expression : Object {
 		expect (SparqlTokenType.CLOSE_PARENS);
 	}
 
-	internal void skip_select_variables () throws SparqlError {
+	internal void skip_select_variables () throws Sparql.Error {
 		while (true) {
 			switch (current ()) {
 			case SparqlTokenType.OPEN_PARENS:
@@ -116,7 +116,7 @@ class Tracker.Sparql.Expression : Object {
 		}
 	}
 
-	internal PropertyType translate_select_expression (StringBuilder sql, bool subquery) throws SparqlError {
+	internal PropertyType translate_select_expression (StringBuilder sql, bool subquery) throws Sparql.Error {
 		Variable variable = null;
 
 		long begin = sql.len;
@@ -171,7 +171,7 @@ class Tracker.Sparql.Expression : Object {
 		return type;
 	}
 
-	void translate_expression_as_order_condition (StringBuilder sql) throws SparqlError {
+	void translate_expression_as_order_condition (StringBuilder sql) throws Sparql.Error {
 		long begin = sql.len;
 		if (translate_expression (sql) == PropertyType.RESOURCE) {
 			// ID => Uri
@@ -180,7 +180,7 @@ class Tracker.Sparql.Expression : Object {
 		}
 	}
 
-	internal void translate_order_condition (StringBuilder sql) throws SparqlError {
+	internal void translate_order_condition (StringBuilder sql) throws Sparql.Error {
 		if (accept (SparqlTokenType.ASC)) {
 			translate_expression_as_order_condition (sql);
 			sql.append (" ASC");
@@ -192,7 +192,7 @@ class Tracker.Sparql.Expression : Object {
 		}
 	}
 
-	void translate_bound_call (StringBuilder sql) throws SparqlError {
+	void translate_bound_call (StringBuilder sql) throws Sparql.Error {
 		expect (SparqlTokenType.BOUND);
 		expect (SparqlTokenType.OPEN_PARENS);
 		sql.append ("(");
@@ -201,7 +201,7 @@ class Tracker.Sparql.Expression : Object {
 		expect (SparqlTokenType.CLOSE_PARENS);
 	}
 
-	void translate_regex (StringBuilder sql) throws SparqlError {
+	void translate_regex (StringBuilder sql) throws Sparql.Error {
 		expect (SparqlTokenType.REGEX);
 		expect (SparqlTokenType.OPEN_PARENS);
 		sql.append ("SparqlRegex(");
@@ -224,7 +224,7 @@ class Tracker.Sparql.Expression : Object {
 		expect (SparqlTokenType.CLOSE_PARENS);
 	}
 
-	void translate_exists (StringBuilder sql) throws SparqlError {
+	void translate_exists (StringBuilder sql) throws Sparql.Error {
 		sql.append ("(");
 		pattern.translate_exists (sql);
 		sql.append (")");
@@ -265,7 +265,7 @@ class Tracker.Sparql.Expression : Object {
 		}
 	}
 
-	void translate_expression_as_string (StringBuilder sql) throws SparqlError {
+	void translate_expression_as_string (StringBuilder sql) throws Sparql.Error {
 		switch (current ()) {
 		case SparqlTokenType.IRI_REF:
 		case SparqlTokenType.PN_PREFIX:
@@ -293,7 +293,7 @@ class Tracker.Sparql.Expression : Object {
 		}
 	}
 
-	void translate_str (StringBuilder sql) throws SparqlError {
+	void translate_str (StringBuilder sql) throws Sparql.Error {
 		expect (SparqlTokenType.STR);
 		expect (SparqlTokenType.OPEN_PARENS);
 
@@ -302,7 +302,7 @@ class Tracker.Sparql.Expression : Object {
 		expect (SparqlTokenType.CLOSE_PARENS);
 	}
 
-	void translate_isuri (StringBuilder sql) throws SparqlError {
+	void translate_isuri (StringBuilder sql) throws Sparql.Error {
 		if (!accept (SparqlTokenType.ISURI)) {
 			expect (SparqlTokenType.ISIRI);
 		}
@@ -327,7 +327,7 @@ class Tracker.Sparql.Expression : Object {
 		expect (SparqlTokenType.CLOSE_PARENS);
 	}
 
-	void translate_datatype (StringBuilder sql) throws SparqlError {
+	void translate_datatype (StringBuilder sql) throws Sparql.Error {
 		expect (SparqlTokenType.DATATYPE);
 		expect (SparqlTokenType.OPEN_PARENS);
 
@@ -356,7 +356,7 @@ class Tracker.Sparql.Expression : Object {
 		expect (SparqlTokenType.CLOSE_PARENS);
 	}
 
-	PropertyType translate_function (StringBuilder sql, string uri) throws SparqlError {
+	PropertyType translate_function (StringBuilder sql, string uri) throws Sparql.Error {
 		if (uri == XSD_NS + "string") {
 			// conversion to string
 			translate_expression_as_string (sql);
@@ -663,7 +663,7 @@ class Tracker.Sparql.Expression : Object {
 		}
 	}
 
-	PropertyType parse_type_uri () throws SparqlError {
+	PropertyType parse_type_uri () throws Sparql.Error {
 		string type_iri;
 		PropertyType type;
 
@@ -707,7 +707,7 @@ class Tracker.Sparql.Expression : Object {
 		return type;
 	}
 
-	internal string parse_string_literal (out PropertyType type = null) throws SparqlError {
+	internal string parse_string_literal (out PropertyType type = null) throws Sparql.Error {
 		next ();
 		switch (last ()) {
 		case SparqlTokenType.STRING_LITERAL1:
@@ -782,7 +782,7 @@ class Tracker.Sparql.Expression : Object {
 		}
 	}
 
-	PropertyType translate_uri_expression (StringBuilder sql, string uri) throws SparqlError {
+	PropertyType translate_uri_expression (StringBuilder sql, string uri) throws Sparql.Error {
 		if (accept (SparqlTokenType.OPEN_PARENS)) {
 			// function
 			var result = translate_function (sql, uri);
@@ -798,7 +798,7 @@ class Tracker.Sparql.Expression : Object {
 		}
 	}
 
-	PropertyType translate_primary_expression (StringBuilder sql) throws SparqlError {
+	PropertyType translate_primary_expression (StringBuilder sql) throws Sparql.Error {
 		PropertyType type;
 
 		switch (current ()) {
@@ -986,7 +986,7 @@ class Tracker.Sparql.Expression : Object {
 		}
 	}
 
-	PropertyType translate_unary_expression (StringBuilder sql) throws SparqlError {
+	PropertyType translate_unary_expression (StringBuilder sql) throws Sparql.Error {
 		if (accept (SparqlTokenType.OP_NEG)) {
 			sql.append ("NOT (");
 			var optype = translate_primary_expression (sql);
@@ -1006,7 +1006,7 @@ class Tracker.Sparql.Expression : Object {
 		return translate_primary_expression (sql);
 	}
 
-	PropertyType translate_multiplicative_expression (StringBuilder sql) throws SparqlError {
+	PropertyType translate_multiplicative_expression (StringBuilder sql) throws Sparql.Error {
 		long begin = sql.len;
 		var optype = translate_unary_expression (sql);
 		while (true) {
@@ -1037,7 +1037,7 @@ class Tracker.Sparql.Expression : Object {
 		return optype;
 	}
 
-	PropertyType translate_additive_expression (StringBuilder sql) throws SparqlError {
+	PropertyType translate_additive_expression (StringBuilder sql) throws Sparql.Error {
 		long begin = sql.len;
 		var optype = translate_multiplicative_expression (sql);
 		while (true) {
@@ -1068,11 +1068,11 @@ class Tracker.Sparql.Expression : Object {
 		return optype;
 	}
 
-	PropertyType translate_numeric_expression (StringBuilder sql) throws SparqlError {
+	PropertyType translate_numeric_expression (StringBuilder sql) throws Sparql.Error {
 		return translate_additive_expression (sql);
 	}
 
-	PropertyType process_relational_expression (StringBuilder sql, long begin, uint n_bindings, PropertyType op1type, string operator) throws SparqlError {
+	PropertyType process_relational_expression (StringBuilder sql, long begin, uint n_bindings, PropertyType op1type, string operator) throws Sparql.Error {
 		sql.insert (begin, "(");
 		sql.append (operator);
 		var op2type = translate_numeric_expression (sql);
@@ -1088,7 +1088,7 @@ class Tracker.Sparql.Expression : Object {
 		return PropertyType.BOOLEAN;
 	}
 
-	PropertyType translate_in (StringBuilder sql, bool not) throws SparqlError {
+	PropertyType translate_in (StringBuilder sql, bool not) throws Sparql.Error {
 
 		if (not) {
 			sql.append (" NOT");
@@ -1108,7 +1108,7 @@ class Tracker.Sparql.Expression : Object {
 		return PropertyType.BOOLEAN;
 	}
 
-	PropertyType translate_relational_expression (StringBuilder sql) throws SparqlError {
+	PropertyType translate_relational_expression (StringBuilder sql) throws Sparql.Error {
 		long begin = sql.len;
 		// TODO: improve performance (linked list)
 		uint n_bindings = query.bindings.length ();
@@ -1134,11 +1134,11 @@ class Tracker.Sparql.Expression : Object {
 		return optype;
 	}
 
-	PropertyType translate_value_logical (StringBuilder sql) throws SparqlError {
+	PropertyType translate_value_logical (StringBuilder sql) throws Sparql.Error {
 		return translate_relational_expression (sql);
 	}
 
-	PropertyType translate_conditional_and_expression (StringBuilder sql) throws SparqlError {
+	PropertyType translate_conditional_and_expression (StringBuilder sql) throws Sparql.Error {
 		long begin = sql.len;
 		var optype = translate_value_logical (sql);
 		while (accept (SparqlTokenType.OP_AND)) {
@@ -1156,7 +1156,7 @@ class Tracker.Sparql.Expression : Object {
 		return optype;
 	}
 
-	PropertyType translate_conditional_or_expression (StringBuilder sql) throws SparqlError {
+	PropertyType translate_conditional_or_expression (StringBuilder sql) throws Sparql.Error {
 		long begin = sql.len;
 		var optype = translate_conditional_and_expression (sql);
 		while (accept (SparqlTokenType.OP_OR)) {
@@ -1174,11 +1174,11 @@ class Tracker.Sparql.Expression : Object {
 		return optype;
 	}
 
-	internal PropertyType translate_expression (StringBuilder sql) throws SparqlError {
+	internal PropertyType translate_expression (StringBuilder sql) throws Sparql.Error {
 		return translate_conditional_or_expression (sql);
 	}
 
-	PropertyType translate_bracketted_expression (StringBuilder sql) throws SparqlError {
+	PropertyType translate_bracketted_expression (StringBuilder sql) throws Sparql.Error {
 		expect (SparqlTokenType.OPEN_PARENS);
 
 		if (current () == SparqlTokenType.SELECT) {
@@ -1197,7 +1197,7 @@ class Tracker.Sparql.Expression : Object {
 		return optype;
 	}
 
-	PropertyType translate_aggregate_expression (StringBuilder sql) throws SparqlError {
+	PropertyType translate_aggregate_expression (StringBuilder sql) throws Sparql.Error {
 		expect (SparqlTokenType.OPEN_PARENS);
 		if (accept (SparqlTokenType.DISTINCT)) {
 			sql.append ("DISTINCT ");
@@ -1207,7 +1207,7 @@ class Tracker.Sparql.Expression : Object {
 		return optype;
 	}
 
-	internal PropertyType translate_constraint (StringBuilder sql) throws SparqlError {
+	internal PropertyType translate_constraint (StringBuilder sql) throws Sparql.Error {
 		switch (current ()) {
 		case SparqlTokenType.STR:
 		case SparqlTokenType.LANG:
diff --git a/src/libtracker-data/tracker-sparql-pattern.vala b/src/libtracker-data/tracker-sparql-pattern.vala
index 432b174..bbc5aeb 100644
--- a/src/libtracker-data/tracker-sparql-pattern.vala
+++ b/src/libtracker-data/tracker-sparql-pattern.vala
@@ -26,7 +26,7 @@ namespace Tracker.Sparql {
 
 		public Class? domain;
 
-		public string get_sql_query (Query query) throws SparqlError {
+		public string get_sql_query (Query query) throws Sparql.Error {
 			try {
 				var sql = new StringBuilder ();
 
@@ -142,7 +142,7 @@ namespace Tracker.Sparql {
 				}
 				return sql.str;
 			} catch (DBInterfaceError e) {
-				throw new SparqlError.INTERNAL (e.message);
+				throw new Sparql.Error.INTERNAL (e.message);
 			}
 		}
 	}
@@ -173,7 +173,7 @@ class Tracker.Sparql.Pattern : Object {
 		set { query.context = value; }
 	}
 
-	inline bool next () throws SparqlError {
+	inline bool next () throws Sparql.Error {
 		return query.next ();
 	}
 
@@ -181,15 +181,15 @@ class Tracker.Sparql.Pattern : Object {
 		return query.current ();
 	}
 
-	inline bool accept (SparqlTokenType type) throws SparqlError {
+	inline bool accept (SparqlTokenType type) throws Sparql.Error {
 		return query.accept (type);
 	}
 
-	SparqlError get_error (string msg) {
+	Sparql.Error get_error (string msg) {
 		return query.get_error (msg);
 	}
 
-	bool expect (SparqlTokenType type) throws SparqlError {
+	bool expect (SparqlTokenType type) throws Sparql.Error {
 		return query.expect (type);
 	}
 
@@ -230,7 +230,7 @@ class Tracker.Sparql.Pattern : Object {
 
 	TripleContext? triple_context;
 
-	internal SelectContext translate_select (StringBuilder sql, bool subquery = false, bool scalar_subquery = false) throws SparqlError {
+	internal SelectContext translate_select (StringBuilder sql, bool subquery = false, bool scalar_subquery = false) throws Sparql.Error {
 		SelectContext result;
 		if (scalar_subquery) {
 			result = new SelectContext.subquery (context);
@@ -416,7 +416,7 @@ class Tracker.Sparql.Pattern : Object {
 		return result;
 	}
 
-	internal void translate_exists (StringBuilder sql) throws SparqlError {
+	internal void translate_exists (StringBuilder sql) throws Sparql.Error {
 		bool not = accept (SparqlTokenType.NOT);
 		expect (SparqlTokenType.EXISTS);
 
@@ -454,7 +454,7 @@ class Tracker.Sparql.Pattern : Object {
 		sql.append (")");
 	}
 
-	internal string parse_var_or_term (StringBuilder? sql, out bool is_var) throws SparqlError {
+	internal string parse_var_or_term (StringBuilder? sql, out bool is_var) throws Sparql.Error {
 		string result = "";
 		is_var = false;
 		if (current () == SparqlTokenType.VAR) {
@@ -524,7 +524,7 @@ class Tracker.Sparql.Pattern : Object {
 		return result;
 	}
 
-	void parse_object_list (StringBuilder sql, bool in_simple_optional = false) throws SparqlError {
+	void parse_object_list (StringBuilder sql, bool in_simple_optional = false) throws Sparql.Error {
 		while (true) {
 			parse_object (sql, in_simple_optional);
 			if (accept (SparqlTokenType.COMMA)) {
@@ -534,7 +534,7 @@ class Tracker.Sparql.Pattern : Object {
 		}
 	}
 
-	void parse_property_list_not_empty (StringBuilder sql, bool in_simple_optional = false) throws SparqlError {
+	void parse_property_list_not_empty (StringBuilder sql, bool in_simple_optional = false) throws Sparql.Error {
 		while (true) {
 			var old_predicate = current_predicate;
 			var old_predicate_is_var = current_predicate_is_var;
@@ -578,12 +578,12 @@ class Tracker.Sparql.Pattern : Object {
 		}
 	}
 
-	void translate_filter (StringBuilder sql) throws SparqlError {
+	void translate_filter (StringBuilder sql) throws Sparql.Error {
 		expect (SparqlTokenType.FILTER);
 		expression.translate_constraint (sql);
 	}
 
-	void skip_filter () throws SparqlError {
+	void skip_filter () throws Sparql.Error {
 		expect (SparqlTokenType.FILTER);
 
 		switch (current ()) {
@@ -620,13 +620,13 @@ class Tracker.Sparql.Pattern : Object {
 		}
 	}
 
-	void start_triples_block (StringBuilder sql) throws SparqlError {
+	void start_triples_block (StringBuilder sql) throws Sparql.Error {
 		context = triple_context = new TripleContext (context);
 
 		sql.append ("SELECT ");
 	}
 
-	void end_triples_block (StringBuilder sql, ref bool first_where, bool in_group_graph_pattern) throws SparqlError {
+	void end_triples_block (StringBuilder sql, ref bool first_where, bool in_group_graph_pattern) throws Sparql.Error {
 		// remove last comma and space
 		sql.truncate (sql.len - 2);
 
@@ -724,7 +724,7 @@ class Tracker.Sparql.Pattern : Object {
 		context = context.parent_context;
 	}
 
-	void parse_triples (StringBuilder sql, long group_graph_pattern_start, ref bool in_triples_block, ref bool first_where, ref bool in_group_graph_pattern, bool found_simple_optional) throws SparqlError {
+	void parse_triples (StringBuilder sql, long group_graph_pattern_start, ref bool in_triples_block, ref bool first_where, ref bool in_group_graph_pattern, bool found_simple_optional) throws Sparql.Error {
 		while (true) {
 			if (current () != SparqlTokenType.VAR &&
 			    current () != SparqlTokenType.IRI_REF &&
@@ -847,7 +847,7 @@ class Tracker.Sparql.Pattern : Object {
 
 			// no match
 			return false;
-		} catch (SparqlError e) {
+		} catch (Sparql.Error e) {
 			return false;
 		} finally {
 			// in any case, go back to the start of the optional
@@ -855,7 +855,7 @@ class Tracker.Sparql.Pattern : Object {
 		}
 	}
 
-	internal Context translate_group_graph_pattern (StringBuilder sql) throws SparqlError {
+	internal Context translate_group_graph_pattern (StringBuilder sql) throws Sparql.Error {
 		expect (SparqlTokenType.OPEN_BRACE);
 
 		if (current () == SparqlTokenType.SELECT) {
@@ -1082,7 +1082,7 @@ class Tracker.Sparql.Pattern : Object {
 		return result;
 	}
 
-	void translate_group_or_union_graph_pattern (StringBuilder sql) throws SparqlError {
+	void translate_group_or_union_graph_pattern (StringBuilder sql) throws Sparql.Error {
 		Variable[] all_vars = { };
 		HashTable<Variable,int> all_var_set = new HashTable<Variable,int>.full (direct_hash, direct_equal, g_object_unref, null);
 
@@ -1202,7 +1202,7 @@ class Tracker.Sparql.Pattern : Object {
 		}
 	}
 
-	void parse_object (StringBuilder sql, bool in_simple_optional = false) throws SparqlError {
+	void parse_object (StringBuilder sql, bool in_simple_optional = false) throws Sparql.Error {
 		long begin_sql_len = sql.len;
 
 		bool object_is_var;
@@ -1228,7 +1228,7 @@ class Tracker.Sparql.Pattern : Object {
 				rdftype = true;
 				var cl = Ontologies.get_class_by_uri (object);
 				if (cl == null) {
-					throw new SparqlError.UNKNOWN_CLASS ("Unknown class `%s'".printf (object));
+					throw new Sparql.Error.UNKNOWN_CLASS ("Unknown class `%s'".printf (object));
 				}
 				db_table = cl.name;
 				subject_type = cl;
@@ -1239,7 +1239,7 @@ class Tracker.Sparql.Pattern : Object {
 					share_table = false;
 					is_fts_match = true;
 				} else {
-					throw new SparqlError.UNKNOWN_PROPERTY ("Unknown property `%s'".printf (current_predicate));
+					throw new Sparql.Error.UNKNOWN_PROPERTY ("Unknown property `%s'".printf (current_predicate));
 				}
 			} else {
 				if (current_predicate == "http://www.w3.org/2000/01/rdf-schema#domain";
@@ -1248,7 +1248,7 @@ class Tracker.Sparql.Pattern : Object {
 					// rdfs:domain
 					var domain = Ontologies.get_class_by_uri (object);
 					if (domain == null) {
-						throw new SparqlError.UNKNOWN_CLASS ("Unknown class `%s'".printf (object));
+						throw new Sparql.Error.UNKNOWN_CLASS ("Unknown class `%s'".printf (object));
 					}
 					var pv = context.predicate_variable_map.lookup (context.get_variable (current_subject));
 					if (pv == null) {
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index c4a2d9e..fef92a9 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -17,15 +17,6 @@
  * Boston, MA  02110-1301, USA.
  */
 
-public errordomain Tracker.SparqlError {
-	PARSE,
-	UNKNOWN_CLASS,
-	UNKNOWN_PROPERTY,
-	TYPE,
-	INTERNAL,
-	UNSUPPORTED
-}
-
 namespace Tracker.Sparql {
 	enum VariableState {
 		NONE,
@@ -291,7 +282,7 @@ public class Tracker.Sparql.Query : Object {
 		}
 	}
 
-	internal bool next () throws SparqlError {
+	internal bool next () throws Sparql.Error {
 		index = (index + 1) % BUFFER_SIZE;
 		size--;
 		if (size <= 0) {
@@ -314,7 +305,7 @@ public class Tracker.Sparql.Query : Object {
 		return tokens[last_index].type;
 	}
 
-	internal bool accept (SparqlTokenType type) throws SparqlError {
+	internal bool accept (SparqlTokenType type) throws Sparql.Error {
 		if (current () == type) {
 			next ();
 			return true;
@@ -322,15 +313,15 @@ public class Tracker.Sparql.Query : Object {
 		return false;
 	}
 
-	internal SparqlError get_error (string msg) {
-		return new SparqlError.PARSE ("%d.%d: syntax error, %s".printf (tokens[index].begin.line, tokens[index].begin.column, msg));
+	internal Sparql.Error get_error (string msg) {
+		return new Sparql.Error.PARSE ("%d.%d: syntax error, %s".printf (tokens[index].begin.line, tokens[index].begin.column, msg));
 	}
 
-	internal SparqlError get_internal_error (string msg) {
-		return new SparqlError.INTERNAL ("%d.%d: %s".printf (tokens[index].begin.line, tokens[index].begin.column, msg));
+	internal Sparql.Error get_internal_error (string msg) {
+		return new Sparql.Error.INTERNAL ("%d.%d: %s".printf (tokens[index].begin.line, tokens[index].begin.column, msg));
 	}
 
-	internal bool expect (SparqlTokenType type) throws SparqlError {
+	internal bool expect (SparqlTokenType type) throws Sparql.Error {
 		if (accept (type)) {
 			return true;
 		}
@@ -348,7 +339,7 @@ public class Tracker.Sparql.Query : Object {
 		index = 0;
 		try {
 			next ();
-		} catch (SparqlError e) {
+		} catch (Sparql.Error e) {
 			// this should never happen as this is the second time we scan this token
 			critical ("internal error: next in set_location failed");
 		}
@@ -359,7 +350,7 @@ public class Tracker.Sparql.Query : Object {
 		return ((string) (tokens[last_index].begin.pos + strip)).ndup ((tokens[last_index].end.pos - tokens[last_index].begin.pos - 2 * strip));
 	}
 
-	void parse_prologue () throws SparqlError {
+	void parse_prologue () throws Sparql.Error {
 		if (accept (SparqlTokenType.BASE)) {
 			expect (SparqlTokenType.IRI_REF);
 		}
@@ -375,7 +366,7 @@ public class Tracker.Sparql.Query : Object {
 		}
 	}
 
-	void prepare_execute () throws DBInterfaceError, SparqlError, DateError {
+	void prepare_execute () throws DBInterfaceError, Sparql.Error, DateError {
 		assert (!update_extensions);
 
 		scanner = new SparqlScanner ((char*) query_string, (long) query_string.size ());
@@ -395,7 +386,7 @@ public class Tracker.Sparql.Query : Object {
 		parse_prologue ();
 	}
 
-	public DBResultSet? execute () throws DBInterfaceError, SparqlError, DateError {
+	public DBResultSet? execute () throws DBInterfaceError, Sparql.Error, DateError {
 
 		prepare_execute ();
 
@@ -418,7 +409,7 @@ public class Tracker.Sparql.Query : Object {
 	}
 
 
-	public DBCursor? execute_cursor () throws DBInterfaceError, SparqlError, DateError {
+	public DBCursor? execute_cursor () throws DBInterfaceError, Sparql.Error, DateError {
 
 		prepare_execute ();
 
@@ -440,7 +431,7 @@ public class Tracker.Sparql.Query : Object {
 		}
 	}
 
-	public PtrArray? execute_update (bool blank) throws DataError, DBInterfaceError, SparqlError, DateError {
+	public PtrArray? execute_update (bool blank) throws DataError, DBInterfaceError, Sparql.Error, DateError {
 		assert (update_extensions);
 
 		scanner = new SparqlScanner ((char*) query_string, (long) query_string.size ());
@@ -492,7 +483,7 @@ public class Tracker.Sparql.Query : Object {
 		return blank_nodes;
 	}
 
-	DBStatement prepare_for_exec (string sql) throws DBInterfaceError, SparqlError, DateError {
+	DBStatement prepare_for_exec (string sql) throws DBInterfaceError, Sparql.Error, DateError {
 		var iface = DBManager.get_db_interface ();
 		var stmt = iface.create_statement ("%s", sql);
 
@@ -505,7 +496,7 @@ public class Tracker.Sparql.Query : Object {
 				} else if (binding.literal == "false" || binding.literal == "0") {
 					stmt.bind_int (i, 0);
 				} else {
-					throw new SparqlError.TYPE ("`%s' is not a valid boolean".printf (binding.literal));
+					throw new Sparql.Error.TYPE ("`%s' is not a valid boolean".printf (binding.literal));
 				}
 			} else if (binding.data_type == PropertyType.DATETIME) {
 				stmt.bind_int (i, string_to_date (binding.literal, null));
@@ -520,19 +511,19 @@ public class Tracker.Sparql.Query : Object {
 		return stmt;
 	}
 
-	DBResultSet? exec_sql (string sql) throws DBInterfaceError, SparqlError, DateError {
+	DBResultSet? exec_sql (string sql) throws DBInterfaceError, Sparql.Error, DateError {
 		var stmt = prepare_for_exec (sql);
 
 		return stmt.execute ();
 	}
 
-	DBCursor? exec_sql_cursor (string sql) throws DBInterfaceError, SparqlError, DateError {
+	DBCursor? exec_sql_cursor (string sql) throws DBInterfaceError, Sparql.Error, DateError {
 		var stmt = prepare_for_exec (sql);
 
 		return stmt.start_cursor ();
 	}
 
-	string get_select_query () throws DBInterfaceError, SparqlError, DateError {
+	string get_select_query () throws DBInterfaceError, Sparql.Error, DateError {
 		// SELECT query
 
 		// build SQL
@@ -544,15 +535,15 @@ public class Tracker.Sparql.Query : Object {
 		return sql.str;
 	}
 
-	DBResultSet? execute_select () throws DBInterfaceError, SparqlError, DateError {
+	DBResultSet? execute_select () throws DBInterfaceError, Sparql.Error, DateError {
 		return exec_sql (get_select_query ());
 	}
 
-	DBCursor? execute_select_cursor () throws DBInterfaceError, SparqlError, DateError {
+	DBCursor? execute_select_cursor () throws DBInterfaceError, Sparql.Error, DateError {
 		return exec_sql_cursor (get_select_query ());
 	}
 
-	string get_ask_query () throws DBInterfaceError, SparqlError, DateError {
+	string get_ask_query () throws DBInterfaceError, Sparql.Error, DateError {
 		// ASK query
 
 		var pattern_sql = new StringBuilder ();
@@ -579,15 +570,15 @@ public class Tracker.Sparql.Query : Object {
 		return sql.str;
 	}
 
-	DBResultSet? execute_ask () throws DBInterfaceError, SparqlError, DateError {
+	DBResultSet? execute_ask () throws DBInterfaceError, Sparql.Error, DateError {
 		return exec_sql (get_ask_query ());
 	}
 
-	DBCursor? execute_ask_cursor () throws DBInterfaceError, SparqlError, DateError {
+	DBCursor? execute_ask_cursor () throws DBInterfaceError, Sparql.Error, DateError {
 		return exec_sql_cursor (get_ask_query ());
 	}
 
-	private void parse_from_or_into_param () throws SparqlError {
+	private void parse_from_or_into_param () throws Sparql.Error {
 		if (accept (SparqlTokenType.IRI_REF)) {
 			current_graph = get_last_string (1);
 		} else if (accept (SparqlTokenType.PN_PREFIX)) {
@@ -600,7 +591,7 @@ public class Tracker.Sparql.Query : Object {
 		}
 	}
 
-	PtrArray? execute_insert_or_delete (bool blank) throws DBInterfaceError, DataError, SparqlError, DateError {
+	PtrArray? execute_insert_or_delete (bool blank) throws DBInterfaceError, DataError, Sparql.Error, DateError {
 		// INSERT or DELETE
 
 		if (accept (SparqlTokenType.WITH)) {
@@ -732,7 +723,7 @@ public class Tracker.Sparql.Query : Object {
 		return update_blank_nodes;
 	}
 
-	void execute_drop_graph () throws DBInterfaceError, DataError, SparqlError {
+	void execute_drop_graph () throws DBInterfaceError, DataError, Sparql.Error {
 		expect (SparqlTokenType.DROP);
 		expect (SparqlTokenType.GRAPH);
 
@@ -745,7 +736,7 @@ public class Tracker.Sparql.Query : Object {
 		Data.update_buffer_flush ();
 	}
 
-	internal string resolve_prefixed_name (string prefix, string local_name) throws SparqlError {
+	internal string resolve_prefixed_name (string prefix, string local_name) throws Sparql.Error {
 		string ns = prefix_map.lookup (prefix);
 		if (ns == null) {
 			throw get_error ("use of undefined prefix `%s'".printf (prefix));
@@ -753,7 +744,7 @@ public class Tracker.Sparql.Query : Object {
 		return ns + local_name;
 	}
 
-	void skip_braces () throws SparqlError {
+	void skip_braces () throws Sparql.Error {
 		expect (SparqlTokenType.OPEN_BRACE);
 		int n_braces = 1;
 		while (n_braces > 0) {
@@ -770,7 +761,7 @@ public class Tracker.Sparql.Query : Object {
 		}
 	}
 
-	void parse_construct_triples_block (HashTable<string,string> var_value_map) throws SparqlError, DataError, DateError {
+	void parse_construct_triples_block (HashTable<string,string> var_value_map) throws Sparql.Error, DataError, DateError {
 		expect (SparqlTokenType.OPEN_BRACE);
 
 		while (current () != SparqlTokenType.CLOSE_BRACE) {
@@ -807,7 +798,7 @@ public class Tracker.Sparql.Query : Object {
 
 	bool anon_blank_node_open = false;
 
-	string parse_construct_var_or_term (HashTable<string,string> var_value_map) throws SparqlError, DataError, DateError {
+	string parse_construct_var_or_term (HashTable<string,string> var_value_map) throws Sparql.Error, DataError, DateError {
 		string result = "";
 		if (current () == SparqlTokenType.VAR) {
 			next ();
@@ -892,7 +883,7 @@ public class Tracker.Sparql.Query : Object {
 		return result;
 	}
 
-	void parse_construct_property_list_not_empty (HashTable<string,string> var_value_map) throws SparqlError, DataError, DateError {
+	void parse_construct_property_list_not_empty (HashTable<string,string> var_value_map) throws Sparql.Error, DataError, DateError {
 		while (true) {
 			var old_predicate = current_predicate;
 
@@ -929,7 +920,7 @@ public class Tracker.Sparql.Query : Object {
 		}
 	}
 
-	void parse_construct_object_list (HashTable<string,string> var_value_map) throws SparqlError, DataError, DateError {
+	void parse_construct_object_list (HashTable<string,string> var_value_map) throws Sparql.Error, DataError, DateError {
 		while (true) {
 			parse_construct_object (var_value_map);
 			if (accept (SparqlTokenType.COMMA)) {
@@ -939,7 +930,7 @@ public class Tracker.Sparql.Query : Object {
 		}
 	}
 
-	void parse_construct_object (HashTable<string,string> var_value_map) throws SparqlError, DataError, DateError {
+	void parse_construct_object (HashTable<string,string> var_value_map) throws Sparql.Error, DataError, DateError {
 		string object = parse_construct_var_or_term (var_value_map);
 		try {
 			if (delete_statements) {
diff --git a/src/libtracker-data/tracker-sparql-scanner.vala b/src/libtracker-data/tracker-sparql-scanner.vala
index bef8d5c..7ba8ea1 100644
--- a/src/libtracker-data/tracker-sparql-scanner.vala
+++ b/src/libtracker-data/tracker-sparql-scanner.vala
@@ -430,7 +430,7 @@ public class Tracker.SparqlScanner : Object {
 		return (c.isalnum () || c == '_');
 	}
 
-	public SparqlTokenType read_token (out SourceLocation token_begin, out SourceLocation token_end) throws SparqlError {
+	public SparqlTokenType read_token (out SourceLocation token_begin, out SourceLocation token_end) throws Sparql.Error {
 		space ();
 
 		SparqlTokenType type;
@@ -651,14 +651,14 @@ public class Tracker.SparqlScanner : Object {
 								current += u.to_utf8 (null);
 								token_length_in_chars++;
 							} else {
-								throw new SparqlError.PARSE ("%d.%d: invalid UTF-8 character", line, column + token_length_in_chars);
+								throw new Sparql.Error.PARSE ("%d.%d: invalid UTF-8 character", line, column + token_length_in_chars);
 							}
 						}
 					}
 					if (current[0] == begin[0] && current[1] == begin[0] && current[2] == begin[0]) {
 						current += 3;
 					} else {
-						throw new SparqlError.PARSE ("%d.%d: syntax error, expected \"\"\"", line, column + token_length_in_chars);
+						throw new Sparql.Error.PARSE ("%d.%d: syntax error, expected \"\"\"", line, column + token_length_in_chars);
 					}
 					break;
 				}
@@ -692,7 +692,7 @@ public class Tracker.SparqlScanner : Object {
 							token_length_in_chars++;
 							break;
 						default:
-							throw new SparqlError.PARSE ("%d.%d: invalid escape sequence", line, column + token_length_in_chars);
+							throw new Sparql.Error.PARSE ("%d.%d: invalid escape sequence", line, column + token_length_in_chars);
 						}
 					} else if (current[0] == '\n') {
 						break;
@@ -703,14 +703,14 @@ public class Tracker.SparqlScanner : Object {
 							token_length_in_chars++;
 						} else {
 							current++;
-							throw new SparqlError.PARSE ("%d.%d: invalid UTF-8 character", line, column + token_length_in_chars);
+							throw new Sparql.Error.PARSE ("%d.%d: invalid UTF-8 character", line, column + token_length_in_chars);
 						}
 					}
 				}
 				if (current < end && current[0] != '\n') {
 					current++;
 				} else {
-					throw new SparqlError.PARSE ("%d.%d: syntax error, expected %c", line, column + token_length_in_chars, begin[0]);
+					throw new Sparql.Error.PARSE ("%d.%d: syntax error, expected %c", line, column + token_length_in_chars, begin[0]);
 				}
 				break;
 			case '^':
@@ -719,7 +719,7 @@ public class Tracker.SparqlScanner : Object {
 					type = SparqlTokenType.DOUBLE_CIRCUMFLEX;
 					current += 2;
 				} else {
-					throw new SparqlError.PARSE ("%d.%d: syntax error, unexpected character", line, column);
+					throw new Sparql.Error.PARSE ("%d.%d: syntax error, unexpected character", line, column);
 				}
 				break;
 			case '_':
@@ -729,9 +729,9 @@ public class Tracker.SparqlScanner : Object {
 			default:
 				unichar u = ((string) current).get_char_validated ((long) (end - current));
 				if (u != (unichar) (-1)) {
-					throw new SparqlError.PARSE ("%d.%d: syntax error, unexpected character", line, column);
+					throw new Sparql.Error.PARSE ("%d.%d: syntax error, unexpected character", line, column);
 				} else {
-					throw new SparqlError.PARSE ("%d.%d: invalid UTF-8 character", line, column);
+					throw new Sparql.Error.PARSE ("%d.%d: invalid UTF-8 character", line, column);
 				}
 			}
 		}
diff --git a/src/libtracker-data/tracker-turtle-reader.vala b/src/libtracker-data/tracker-turtle-reader.vala
index 2ab09e5..778a746 100644
--- a/src/libtracker-data/tracker-turtle-reader.vala
+++ b/src/libtracker-data/tracker-turtle-reader.vala
@@ -94,7 +94,7 @@ public class Tracker.TurtleReader : Object {
 		}
 	}
 
-	inline bool next_token () throws SparqlError {
+	inline bool next_token () throws Sparql.Error {
 		index = (index + 1) % BUFFER_SIZE;
 		size--;
 		if (size <= 0) {
@@ -112,7 +112,7 @@ public class Tracker.TurtleReader : Object {
 		return tokens[index].type;
 	}
 
-	inline bool accept (SparqlTokenType type) throws SparqlError {
+	inline bool accept (SparqlTokenType type) throws Sparql.Error {
 		if (current () == type) {
 			next_token ();
 			return true;
@@ -120,11 +120,11 @@ public class Tracker.TurtleReader : Object {
 		return false;
 	}
 
-	SparqlError get_error (string msg) {
-		return new SparqlError.PARSE ("%d.%d: syntax error, %s".printf (tokens[index].begin.line, tokens[index].begin.column, msg));
+	Sparql.Error get_error (string msg) {
+		return new Sparql.Error.PARSE ("%d.%d: syntax error, %s".printf (tokens[index].begin.line, tokens[index].begin.column, msg));
 	}
 
-	bool expect (SparqlTokenType type) throws SparqlError {
+	bool expect (SparqlTokenType type) throws Sparql.Error {
 		if (accept (type)) {
 			return true;
 		}
@@ -137,7 +137,7 @@ public class Tracker.TurtleReader : Object {
 		return ((string) (tokens[last_index].begin.pos + strip)).ndup ((tokens[last_index].end.pos - tokens[last_index].begin.pos - 2 * strip));
 	}
 
-	string resolve_prefixed_name (string prefix, string local_name) throws SparqlError {
+	string resolve_prefixed_name (string prefix, string local_name) throws Sparql.Error {
 		string ns = prefix_map.lookup (prefix);
 		if (ns == null) {
 			throw get_error ("use of undefined prefix `%s'".printf (prefix));
@@ -145,7 +145,7 @@ public class Tracker.TurtleReader : Object {
 		return ns + local_name;
 	}
 
-	public bool next () throws SparqlError {
+	public bool next () throws Sparql.Error {
 		while (true) {
 			switch (state) {
 			case State.INITIAL:
@@ -365,7 +365,7 @@ public class Tracker.TurtleReader : Object {
 		}
 	}
 
-	public static void load (string path) throws FileError, SparqlError, DataError, DateError, DBInterfaceError {
+	public static void load (string path) throws FileError, Sparql.Error, DataError, DateError, DBInterfaceError {
 		try {
 			Data.begin_transaction ();
 
diff --git a/src/libtracker-direct/tracker-direct.vala b/src/libtracker-direct/tracker-direct.vala
index 2044902..32953ae 100644
--- a/src/libtracker-direct/tracker-direct.vala
+++ b/src/libtracker-direct/tracker-direct.vala
@@ -33,14 +33,20 @@ public class Tracker.Direct.Connection : Tracker.Sparql.Connection {
 		initialized = false;
 	}
 
-	public override Sparql.Cursor? query (string sparql, Cancellable? cancellable) throws GLib.Error {
-		var query_object = new Sparql.Query (sparql);
-		var cursor = query_object.execute_cursor ();
-		cursor.connection = this;
-		return cursor;
+	public override Sparql.Cursor? query (string sparql, Cancellable? cancellable) throws Sparql.Error {
+		try {
+			var query_object = new Sparql.Query (sparql);
+			var cursor = query_object.execute_cursor ();
+			cursor.connection = this;
+			return cursor;
+		} catch (DBInterfaceError e) {
+			throw new Sparql.Error.INTERNAL (e.message);
+		} catch (DateError e) {
+			throw new Sparql.Error.PARSE (e.message);
+		}
 	}
 
-	public async override Sparql.Cursor? query_async (string sparql, Cancellable? cancellable = null) throws GLib.Error {
+	public async override Sparql.Cursor? query_async (string sparql, Cancellable? cancellable = null) throws Sparql.Error {
 		// just creating the cursor won't block
 		return query (sparql, cancellable);
 	}
diff --git a/src/tracker-store/Makefile.am b/src/tracker-store/Makefile.am
index 33e94e5..f5df592 100644
--- a/src/tracker-store/Makefile.am
+++ b/src/tracker-store/Makefile.am
@@ -9,6 +9,7 @@ INCLUDES =								\
 	-DTRACKER_COMPILATION						\
 	-I$(top_srcdir)/src						\
 	-I$(top_builddir)/src						\
+	-I$(top_builddir)/src/libtracker-sparql				\
 	-I$(top_builddir)/src/libtracker-data				\
 	$(WARN_CFLAGS)							\
 	$(GLIB2_CFLAGS)							\
diff --git a/tests/libtracker-data/Makefile.am b/tests/libtracker-data/Makefile.am
index 165624f..a12898d 100644
--- a/tests/libtracker-data/Makefile.am
+++ b/tests/libtracker-data/Makefile.am
@@ -63,6 +63,8 @@ INCLUDES = 								\
 	-I$(top_builddir)/src/libtracker-client				\
 	-I$(top_srcdir)/src/libtracker-data				\
 	-I$(top_builddir)/src/libtracker-data				\
+	-I$(top_srcdir)/src/libtracker-sparql				\
+	-I$(top_builddir)/src/libtracker-sparql				\
 	$(WARN_CFLAGS)							\
 	$(GCOV_CFLAGS)							\
 	$(DBUS_CFLAGS)							\
diff --git a/tests/libtracker-fts/Makefile.am b/tests/libtracker-fts/Makefile.am
index 910c561..06928be 100644
--- a/tests/libtracker-fts/Makefile.am
+++ b/tests/libtracker-fts/Makefile.am
@@ -25,6 +25,8 @@ INCLUDES = 								\
 	-I$(top_builddir)/src/libtracker-client				\
 	-I$(top_srcdir)/src/libtracker-data				\
 	-I$(top_builddir)/src/libtracker-data				\
+	-I$(top_srcdir)/src/libtracker-sparql				\
+	-I$(top_builddir)/src/libtracker-sparql				\
 	$(WARN_CFLAGS)							\
 	$(GCOV_CFLAGS)							\
 	$(DBUS_CFLAGS)							\



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