| 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 #ifndef SQL_STATEMENT_H_ | 5 #ifndef SQL_STATEMENT_H_ |
| 6 #define SQL_STATEMENT_H_ | 6 #define SQL_STATEMENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // may not always care about the return value (they'll DCHECK if they fail). | 101 // may not always care about the return value (they'll DCHECK if they fail). |
| 102 // The main thing you may want to check is when binding large blobs or | 102 // The main thing you may want to check is when binding large blobs or |
| 103 // strings there may be out of memory. | 103 // strings there may be out of memory. |
| 104 bool BindNull(int col); | 104 bool BindNull(int col); |
| 105 bool BindBool(int col, bool val); | 105 bool BindBool(int col, bool val); |
| 106 bool BindInt(int col, int val); | 106 bool BindInt(int col, int val); |
| 107 bool BindInt64(int col, int64 val); | 107 bool BindInt64(int col, int64 val); |
| 108 bool BindDouble(int col, double val); | 108 bool BindDouble(int col, double val); |
| 109 bool BindCString(int col, const char* val); | 109 bool BindCString(int col, const char* val); |
| 110 bool BindString(int col, const std::string& val); | 110 bool BindString(int col, const std::string& val); |
| 111 bool BindString16(int col, const string16& value); | 111 bool BindString16(int col, const base::string16& value); |
| 112 bool BindBlob(int col, const void* value, int value_len); | 112 bool BindBlob(int col, const void* value, int value_len); |
| 113 | 113 |
| 114 // Retrieving ---------------------------------------------------------------- | 114 // Retrieving ---------------------------------------------------------------- |
| 115 | 115 |
| 116 // Returns the number of output columns in the result. | 116 // Returns the number of output columns in the result. |
| 117 int ColumnCount() const; | 117 int ColumnCount() const; |
| 118 | 118 |
| 119 // Returns the type associated with the given column. | 119 // Returns the type associated with the given column. |
| 120 // | 120 // |
| 121 // Watch out: the type may be undefined if you've done something to cause a | 121 // Watch out: the type may be undefined if you've done something to cause a |
| 122 // "type conversion." This means requesting the value of a column of a type | 122 // "type conversion." This means requesting the value of a column of a type |
| 123 // where that type is not the native type. For safety, call ColumnType only | 123 // where that type is not the native type. For safety, call ColumnType only |
| 124 // on a column before getting the value out in any way. | 124 // on a column before getting the value out in any way. |
| 125 ColType ColumnType(int col) const; | 125 ColType ColumnType(int col) const; |
| 126 ColType DeclaredColumnType(int col) const; | 126 ColType DeclaredColumnType(int col) const; |
| 127 | 127 |
| 128 // These all take a 0-based argument index. | 128 // These all take a 0-based argument index. |
| 129 bool ColumnBool(int col) const; | 129 bool ColumnBool(int col) const; |
| 130 int ColumnInt(int col) const; | 130 int ColumnInt(int col) const; |
| 131 int64 ColumnInt64(int col) const; | 131 int64 ColumnInt64(int col) const; |
| 132 double ColumnDouble(int col) const; | 132 double ColumnDouble(int col) const; |
| 133 std::string ColumnString(int col) const; | 133 std::string ColumnString(int col) const; |
| 134 string16 ColumnString16(int col) const; | 134 base::string16 ColumnString16(int col) const; |
| 135 | 135 |
| 136 // When reading a blob, you can get a raw pointer to the underlying data, | 136 // When reading a blob, you can get a raw pointer to the underlying data, |
| 137 // along with the length, or you can just ask us to copy the blob into a | 137 // along with the length, or you can just ask us to copy the blob into a |
| 138 // vector. Danger! ColumnBlob may return NULL if there is no data! | 138 // vector. Danger! ColumnBlob may return NULL if there is no data! |
| 139 int ColumnByteLength(int col) const; | 139 int ColumnByteLength(int col) const; |
| 140 const void* ColumnBlob(int col) const; | 140 const void* ColumnBlob(int col) const; |
| 141 bool ColumnBlobAsString(int col, std::string* blob); | 141 bool ColumnBlobAsString(int col, std::string* blob); |
| 142 bool ColumnBlobAsString16(int col, string16* val) const; | 142 bool ColumnBlobAsString16(int col, base::string16* val) const; |
| 143 bool ColumnBlobAsVector(int col, std::vector<char>* val) const; | 143 bool ColumnBlobAsVector(int col, std::vector<char>* val) const; |
| 144 bool ColumnBlobAsVector(int col, std::vector<unsigned char>* val) const; | 144 bool ColumnBlobAsVector(int col, std::vector<unsigned char>* val) const; |
| 145 | 145 |
| 146 // Diagnostics -------------------------------------------------------------- | 146 // Diagnostics -------------------------------------------------------------- |
| 147 | 147 |
| 148 // Returns the original text of sql statement. Do not keep a pointer to it. | 148 // Returns the original text of sql statement. Do not keep a pointer to it. |
| 149 const char* GetSQLStatement(); | 149 const char* GetSQLStatement(); |
| 150 | 150 |
| 151 private: | 151 private: |
| 152 // This is intended to check for serious errors and report them to the | 152 // This is intended to check for serious errors and report them to the |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 185 |
| 186 // See Succeeded() for what this holds. | 186 // See Succeeded() for what this holds. |
| 187 bool succeeded_; | 187 bool succeeded_; |
| 188 | 188 |
| 189 DISALLOW_COPY_AND_ASSIGN(Statement); | 189 DISALLOW_COPY_AND_ASSIGN(Statement); |
| 190 }; | 190 }; |
| 191 | 191 |
| 192 } // namespace sql | 192 } // namespace sql |
| 193 | 193 |
| 194 #endif // SQL_STATEMENT_H_ | 194 #endif // SQL_STATEMENT_H_ |
| OLD | NEW |