| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "third_party/sqlite/sqlite3.h" | 10 #include "third_party/sqlite/sqlite3.h" |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 203 |
| 204 double Statement::ColumnDouble(int col) const { | 204 double Statement::ColumnDouble(int col) const { |
| 205 if (!CheckValid()) | 205 if (!CheckValid()) |
| 206 return 0; | 206 return 0; |
| 207 | 207 |
| 208 return sqlite3_column_double(ref_->stmt(), col); | 208 return sqlite3_column_double(ref_->stmt(), col); |
| 209 } | 209 } |
| 210 | 210 |
| 211 std::string Statement::ColumnString(int col) const { | 211 std::string Statement::ColumnString(int col) const { |
| 212 if (!CheckValid()) | 212 if (!CheckValid()) |
| 213 return ""; | 213 return std::string(); |
| 214 | 214 |
| 215 const char* str = reinterpret_cast<const char*>( | 215 const char* str = reinterpret_cast<const char*>( |
| 216 sqlite3_column_text(ref_->stmt(), col)); | 216 sqlite3_column_text(ref_->stmt(), col)); |
| 217 int len = sqlite3_column_bytes(ref_->stmt(), col); | 217 int len = sqlite3_column_bytes(ref_->stmt(), col); |
| 218 | 218 |
| 219 std::string result; | 219 std::string result; |
| 220 if (str && len > 0) | 220 if (str && len > 0) |
| 221 result.assign(str, len); | 221 result.assign(str, len); |
| 222 return result; | 222 return result; |
| 223 } | 223 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 | 307 |
| 308 int Statement::CheckError(int err) { | 308 int Statement::CheckError(int err) { |
| 309 // Please don't add DCHECKs here, OnSqliteError() already has them. | 309 // Please don't add DCHECKs here, OnSqliteError() already has them. |
| 310 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); | 310 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); |
| 311 if (!succeeded_ && ref_ && ref_->connection()) | 311 if (!succeeded_ && ref_ && ref_->connection()) |
| 312 return ref_->connection()->OnSqliteError(err, this); | 312 return ref_->connection()->OnSqliteError(err, this); |
| 313 return err; | 313 return err; |
| 314 } | 314 } |
| 315 | 315 |
| 316 } // namespace sql | 316 } // namespace sql |
| OLD | NEW |