Bug 634734 - Fennec ASSERTION: mFUnitsConvFactor not valid: mFUnitsConvFactor > 0...
[mozilla-central.git] / storage / src / mozStorageStatement.h
blobae63a20f1970b06c09e72e5210c6d57ed84e305a
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 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is Oracle Corporation code.
18 * The Initial Developer of the Original Code is
19 * Oracle Corporation
20 * Portions created by the Initial Developer are Copyright (C) 2004
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
24 * Vladimir Vukicevic <vladimir.vukicevic@oracle.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef mozStorageStatement_h
41 #define mozStorageStatement_h
43 #include "nsAutoPtr.h"
44 #include "nsString.h"
46 #include "nsTArray.h"
48 #include "mozStorageBindingParamsArray.h"
49 #include "mozStorageStatementData.h"
50 #include "mozIStorageStatement.h"
51 #include "mozIStorageValueArray.h"
52 #include "StorageBaseStatementInternal.h"
54 class nsIXPConnectJSObjectHolder;
55 struct sqlite3_stmt;
57 namespace mozilla {
58 namespace storage {
59 class StatementJSHelper;
60 class Connection;
62 class Statement : public mozIStorageStatement
63 , public mozIStorageValueArray
64 , public StorageBaseStatementInternal
66 public:
67 NS_DECL_ISUPPORTS
68 NS_DECL_MOZISTORAGESTATEMENT
69 NS_DECL_MOZISTORAGEBASESTATEMENT
70 NS_DECL_MOZISTORAGEBINDINGPARAMS
71 // NS_DECL_MOZISTORAGEVALUEARRAY (methods in mozIStorageStatement)
72 NS_DECL_STORAGEBASESTATEMENTINTERNAL
74 Statement();
76 /**
77 * Initializes the object on aDBConnection by preparing the SQL statement
78 * given by aSQLStatement.
80 * @param aDBConnection
81 * The Connection object this statement is associated with.
82 * @param aSQLStatement
83 * The SQL statement to prepare that this object will represent.
85 nsresult initialize(Connection *aDBConnection,
86 const nsACString &aSQLStatement);
89 /**
90 * Obtains the native statement pointer.
92 inline sqlite3_stmt *nativeStatement() { return mDBStatement; }
94 /**
95 * Obtains and transfers ownership of the array of parameters that are bound
96 * to this statment. This can be null.
98 inline already_AddRefed<BindingParamsArray> bindingParamsArray()
100 return mParamsArray.forget();
103 private:
104 ~Statement();
106 sqlite3_stmt *mDBStatement;
107 PRUint32 mParamCount;
108 PRUint32 mResultColumnCount;
109 nsTArray<nsCString> mColumnNames;
110 bool mExecuting;
113 * @return a pointer to the BindingParams object to use with our Bind*
114 * method.
116 mozIStorageBindingParams *getParams();
119 * Holds the array of parameters to bind to this statement when we execute
120 * it asynchronously.
122 nsRefPtr<BindingParamsArray> mParamsArray;
125 * The following two members are only used with the JS helper. They cache
126 * the row and params objects.
128 nsCOMPtr<nsIXPConnectJSObjectHolder> mStatementParamsHolder;
129 nsCOMPtr<nsIXPConnectJSObjectHolder> mStatementRowHolder;
132 * Internal version of finalize that allows us to tell it if it is being
133 * called from the destructor so it can know not to dispatch events that
134 * require a reference to us.
136 * @param aDestructing
137 * Is the destructor calling?
139 nsresult internalFinalize(bool aDestructing);
141 friend class StatementJSHelper;
144 } // storage
145 } // mozilla
147 #endif // mozStorageStatement_h