storage/src/mozStorageStatement.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2 * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozStorageStatement_h
michael@0 8 #define mozStorageStatement_h
michael@0 9
michael@0 10 #include "nsAutoPtr.h"
michael@0 11 #include "nsString.h"
michael@0 12
michael@0 13 #include "nsTArray.h"
michael@0 14
michael@0 15 #include "mozStorageBindingParamsArray.h"
michael@0 16 #include "mozStorageStatementData.h"
michael@0 17 #include "mozIStorageStatement.h"
michael@0 18 #include "mozIStorageValueArray.h"
michael@0 19 #include "StorageBaseStatementInternal.h"
michael@0 20 #include "mozilla/Attributes.h"
michael@0 21
michael@0 22 class nsIXPConnectJSObjectHolder;
michael@0 23 struct sqlite3_stmt;
michael@0 24
michael@0 25 namespace mozilla {
michael@0 26 namespace storage {
michael@0 27 class StatementJSHelper;
michael@0 28 class Connection;
michael@0 29
michael@0 30 class Statement MOZ_FINAL : public mozIStorageStatement
michael@0 31 , public mozIStorageValueArray
michael@0 32 , public StorageBaseStatementInternal
michael@0 33 {
michael@0 34 public:
michael@0 35 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 36 NS_DECL_MOZISTORAGESTATEMENT
michael@0 37 NS_DECL_MOZISTORAGEBASESTATEMENT
michael@0 38 NS_DECL_MOZISTORAGEBINDINGPARAMS
michael@0 39 // NS_DECL_MOZISTORAGEVALUEARRAY (methods in mozIStorageStatement)
michael@0 40 NS_DECL_STORAGEBASESTATEMENTINTERNAL
michael@0 41
michael@0 42 Statement();
michael@0 43
michael@0 44 /**
michael@0 45 * Initializes the object on aDBConnection by preparing the SQL statement
michael@0 46 * given by aSQLStatement.
michael@0 47 *
michael@0 48 * @param aDBConnection
michael@0 49 * The Connection object this statement is associated with.
michael@0 50 * @param aNativeConnection
michael@0 51 * The native Sqlite connection this statement is associated with.
michael@0 52 * @param aSQLStatement
michael@0 53 * The SQL statement to prepare that this object will represent.
michael@0 54 */
michael@0 55 nsresult initialize(Connection *aDBConnection,
michael@0 56 sqlite3* aNativeConnection,
michael@0 57 const nsACString &aSQLStatement);
michael@0 58
michael@0 59
michael@0 60 /**
michael@0 61 * Obtains the native statement pointer.
michael@0 62 */
michael@0 63 inline sqlite3_stmt *nativeStatement() { return mDBStatement; }
michael@0 64
michael@0 65 /**
michael@0 66 * Obtains and transfers ownership of the array of parameters that are bound
michael@0 67 * to this statment. This can be null.
michael@0 68 */
michael@0 69 inline already_AddRefed<BindingParamsArray> bindingParamsArray()
michael@0 70 {
michael@0 71 return mParamsArray.forget();
michael@0 72 }
michael@0 73
michael@0 74 private:
michael@0 75 ~Statement();
michael@0 76
michael@0 77 sqlite3_stmt *mDBStatement;
michael@0 78 uint32_t mParamCount;
michael@0 79 uint32_t mResultColumnCount;
michael@0 80 nsTArray<nsCString> mColumnNames;
michael@0 81 bool mExecuting;
michael@0 82
michael@0 83 /**
michael@0 84 * @return a pointer to the BindingParams object to use with our Bind*
michael@0 85 * method.
michael@0 86 */
michael@0 87 mozIStorageBindingParams *getParams();
michael@0 88
michael@0 89 /**
michael@0 90 * Holds the array of parameters to bind to this statement when we execute
michael@0 91 * it asynchronously.
michael@0 92 */
michael@0 93 nsRefPtr<BindingParamsArray> mParamsArray;
michael@0 94
michael@0 95 /**
michael@0 96 * The following two members are only used with the JS helper. They cache
michael@0 97 * the row and params objects.
michael@0 98 */
michael@0 99 nsCOMPtr<nsIXPConnectJSObjectHolder> mStatementParamsHolder;
michael@0 100 nsCOMPtr<nsIXPConnectJSObjectHolder> mStatementRowHolder;
michael@0 101
michael@0 102 /**
michael@0 103 * Internal version of finalize that allows us to tell it if it is being
michael@0 104 * called from the destructor so it can know not to dispatch events that
michael@0 105 * require a reference to us.
michael@0 106 *
michael@0 107 * @param aDestructing
michael@0 108 * Is the destructor calling?
michael@0 109 */
michael@0 110 nsresult internalFinalize(bool aDestructing);
michael@0 111
michael@0 112 friend class StatementJSHelper;
michael@0 113 };
michael@0 114
michael@0 115 } // storage
michael@0 116 } // mozilla
michael@0 117
michael@0 118 #endif // mozStorageStatement_h

mercurial