| Index: gears/database2/statement.h |
| =================================================================== |
| --- gears/database2/statement.h (revision 1609) |
| +++ gears/database2/statement.h (working copy) |
| @@ -33,12 +33,11 @@ |
| // forward declarations |
| class Database2; |
| class Database2Transaction; |
| +class Database2Values; |
| -// represents Database2Statement |
| +// represents statement, for both synchronous and asynchronous operations |
| class Database2Statement { |
| public: |
| - Database2Statement() {} |
| - |
| bool HasCallback() const { |
| assert(callback_.get()); |
| return !JsTokenIsNullOrUndefined(callback_->token()); |
| @@ -59,16 +58,44 @@ |
| Database2Statement **instance); |
| std::string16 sql() const { return sql_statement_; } |
| - JsParamToSend *arguments() const { return sql_arguments_; } |
| - int num_arguments() const { return num_arguments_; } |
| + Database2Values *arguments() const { return arguments_.get(); } |
| private: |
| + Database2Statement() {} |
| + // if true, the statement has invalid arguments |
| + bool bogus_; |
| std::string16 sql_statement_; |
| - int num_arguments_; |
| - JsParamToSend *sql_arguments_; |
| + scoped_ptr<Database2Values> arguments_; |
| scoped_ptr<JsRootedCallback> callback_; |
| scoped_ptr<JsRootedCallback> error_callback_; |
| DISALLOW_EVIL_CONSTRUCTORS(Database2Statement); |
| }; |
| +// used for marshaling statement arguments to the database thread and |
| +// results to the main thread |
| +class Database2Values { |
| + public: |
| + ~Database2Values(); |
| + |
| + static bool CreateFromJsArray(const JsArray &sql_arguments, |
| + Database2Values **instance); |
| + |
| + int length() const { return length_; } |
| + JsParamType GetType(int index) const; |
| + int GetAsInt(int index) const; |
| + double GetAsDouble(int index) const; |
| + std::string16 &GetAsString(int index) const; |
| + private: |
| + Database2Values() {} |
| + |
| + static bool SetJsParamToSend(JsArray js_array, |
| + int index, |
| + JsParamToSend *param); |
| + |
| + scoped_array<JsParamToSend> arguments_; |
| + int length_; |
|
Aaron
2008/05/11 18:11:21
Should length be passed separately? The way it is
Dimitri
2008/05/13 22:52:03
On 2008/05/11 18:11:21, Aaron wrote:
> Should leng
|
| + |
| + DISALLOW_EVIL_CONSTRUCTORS(Database2Values); |
| +}; |
| + |
| #endif // GEARS_DATABASE2_STATEMENT_H__ |