lib/sqlite3: use a precise type as return of column_type
authorAlexis Laferrière <alexis.laf@xymus.net>
Wed, 16 Jul 2014 16:56:36 +0000 (12:56 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 16 Jul 2014 16:56:36 +0000 (12:56 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/sqlite3/native_sqlite3.nit

index 10cb886..f200b23 100644 (file)
@@ -89,6 +89,7 @@ extern class NativeStatement `{sqlite3_stmt*`}
                return NativeString_to_s(ret);
        `}
 
+       # Number of bytes in the blob or string at row `i`
        fun column_bytes(i: Int) : Int `{
                return sqlite3_column_bytes(recv, i);
        `}
@@ -109,7 +110,8 @@ extern class NativeStatement `{sqlite3_stmt*`}
                return NativeString_to_s(ret);
        `}
 
-       fun column_type(i: Int) : Int `{
+       # Type of the entry at row `i`
+       fun column_type(i: Int): DataType `{
                return sqlite3_column_type(recv, i);
        `}
 
@@ -169,3 +171,14 @@ extern class NativeSqlite3 `{sqlite3 *`}
                return sqlite3_errcode(recv);
        `}
 end
+
+# Sqlite data types
+extern class DataType `{ int `}
+       fun is_integer: Bool `{ return recv == SQLITE_INTEGER; `}
+       fun is_float: Bool `{ return recv == SQLITE_FLOAT; `}
+       fun is_blob: Bool `{ return recv == SQLITE_BLOB; `}
+       fun is_null: Bool `{ return recv == SQLITE_NULL; `}
+       fun is_text: Bool `{ return recv == SQLITE_TEXT; `}
+
+       fun to_i: Int `{ return recv; `}
+end