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 <stdint.h> |
8 #include <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
14 #include "sql/connection.h" | 15 #include "sql/connection.h" |
15 #include "sql/sql_export.h" | 16 #include "sql/sql_export.h" |
16 | 17 |
17 namespace sql { | 18 namespace sql { |
18 | 19 |
19 // Possible return values from ColumnType in a statement. These should match | 20 // Possible return values from ColumnType in a statement. These should match |
20 // the values in sqlite3.h. | 21 // the values in sqlite3.h. |
21 enum ColType { | 22 enum ColType { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 98 |
98 // Binding ------------------------------------------------------------------- | 99 // Binding ------------------------------------------------------------------- |
99 | 100 |
100 // These all take a 0-based argument index and return true on success. You | 101 // These all take a 0-based argument index and return true on success. You |
101 // may not always care about the return value (they'll DCHECK if they fail). | 102 // 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 | 103 // The main thing you may want to check is when binding large blobs or |
103 // strings there may be out of memory. | 104 // strings there may be out of memory. |
104 bool BindNull(int col); | 105 bool BindNull(int col); |
105 bool BindBool(int col, bool val); | 106 bool BindBool(int col, bool val); |
106 bool BindInt(int col, int val); | 107 bool BindInt(int col, int val); |
107 bool BindInt64(int col, int64 val); | 108 bool BindInt64(int col, int64_t val); |
108 bool BindDouble(int col, double val); | 109 bool BindDouble(int col, double val); |
109 bool BindCString(int col, const char* val); | 110 bool BindCString(int col, const char* val); |
110 bool BindString(int col, const std::string& val); | 111 bool BindString(int col, const std::string& val); |
111 bool BindString16(int col, const base::string16& value); | 112 bool BindString16(int col, const base::string16& value); |
112 bool BindBlob(int col, const void* value, int value_len); | 113 bool BindBlob(int col, const void* value, int value_len); |
113 | 114 |
114 // Retrieving ---------------------------------------------------------------- | 115 // Retrieving ---------------------------------------------------------------- |
115 | 116 |
116 // Returns the number of output columns in the result. | 117 // Returns the number of output columns in the result. |
117 int ColumnCount() const; | 118 int ColumnCount() const; |
118 | 119 |
119 // Returns the type associated with the given column. | 120 // Returns the type associated with the given column. |
120 // | 121 // |
121 // Watch out: the type may be undefined if you've done something to cause a | 122 // 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 | 123 // "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 | 124 // 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. | 125 // on a column before getting the value out in any way. |
125 ColType ColumnType(int col) const; | 126 ColType ColumnType(int col) const; |
126 ColType DeclaredColumnType(int col) const; | 127 ColType DeclaredColumnType(int col) const; |
127 | 128 |
128 // These all take a 0-based argument index. | 129 // These all take a 0-based argument index. |
129 bool ColumnBool(int col) const; | 130 bool ColumnBool(int col) const; |
130 int ColumnInt(int col) const; | 131 int ColumnInt(int col) const; |
131 int64 ColumnInt64(int col) const; | 132 int64_t ColumnInt64(int col) const; |
132 double ColumnDouble(int col) const; | 133 double ColumnDouble(int col) const; |
133 std::string ColumnString(int col) const; | 134 std::string ColumnString(int col) const; |
134 base::string16 ColumnString16(int col) const; | 135 base::string16 ColumnString16(int col) const; |
135 | 136 |
136 // When reading a blob, you can get a raw pointer to the underlying data, | 137 // 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 | 138 // 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! | 139 // vector. Danger! ColumnBlob may return NULL if there is no data! |
139 int ColumnByteLength(int col) const; | 140 int ColumnByteLength(int col) const; |
140 const void* ColumnBlob(int col) const; | 141 const void* ColumnBlob(int col) const; |
141 bool ColumnBlobAsString(int col, std::string* blob); | 142 bool ColumnBlobAsString(int col, std::string* blob); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 186 |
186 // See Succeeded() for what this holds. | 187 // See Succeeded() for what this holds. |
187 bool succeeded_; | 188 bool succeeded_; |
188 | 189 |
189 DISALLOW_COPY_AND_ASSIGN(Statement); | 190 DISALLOW_COPY_AND_ASSIGN(Statement); |
190 }; | 191 }; |
191 | 192 |
192 } // namespace sql | 193 } // namespace sql |
193 | 194 |
194 #endif // SQL_STATEMENT_H_ | 195 #endif // SQL_STATEMENT_H_ |
OLD | NEW |