OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // you initialize it via Assign. | 48 // you initialize it via Assign. |
49 Statement(); | 49 Statement(); |
50 | 50 |
51 explicit Statement(scoped_refptr<Connection::StatementRef> ref); | 51 explicit Statement(scoped_refptr<Connection::StatementRef> ref); |
52 ~Statement(); | 52 ~Statement(); |
53 | 53 |
54 // Initializes this object with the given statement, which may or may not | 54 // Initializes this object with the given statement, which may or may not |
55 // be valid. Use is_valid() to check if it's OK. | 55 // be valid. Use is_valid() to check if it's OK. |
56 void Assign(scoped_refptr<Connection::StatementRef> ref); | 56 void Assign(scoped_refptr<Connection::StatementRef> ref); |
57 | 57 |
| 58 // Resets the statement to an uninitialized state corrosponding to |
| 59 // the default constructor, releasing the StatementRef. |
| 60 void Clear(); |
| 61 |
58 // Returns true if the statement can be executed. All functions can still | 62 // Returns true if the statement can be executed. All functions can still |
59 // be used if the statement is invalid, but they will return failure or some | 63 // be used if the statement is invalid, but they will return failure or some |
60 // default value. This is because the statement can become invalid in the | 64 // default value. This is because the statement can become invalid in the |
61 // middle of executing a command if there is a serious error and the database | 65 // middle of executing a command if there is a serious error and the database |
62 // has to be reset. | 66 // has to be reset. |
63 bool is_valid() const { return ref_->is_valid(); } | 67 bool is_valid() const { return ref_->is_valid(); } |
64 | 68 |
65 // These operators allow conveniently checking if the statement is valid | 69 // These operators allow conveniently checking if the statement is valid |
66 // or not. See the pattern above for an example. | 70 // or not. See the pattern above for an example. |
67 // TODO(shess,gbillock): Remove these once clients are converted. | 71 // TODO(shess,gbillock): Remove these once clients are converted. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 185 |
182 // See Succeeded() for what this holds. | 186 // See Succeeded() for what this holds. |
183 bool succeeded_; | 187 bool succeeded_; |
184 | 188 |
185 DISALLOW_COPY_AND_ASSIGN(Statement); | 189 DISALLOW_COPY_AND_ASSIGN(Statement); |
186 }; | 190 }; |
187 | 191 |
188 } // namespace sql | 192 } // namespace sql |
189 | 193 |
190 #endif // SQL_STATEMENT_H_ | 194 #endif // SQL_STATEMENT_H_ |
OLD | NEW |