From 8c34737c42be8b8fa7ef561305832aada199c0a0 Mon Sep 17 00:00:00 2001 From: Cedric RICARD Date: Fri, 29 Feb 2008 22:11:35 +0000 Subject: [PATCH] Added db helper functions --- calexium_lib/database/db_utils.anubis | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+), 0 deletions(-) diff --git a/calexium_lib/database/db_utils.anubis b/calexium_lib/database/db_utils.anubis index 312cdc4..ab4c73f 100644 --- a/calexium_lib/database/db_utils.anubis +++ b/calexium_lib/database/db_utils.anubis @@ -91,3 +91,35 @@ public define Maybe(SQLite3HeadersOrRow -> SQLite3Row) error(sql_error) then logError("DB", db_error(sql_error,msg));failure, ok(cursor) then success(cursor) }. + +// -- Extractors HELPERS --------------- + +public define List(String) + db_get_string_list + ( + SQLite3HeadersOrRow -> SQLite3Row table_cursor, + List(String) so_far + ) = + if table_cursor(next_row) is + { + error(sql_error) then logError("DB", db_error(sql_error, "db_get_string_list")); reverse(so_far), + no_more_row then reverse(so_far), //can't find the symbol in the table, because the row is empty + row(explorer) then + with s = text(explorer)(0), + db_get_string_list(table_cursor, [s . so_far]) + }. + +public define List(Int32) + db_get_integer_list + ( + SQLite3HeadersOrRow -> SQLite3Row table_cursor, + List(Int32) so_far + ) = + if table_cursor(next_row) is + { + error(sql_error) then logError("DB", db_error(sql_error, "db_get_integer_list")); reverse(so_far), + no_more_row then reverse(so_far), //can't find the symbol in the table, because the row is empty + row(explorer) then + with s = (Int32)db_integer(explorer)(0), + db_get_integer_list(table_cursor, [s . so_far]) + }. -- libgit2 0.21.4