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

Unified Diff: app/sql/statement.cc

Issue 1700017: Get rid of MetaTableHelper class and make use of the app/sql API in the LoginDatabase. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: fix rebase that removed the chrome_tests.gypi Created 10 years, 7 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
« no previous file with comments | « app/sql/statement.h ('k') | chrome/browser/history/starred_url_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/sql/statement.cc
diff --git a/app/sql/statement.cc b/app/sql/statement.cc
index 9f1d85a8cfee331c1c02bca34960e070b9facb1b..195b2d320c60f464d0db8212aa5a667f51829f7d 100644
--- a/app/sql/statement.cc
+++ b/app/sql/statement.cc
@@ -1,10 +1,11 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "app/sql/statement.h"
#include "base/logging.h"
+#include "base/utf_string_conversions.h"
#include "third_party/sqlite/preprocessed/sqlite3.h"
namespace sql {
@@ -117,6 +118,10 @@ bool Statement::BindString(int col, const std::string& val) {
return false;
}
+bool Statement::BindString16(int col, const string16& value) {
+ return BindString(col, UTF16ToUTF8(value));
+}
+
bool Statement::BindBlob(int col, const void* val, int val_len) {
if (is_valid()) {
int err = CheckError(sqlite3_bind_blob(ref_->stmt(), col + 1,
@@ -188,6 +193,15 @@ std::string Statement::ColumnString(int col) const {
return result;
}
+string16 Statement::ColumnString16(int col) const {
+ if (!is_valid()) {
+ NOTREACHED();
+ return string16();
+ }
+ std::string s = ColumnString(col);
+ return !s.empty() ? UTF8ToUTF16(s) : string16();
+}
+
int Statement::ColumnByteLength(int col) const {
if (!is_valid()) {
NOTREACHED();
@@ -205,6 +219,21 @@ const void* Statement::ColumnBlob(int col) const {
return sqlite3_column_blob(ref_->stmt(), col);
}
+bool Statement::ColumnBlobAsString(int col, std::string* blob) {
+ if (!is_valid()) {
+ NOTREACHED();
+ return false;
+ }
+ const void* p = ColumnBlob(col);
+ size_t len = ColumnByteLength(col);
+ blob->resize(len);
+ if (blob->size() != len) {
+ return false;
+ }
+ blob->assign(reinterpret_cast<const char*>(p), len);
+ return true;
+}
+
void Statement::ColumnBlobAsVector(int col, std::vector<char>* val) const {
val->clear();
if (!is_valid()) {
« no previous file with comments | « app/sql/statement.h ('k') | chrome/browser/history/starred_url_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698