From 765b445022c7f2a24bc862b45d48ece4ca9a77e1 Mon Sep 17 00:00:00 2001 From: "brettw@chromium.org" Date: Fri, 2 Oct 2009 05:01:42 +0000 Subject: Convert history to use new sql wrappers. Enhance wrappers in several ways to support the needs of history. BUG=none TEST=covered by unit tests Review URL: http://codereview.chromium.org/246053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27832 0039d316-1c4b-4281-b951-d872f2087c98 --- app/sql/statement.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'app/sql/statement.h') diff --git a/app/sql/statement.h b/app/sql/statement.h index 6211d34..8ee6ef5 100644 --- a/app/sql/statement.h +++ b/app/sql/statement.h @@ -14,6 +14,16 @@ namespace sql { +// Possible return values from ColumnType in a statement. These should match +// the values in sqlite3.h. +enum ColType { + COLUMN_TYPE_INTEGER = 1, + COLUMN_TYPE_FLOAT = 2, + COLUMN_TYPE_TEXT = 3, + COLUMN_TYPE_BLOB = 4, + COLUMN_TYPE_NULL = 5, +}; + // Normal usage: // sql::Statement s = connection_.GetUniqueStatement(...); // if (!s) // You should check for errors before using the statement. @@ -88,6 +98,7 @@ class Statement { // The main thing you may want to check is when binding large blobs or // strings there may be out of memory. bool BindNull(int col); + bool BindBool(int col, bool val); bool BindInt(int col, int val); bool BindInt64(int col, int64 val); bool BindDouble(int col, double val); @@ -100,7 +111,16 @@ class Statement { // Returns the number of output columns in the result. int ColumnCount() const; + // Returns the type associated with the given column. + // + // Watch out: the type may be undefined if you've done something to cause a + // "type conversion." This means requesting the value of a column of a type + // where that type is not the native type. For safety, call ColumnType only + // on a column before getting the value out in any way. + ColType ColumnType(int col) const; + // These all take a 0-based argument index. + bool ColumnBool(int col) const; int ColumnInt(int col) const; int64 ColumnInt64(int col) const; double ColumnDouble(int col) const; -- cgit v1.1