VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/ds/nsArray.h@ 101975

最後變更 在這個檔案從101975是 1,由 vboxsync 提交於 55 年 前

import

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 3.7 KB
 
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is XPCOM Array implementation.
16 *
17 * The Initial Developer of the Original Code
18 * Netscape Communications Corp.
19 * Portions created by the Initial Developer are Copyright (C) 2002
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 * Alec Flett <[email protected]>
24 *
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
36 *
37 * ***** END LICENSE BLOCK ***** */
38
39#ifndef nsArray_h__
40#define nsArray_h__
41
42#include "nsIArray.h"
43#include "nsCOMArray.h"
44#include "nsCOMPtr.h"
45
46#define NS_ARRAY_CLASSNAME \
47 "nsIArray implementation"
48
49// {35C66FD1-95E9-4e0a-80C5-C3BD2B375481}
50#define NS_ARRAY_CID \
51{ 0x35c66fd1, 0x95e9, 0x4e0a, \
52 { 0x80, 0xc5, 0xc3, 0xbd, 0x2b, 0x37, 0x54, 0x81 } }
53
54
55// create a new, empty array
56nsresult NS_COM
57NS_NewArray(nsIMutableArray** aResult);
58
59// The resulting array will hold an owning reference to every element
60// in the original nsCOMArray<T>. This also means that any further
61// changes to the original nsCOMArray<T> will not affect the new
62// array, and that the original array can go away and the new array
63// will still hold valid elements.
64nsresult NS_COM
65NS_NewArray(nsIMutableArray** aResult, const nsCOMArray_base& base);
66
67// adapter class to map nsIArray->nsCOMArray
68// do NOT declare this as a stack or member variable, use
69// nsCOMArray instead!
70// if you need to convert a nsCOMArray->nsIArray, see NS_NewArray above
71class nsArray : public nsIMutableArray
72{
73public:
74 nsArray() { }
75 nsArray(const nsCOMArray_base& aBaseArray) : mArray(aBaseArray)
76 { }
77
78 NS_DECL_ISUPPORTS
79 NS_DECL_NSIARRAY
80 NS_DECL_NSIMUTABLEARRAY
81
82private:
83 ~nsArray();
84
85 nsCOMArray_base mArray;
86};
87
88
89// helper class for do_QueryElementAt
90class NS_COM nsQueryArrayElementAt : public nsCOMPtr_helper
91 {
92 public:
93 nsQueryArrayElementAt(nsIArray* aArray, PRUint32 aIndex,
94 nsresult* aErrorPtr)
95 : mArray(aArray),
96 mIndex(aIndex),
97 mErrorPtr(aErrorPtr)
98 {
99 // nothing else to do here
100 }
101
102 virtual nsresult NS_FASTCALL operator()(const nsIID& aIID, void**) const;
103
104 private:
105 nsIArray* mArray;
106 PRUint32 mIndex;
107 nsresult* mErrorPtr;
108 };
109
110inline
111const nsQueryArrayElementAt
112do_QueryElementAt(nsIArray* aArray, PRUint32 aIndex, nsresult* aErrorPtr = 0)
113 {
114 return nsQueryArrayElementAt(aArray, aIndex, aErrorPtr);
115 }
116
117
118#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette