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/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "third_party/sqlite/sqlite3.h" | 10 #include "third_party/sqlite/sqlite3.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 int Statement::ColumnCount() const { | 165 int Statement::ColumnCount() const { |
166 if (!is_valid()) | 166 if (!is_valid()) |
167 return 0; | 167 return 0; |
168 | 168 |
169 return sqlite3_column_count(ref_->stmt()); | 169 return sqlite3_column_count(ref_->stmt()); |
170 } | 170 } |
171 | 171 |
172 ColType Statement::ColumnType(int col) const { | 172 ColType Statement::ColumnType(int col) const { |
173 // Verify that our enum matches sqlite's values. | 173 // Verify that our enum matches sqlite's values. |
174 COMPILE_ASSERT(COLUMN_TYPE_INTEGER == SQLITE_INTEGER, integer_no_match); | 174 static_assert(COLUMN_TYPE_INTEGER == SQLITE_INTEGER, "integer no match"); |
175 COMPILE_ASSERT(COLUMN_TYPE_FLOAT == SQLITE_FLOAT, float_no_match); | 175 static_assert(COLUMN_TYPE_FLOAT == SQLITE_FLOAT, "float no match"); |
176 COMPILE_ASSERT(COLUMN_TYPE_TEXT == SQLITE_TEXT, integer_no_match); | 176 static_assert(COLUMN_TYPE_TEXT == SQLITE_TEXT, "integer no match"); |
177 COMPILE_ASSERT(COLUMN_TYPE_BLOB == SQLITE_BLOB, blob_no_match); | 177 static_assert(COLUMN_TYPE_BLOB == SQLITE_BLOB, "blob no match"); |
178 COMPILE_ASSERT(COLUMN_TYPE_NULL == SQLITE_NULL, null_no_match); | 178 static_assert(COLUMN_TYPE_NULL == SQLITE_NULL, "null no match"); |
179 | 179 |
180 return static_cast<ColType>(sqlite3_column_type(ref_->stmt(), col)); | 180 return static_cast<ColType>(sqlite3_column_type(ref_->stmt(), col)); |
181 } | 181 } |
182 | 182 |
183 ColType Statement::DeclaredColumnType(int col) const { | 183 ColType Statement::DeclaredColumnType(int col) const { |
184 std::string column_type(sqlite3_column_decltype(ref_->stmt(), col)); | 184 std::string column_type(sqlite3_column_decltype(ref_->stmt(), col)); |
185 base::StringToLowerASCII(&column_type); | 185 base::StringToLowerASCII(&column_type); |
186 | 186 |
187 if (column_type == "integer") | 187 if (column_type == "integer") |
188 return COLUMN_TYPE_INTEGER; | 188 return COLUMN_TYPE_INTEGER; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 320 |
321 int Statement::CheckError(int err) { | 321 int Statement::CheckError(int err) { |
322 // Please don't add DCHECKs here, OnSqliteError() already has them. | 322 // Please don't add DCHECKs here, OnSqliteError() already has them. |
323 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); | 323 succeeded_ = (err == SQLITE_OK || err == SQLITE_ROW || err == SQLITE_DONE); |
324 if (!succeeded_ && ref_.get() && ref_->connection()) | 324 if (!succeeded_ && ref_.get() && ref_->connection()) |
325 return ref_->connection()->OnSqliteError(err, this, NULL); | 325 return ref_->connection()->OnSqliteError(err, this, NULL); |
326 return err; | 326 return err; |
327 } | 327 } |
328 | 328 |
329 } // namespace sql | 329 } // namespace sql |
OLD | NEW |