|
1 /* -*- Mode: IDL; 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 #include "nsISerializable.idl" |
|
7 |
|
8 interface nsIEnumerator; |
|
9 |
|
10 [scriptable, uuid(83b6019c-cbc4-11d2-8cca-0060b0fc14a3)] |
|
11 interface nsICollection : nsISerializable |
|
12 { |
|
13 |
|
14 uint32_t Count(); |
|
15 nsISupports GetElementAt(in uint32_t index); |
|
16 void QueryElementAt(in uint32_t index, in nsIIDRef uuid, |
|
17 [iid_is(uuid),retval] out nsQIResult result); |
|
18 void SetElementAt(in uint32_t index, in nsISupports item); |
|
19 void AppendElement(in nsISupports item); |
|
20 void RemoveElement(in nsISupports item); |
|
21 |
|
22 nsIEnumerator Enumerate(); |
|
23 |
|
24 void Clear(); |
|
25 |
|
26 }; |
|
27 |
|
28 %{C++ |
|
29 |
|
30 #ifndef nsCOMPtr_h__ |
|
31 #include "nsCOMPtr.h" |
|
32 #endif |
|
33 |
|
34 class nsQueryElementAt : public nsCOMPtr_helper |
|
35 { |
|
36 public: |
|
37 nsQueryElementAt( nsICollection* aCollection, uint32_t aIndex, nsresult* aErrorPtr ) |
|
38 : mCollection(aCollection), |
|
39 mIndex(aIndex), |
|
40 mErrorPtr(aErrorPtr) |
|
41 { |
|
42 // nothing else to do here |
|
43 } |
|
44 |
|
45 virtual nsresult NS_FASTCALL operator()( const nsIID& aIID, void** ) const; |
|
46 |
|
47 private: |
|
48 nsICollection* mCollection; |
|
49 uint32_t mIndex; |
|
50 nsresult* mErrorPtr; |
|
51 }; |
|
52 |
|
53 inline |
|
54 const nsQueryElementAt |
|
55 do_QueryElementAt( nsICollection* aCollection, uint32_t aIndex, nsresult* aErrorPtr = 0 ) |
|
56 { |
|
57 return nsQueryElementAt(aCollection, aIndex, aErrorPtr); |
|
58 } |
|
59 |
|
60 %} |