michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozStorageStatement_h michael@0: #define mozStorageStatement_h michael@0: michael@0: #include "nsAutoPtr.h" michael@0: #include "nsString.h" michael@0: michael@0: #include "nsTArray.h" michael@0: michael@0: #include "mozStorageBindingParamsArray.h" michael@0: #include "mozStorageStatementData.h" michael@0: #include "mozIStorageStatement.h" michael@0: #include "mozIStorageValueArray.h" michael@0: #include "StorageBaseStatementInternal.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: class nsIXPConnectJSObjectHolder; michael@0: struct sqlite3_stmt; michael@0: michael@0: namespace mozilla { michael@0: namespace storage { michael@0: class StatementJSHelper; michael@0: class Connection; michael@0: michael@0: class Statement MOZ_FINAL : public mozIStorageStatement michael@0: , public mozIStorageValueArray michael@0: , public StorageBaseStatementInternal michael@0: { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_MOZISTORAGESTATEMENT michael@0: NS_DECL_MOZISTORAGEBASESTATEMENT michael@0: NS_DECL_MOZISTORAGEBINDINGPARAMS michael@0: // NS_DECL_MOZISTORAGEVALUEARRAY (methods in mozIStorageStatement) michael@0: NS_DECL_STORAGEBASESTATEMENTINTERNAL michael@0: michael@0: Statement(); michael@0: michael@0: /** michael@0: * Initializes the object on aDBConnection by preparing the SQL statement michael@0: * given by aSQLStatement. michael@0: * michael@0: * @param aDBConnection michael@0: * The Connection object this statement is associated with. michael@0: * @param aNativeConnection michael@0: * The native Sqlite connection this statement is associated with. michael@0: * @param aSQLStatement michael@0: * The SQL statement to prepare that this object will represent. michael@0: */ michael@0: nsresult initialize(Connection *aDBConnection, michael@0: sqlite3* aNativeConnection, michael@0: const nsACString &aSQLStatement); michael@0: michael@0: michael@0: /** michael@0: * Obtains the native statement pointer. michael@0: */ michael@0: inline sqlite3_stmt *nativeStatement() { return mDBStatement; } michael@0: michael@0: /** michael@0: * Obtains and transfers ownership of the array of parameters that are bound michael@0: * to this statment. This can be null. michael@0: */ michael@0: inline already_AddRefed bindingParamsArray() michael@0: { michael@0: return mParamsArray.forget(); michael@0: } michael@0: michael@0: private: michael@0: ~Statement(); michael@0: michael@0: sqlite3_stmt *mDBStatement; michael@0: uint32_t mParamCount; michael@0: uint32_t mResultColumnCount; michael@0: nsTArray mColumnNames; michael@0: bool mExecuting; michael@0: michael@0: /** michael@0: * @return a pointer to the BindingParams object to use with our Bind* michael@0: * method. michael@0: */ michael@0: mozIStorageBindingParams *getParams(); michael@0: michael@0: /** michael@0: * Holds the array of parameters to bind to this statement when we execute michael@0: * it asynchronously. michael@0: */ michael@0: nsRefPtr mParamsArray; michael@0: michael@0: /** michael@0: * The following two members are only used with the JS helper. They cache michael@0: * the row and params objects. michael@0: */ michael@0: nsCOMPtr mStatementParamsHolder; michael@0: nsCOMPtr mStatementRowHolder; michael@0: michael@0: /** michael@0: * Internal version of finalize that allows us to tell it if it is being michael@0: * called from the destructor so it can know not to dispatch events that michael@0: * require a reference to us. michael@0: * michael@0: * @param aDestructing michael@0: * Is the destructor calling? michael@0: */ michael@0: nsresult internalFinalize(bool aDestructing); michael@0: michael@0: friend class StatementJSHelper; michael@0: }; michael@0: michael@0: } // storage michael@0: } // mozilla michael@0: michael@0: #endif // mozStorageStatement_h