[tracker/return-types: 4/26] libtracker-data: Implement tracker_sqlite_cursor_get_value_type
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/return-types: 4/26] libtracker-data: Implement tracker_sqlite_cursor_get_value_type
- Date: Wed, 15 Sep 2010 13:55:44 +0000 (UTC)
commit bc80938b1f43c9371d72548386e91abdfb42fc43
Author: Jürg Billeter <j bitron ch>
Date: Wed Sep 8 18:39:38 2010 +0200
libtracker-data: Implement tracker_sqlite_cursor_get_value_type
src/libtracker-data/tracker-db-interface-sqlite.c | 27 ++++++++++++++++----
1 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c
index b87aa78..597b2aa 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -1383,13 +1383,28 @@ tracker_db_cursor_get_double (TrackerDBCursor *cursor, guint column)
TrackerSparqlValueType
tracker_db_cursor_get_value_type (TrackerDBCursor *cursor, guint column)
{
- /* TODO: Implement */
-
- g_critical ("Unimplemented");
-
- g_return_val_if_reached (TRACKER_SPARQL_VALUE_TYPE_UNBOUND);
+ gint n_columns = sqlite3_column_count (cursor->stmt);
- return TRACKER_SPARQL_VALUE_TYPE_UNBOUND;
+ g_return_val_if_fail (column >= 0 && column < n_columns, TRACKER_SPARQL_VALUE_TYPE_UNBOUND);
+
+ if (sqlite3_column_type (cursor->stmt, column) == SQLITE_NULL) {
+ return TRACKER_SPARQL_VALUE_TYPE_UNBOUND;
+ } else if (column < cursor->n_types) {
+ switch (cursor->types[column]) {
+ case TRACKER_PROPERTY_TYPE_RESOURCE:
+ return TRACKER_SPARQL_VALUE_TYPE_URI;
+ case TRACKER_PROPERTY_TYPE_INTEGER:
+ return TRACKER_SPARQL_VALUE_TYPE_INTEGER;
+ case TRACKER_PROPERTY_TYPE_DOUBLE:
+ return TRACKER_SPARQL_VALUE_TYPE_DOUBLE;
+ case TRACKER_PROPERTY_TYPE_DATETIME:
+ return TRACKER_SPARQL_VALUE_TYPE_DATETIME;
+ default:
+ return TRACKER_SPARQL_VALUE_TYPE_STRING;
+ }
+ } else {
+ return TRACKER_SPARQL_VALUE_TYPE_STRING;
+ }
}
const gchar*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]