[SCM] Lisaac library sqlite-binding branch, master, updated. 1975ba97ddd07a2b12ac587187301ab430d324a9

Jeremy Cowgar jeremy at cowgar.com
Tue Nov 11 04:49:51 UTC 2008


The following commit has been merged in the master branch:
commit 1975ba97ddd07a2b12ac587187301ab430d324a9
Author: Jeremy Cowgar <jeremy at cowgar.com>
Date:   Mon Nov 10 23:48:23 2008 -0500

    * Fixed bugs/typos in Column information section
    * Added `index` to return the column index of a given column name
    * Added field_as_* methods to retrieve field data by name instead
      of by index. These need better names (conflict with as_*)

diff --git a/sqlite_statement.li b/sqlite_statement.li
index d8837ee..3e07b60 100644
--- a/sqlite_statement.li
+++ b/sqlite_statement.li
@@ -184,12 +184,42 @@ Section Public
 	);
 
 Section Public
+	// Column Values (by name)
+
+	- field_as_integer name:ABSTRACT_STRING :INTEGER <-
+	// Get the value of `name` as an integer.
+	(
+		as_integer (index name)
+	);
+
+	- field_as_integer64 name:ABSTRACT_STRING :INTEGER <-
+	// Get the value of `name` as a 64bit integer.
+	(
+		as_integer64 (index name)
+	);
+
+	- field_as_double name:ABSTRACT_STRING :REAL_64 <-
+	// Get the value of `name` as a double.
+	(
+		as_double (index name)
+	);
+
+	- field_as_string name:ABSTRACT_STRING :STRING <-
+	// Get the value of `name` as a string.
+	(
+		as_string (index name)
+	);
+
+Section Public
 	// Column Information
 
 	- count :INTEGER <-
 	// Get the number of columns in the prepared statement.
 	(
 		+ stmt:POINTER;
+
+		stmt := pointer;
+
 		`sqlite3_column_count(@stmt)`:INTEGER
 	);
 
@@ -197,7 +227,9 @@ Section Public
 	// Get the column type of column `col`.
 	(
 		+ stmt :POINTER;
+
 		stmt := pointer;
+
 		`sqlite3_column_type(@stmt, @col)`:INTEGER
 	);
 
@@ -208,7 +240,7 @@ Section Public
 		+ n_name:NATIVE_ARRAY[CHARACTER];
 		+ result:STRING;
 
-		stmt := POINTER;
+		stmt := pointer;
 		n_name := `sqlite3_column_decltype(@stmt, @col)`:NATIVE_ARRAY[CHARACTER];
 
 		result := STRING.clone;
@@ -223,7 +255,7 @@ Section Public
 		+ n_name:NATIVE_ARRAY[CHARACTER];
 		+ result:STRING;
 
-		stmt := POINTER;
+		stmt := pointer;
 		n_name := `sqlite3_column_name(@stmt, @col)`:NATIVE_ARRAY[CHARACTER];
 
 		result := STRING.clone;
@@ -231,6 +263,28 @@ Section Public
 		result
 	);
 
+	- index colname:ABSTRACT_STRING :INTEGER <-
+	// Get the index of the column named `colname`.
+	(
+		// TODO: Cache this information, then search the cache
+		+ result:INTEGER;
+		+ idx:INTEGER;
+
+		result := -1;
+		idx := 0;
+
+		{ idx < count }.while_do {
+			(name idx == colname).if {
+				result := idx;
+				idx := count;
+			};
+
+			idx := idx + 1;
+		};
+
+		result
+	);
+
 	- table_name col:INTEGER :STRING <-
 	// Get the table name of column `col`.
 	(
@@ -238,7 +292,7 @@ Section Public
 		+ n_name:NATIVE_ARRAY[CHARACTER];
 		+ result:STRING;
 
-		stmt := POINTER;
+		stmt := pointer;
 		n_name := `sqlite3_column_table_name(@stmt, @col)`:NATIVE_ARRAY[CHARACTER];
 
 		result := STRING.clone;
@@ -253,7 +307,7 @@ Section Public
 		+ n_name:NATIVE_ARRAY[CHARACTER];
 		+ result:STRING;
 
-		stmt := POINTER;
+		stmt := pointer;
 		n_name := `sqlite3_column_database_name(@stmt, @col)`:NATIVE_ARRAY[CHARACTER];
 
 		result := STRING.clone;

-- 
Lisaac library sqlite-binding



More information about the Lisaac-commits mailing list