Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: sql/statement.cc

Issue 9159020: Create a class to represent a DOM Storage Database. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: DomStorageDatabase for backing local storage to disk. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sql/statement.cc
diff --git a/sql/statement.cc b/sql/statement.cc
index a5daae49a6029f97b0950d4773a840cd5ac222cc..904d9ef4f1425ed4f37c192d2103e61e5c47a88e 100644
--- a/sql/statement.cc
+++ b/sql/statement.cc
@@ -4,6 +4,8 @@
#include "sql/statement.h"
+#include <algorithm>
+
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "third_party/sqlite/sqlite3.h"
@@ -155,6 +157,23 @@ ColType Statement::ColumnType(int col) const {
return static_cast<ColType>(sqlite3_column_type(ref_->stmt(), col));
}
+ColType Statement::DeclaredColumnType(int col) const {
+ std::string column_type(sqlite3_column_decltype(ref_->stmt(), col));
+ std::transform(column_type.begin(), column_type.end(), column_type.begin(),
+ ::tolower);
+
+ if (column_type == "integer")
+ return COLUMN_TYPE_INTEGER;
+ else if (column_type == "float")
+ return COLUMN_TYPE_FLOAT;
+ else if (column_type == "text")
+ return COLUMN_TYPE_TEXT;
+ else if (column_type == "blob")
+ return COLUMN_TYPE_BLOB;
+
+ return COLUMN_TYPE_NULL;
+}
+
bool Statement::ColumnBool(int col) const {
return !!ColumnInt(col);
}
@@ -251,6 +270,19 @@ bool Statement::ColumnBlobAsVector(
return ColumnBlobAsVector(col, reinterpret_cast< std::vector<char>* >(val));
}
+bool Statement::ColumnBlobAsString16(int col, string16* val) const {
+ if (!CheckValid())
+ return false;
+
+ const void* data = sqlite3_column_blob(ref_->stmt(), col);
+ int len = sqlite3_column_bytes(ref_->stmt(), col);
+ if (data && len > 0) {
+ val->resize(len);
+ val->assign(reinterpret_cast<const char16*>(data));
+ }
+ return true;
+}
+
const char* Statement::GetSQLStatement() {
return sqlite3_sql(ref_->stmt());
}

Powered by Google App Engine
This is Rietveld 408576698