| |
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| |
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
| |
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
| |
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| |
5 |
| |
6 #ifndef nsArrayUtils_h__ |
| |
7 #define nsArrayUtils_h__ |
| |
8 |
| |
9 #include "nsCOMPtr.h" |
| |
10 #include "nsIArray.h" |
| |
11 |
| |
12 // helper class for do_QueryElementAt |
| |
13 class NS_COM_GLUE nsQueryArrayElementAt : public nsCOMPtr_helper |
| |
14 { |
| |
15 public: |
| |
16 nsQueryArrayElementAt(nsIArray* aArray, uint32_t aIndex, |
| |
17 nsresult* aErrorPtr) |
| |
18 : mArray(aArray), |
| |
19 mIndex(aIndex), |
| |
20 mErrorPtr(aErrorPtr) |
| |
21 { |
| |
22 // nothing else to do here |
| |
23 } |
| |
24 |
| |
25 virtual nsresult NS_FASTCALL operator()(const nsIID& aIID, void**) const; |
| |
26 |
| |
27 private: |
| |
28 nsIArray* mArray; |
| |
29 uint32_t mIndex; |
| |
30 nsresult* mErrorPtr; |
| |
31 }; |
| |
32 |
| |
33 inline |
| |
34 const nsQueryArrayElementAt |
| |
35 do_QueryElementAt(nsIArray* aArray, uint32_t aIndex, nsresult* aErrorPtr = 0) |
| |
36 { |
| |
37 return nsQueryArrayElementAt(aArray, aIndex, aErrorPtr); |
| |
38 } |
| |
39 |
| |
40 #endif // nsArrayUtils_h__ |