1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/ds/nsIArray.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,91 @@ 1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsISupports.idl" 1.10 + 1.11 +interface nsISimpleEnumerator; 1.12 + 1.13 +/** 1.14 + * nsIArray 1.15 + * 1.16 + * An indexed collection of elements. Provides basic functionality for 1.17 + * retrieving elements at a specific position, searching for 1.18 + * elements. Indexes are zero-based, such that the last element in the 1.19 + * array is stored at the index length-1. 1.20 + * 1.21 + * For an array which can be modified, see nsIMutableArray below. 1.22 + * 1.23 + * Neither interface makes any attempt to protect the individual 1.24 + * elements from modification. The convention is that the elements of 1.25 + * the array should not be modified. Documentation within a specific 1.26 + * interface should describe variations from this convention. 1.27 + * 1.28 + * It is also convention that if an interface provides access to an 1.29 + * nsIArray, that the array should not be QueryInterfaced to an 1.30 + * nsIMutableArray for modification. If the interface in question had 1.31 + * intended the array to be modified, it would have returned an 1.32 + * nsIMutableArray! 1.33 + * 1.34 + * null is a valid entry in the array, and as such any nsISupports 1.35 + * parameters may be null, except where noted. 1.36 + */ 1.37 +[scriptable, uuid(114744d9-c369-456e-b55a-52fe52880d2d)] 1.38 +interface nsIArray : nsISupports 1.39 +{ 1.40 + /** 1.41 + * length 1.42 + * 1.43 + * number of elements in the array. 1.44 + */ 1.45 + readonly attribute unsigned long length; 1.46 + 1.47 + /** 1.48 + * queryElementAt() 1.49 + * 1.50 + * Retrieve a specific element of the array, and QueryInterface it 1.51 + * to the specified interface. null is a valid result for 1.52 + * this method, but exceptions are thrown in other circumstances 1.53 + * 1.54 + * @param index position of element 1.55 + * @param uuid the IID of the requested interface 1.56 + * @param result the object, QI'd to the requested interface 1.57 + * 1.58 + * @throws NS_ERROR_NO_INTERFACE when an entry exists at the 1.59 + * specified index, but the requested interface is not 1.60 + * available. 1.61 + * @throws NS_ERROR_ILLEGAL_VALUE when index > length-1 1.62 + * 1.63 + */ 1.64 + void queryElementAt(in unsigned long index, 1.65 + in nsIIDRef uuid, 1.66 + [iid_is(uuid), retval] out nsQIResult result); 1.67 + 1.68 + /** 1.69 + * indexOf() 1.70 + * 1.71 + * Get the position of a specific element. Note that since null is 1.72 + * a valid input, exceptions are used to indicate that an element 1.73 + * is not found. 1.74 + * 1.75 + * @param startIndex The initial element to search in the array 1.76 + * To start at the beginning, use 0 as the 1.77 + * startIndex 1.78 + * @param element The element you are looking for 1.79 + * @returns a number >= startIndex which is the position of the 1.80 + * element in the array. 1.81 + * @throws NS_ERROR_FAILURE if the element was not in the array. 1.82 + */ 1.83 + unsigned long indexOf(in unsigned long startIndex, 1.84 + in nsISupports element); 1.85 + 1.86 + /** 1.87 + * enumerate the array 1.88 + * 1.89 + * @returns a new enumerator positioned at the start of the array 1.90 + * @throws NS_ERROR_FAILURE if the array is empty (to make it easy 1.91 + * to detect errors), or NS_ERROR_OUT_OF_MEMORY if out of memory. 1.92 + */ 1.93 + nsISimpleEnumerator enumerate(); 1.94 +};