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