| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "sql/statement.h" | 5 #include "sql/statement.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 return sqlite3_column_bytes(ref_->stmt(), col); | 287 return sqlite3_column_bytes(ref_->stmt(), col); |
| 288 } | 288 } |
| 289 | 289 |
| 290 const void* Statement::ColumnBlob(int col) const { | 290 const void* Statement::ColumnBlob(int col) const { |
| 291 if (!CheckValid()) | 291 if (!CheckValid()) |
| 292 return NULL; | 292 return NULL; |
| 293 | 293 |
| 294 return sqlite3_column_blob(ref_->stmt(), col); | 294 return sqlite3_column_blob(ref_->stmt(), col); |
| 295 } | 295 } |
| 296 | 296 |
| 297 bool Statement::ColumnBlobAsString(int col, std::string* blob) { | 297 bool Statement::ColumnBlobAsString(int col, std::string* blob) const { |
| 298 if (!CheckValid()) | 298 if (!CheckValid()) |
| 299 return false; | 299 return false; |
| 300 | 300 |
| 301 const void* p = ColumnBlob(col); | 301 const void* p = ColumnBlob(col); |
| 302 size_t len = ColumnByteLength(col); | 302 size_t len = ColumnByteLength(col); |
| 303 blob->resize(len); | 303 blob->resize(len); |
| 304 if (blob->size() != len) { | 304 if (blob->size() != len) { |
| 305 return false; | 305 return false; |
| 306 } | 306 } |
| 307 blob->assign(reinterpret_cast<const char*>(p), len); | 307 blob->assign(reinterpret_cast<const char*>(p), len); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 | 357 |
| 358 int Statement::CheckError(int err) { | 358 int Statement::CheckError(int err) { |
| 359 // Please don't add DCHECKs here, OnSqliteError() already has them. | 359 // Please don't add DCHECKs here, OnSqliteError() already has them. |
| 360 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); | 360 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); |
| 361 if (!succeeded_ && ref_.get() && ref_->connection()) | 361 if (!succeeded_ && ref_.get() && ref_->connection()) |
| 362 return ref_->connection()->OnSqliteError(err, this, NULL); | 362 return ref_->connection()->OnSqliteError(err, this, NULL); |
| 363 return err; | 363 return err; |
| 364 } | 364 } |
| 365 | 365 |
| 366 } // namespace sql | 366 } // namespace sql |
| OLD | NEW |