From 62a32ce6a13628b339c1391e1de0efdeea2dbe27 Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Tue, 7 Aug 2007 19:15:00 +0000 Subject: [PATCH] add SQLite bindings 2007-08-07 Juerg Billeter * vapi/sqlite3.vala: add SQLite bindings svn path=/trunk/; revision=433 --- ChangeLog | 4 ++++ vapi/sqlite3.vala | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 vapi/sqlite3.vala diff --git a/ChangeLog b/ChangeLog index a163b86..a00988b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2007-08-07 Jürg Billeter + * vapi/sqlite3.vala: add SQLite bindings + +2007-08-07 Jürg Billeter + * vapi/glib-2.0.vala: add stdin 2007-08-07 Jürg Billeter diff --git a/vapi/sqlite3.vala b/vapi/sqlite3.vala new file mode 100644 index 0000000..edb327b --- /dev/null +++ b/vapi/sqlite3.vala @@ -0,0 +1,64 @@ +/* sqlite3.vala + * + * Copyright (C) 2007 Jürg Billeter + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Author: + * Jürg Billeter + */ + +[CCode (lower_case_cprefix = "sqlite3_", cheader_filename = "sqlite3.h")] +namespace Sqlite { + [ReferenceType (free_function = "sqlite3_close")] + [CCode (cname = "sqlite3", cprefix = "sqlite3_")] + public struct Database { + public int exec (string! sql, Callback sqlite3_callback = null, pointer data = null, out string errmsg = null); + public int64 last_insert_rowid (); + public int changes (); + public int total_changes (); + public void interrupt (); + public int complete (string! sql); + public int get_table (string! sql, out string[] resultp, ref int nrow, ref int ncolumn, out string errmsg); + public static int open (string! filename, out Database db); + public int errcode (); + public weak string errmsg (); + public int prepare (string! sql, int n_bytes, out Statement stmt, out string tail = null); + } + + [CCode (cname = "sqlite3_callback")] + public static delegate int Callback (pointer data, int n_columns, string[] values, string[] column_names); + + [ReferenceType (free_function = "sqlite3_finalize")] + [CCode (cname = "sqlite3_stmt", cprefix = "sqlite3_")] + public struct Statement { + [NoArrayLength] + public int bind_blob (int index, uchar[] value, int n, GLib.DestroyNotify destroy_notify); + public int bind_double (int index, double value); + public int bind_int (int index, int value); + public int bind_int64 (int index, int64 value); + public int bind_null (int index); + public int bind_text (int index, string! value, int n, GLib.DestroyNotify destroy_notify); + public int bind_parameter_count (); + public string bind_parameter_name (int index); + public int bind_parameter_index (string! name); + public int clear_bindings (); + public int column_count (); + public string! column_name (int index); + public int step (); + public int column_int (int i_col); + } +} + -- 2.7.4