michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsISimpleEnumerator; michael@0: michael@0: /** michael@0: * nsIArray michael@0: * michael@0: * An indexed collection of elements. Provides basic functionality for michael@0: * retrieving elements at a specific position, searching for michael@0: * elements. Indexes are zero-based, such that the last element in the michael@0: * array is stored at the index length-1. michael@0: * michael@0: * For an array which can be modified, see nsIMutableArray below. michael@0: * michael@0: * Neither interface makes any attempt to protect the individual michael@0: * elements from modification. The convention is that the elements of michael@0: * the array should not be modified. Documentation within a specific michael@0: * interface should describe variations from this convention. michael@0: * michael@0: * It is also convention that if an interface provides access to an michael@0: * nsIArray, that the array should not be QueryInterfaced to an michael@0: * nsIMutableArray for modification. If the interface in question had michael@0: * intended the array to be modified, it would have returned an michael@0: * nsIMutableArray! michael@0: * michael@0: * null is a valid entry in the array, and as such any nsISupports michael@0: * parameters may be null, except where noted. michael@0: */ michael@0: [scriptable, uuid(114744d9-c369-456e-b55a-52fe52880d2d)] michael@0: interface nsIArray : nsISupports michael@0: { michael@0: /** michael@0: * length michael@0: * michael@0: * number of elements in the array. michael@0: */ michael@0: readonly attribute unsigned long length; michael@0: michael@0: /** michael@0: * queryElementAt() michael@0: * michael@0: * Retrieve a specific element of the array, and QueryInterface it michael@0: * to the specified interface. null is a valid result for michael@0: * this method, but exceptions are thrown in other circumstances michael@0: * michael@0: * @param index position of element michael@0: * @param uuid the IID of the requested interface michael@0: * @param result the object, QI'd to the requested interface michael@0: * michael@0: * @throws NS_ERROR_NO_INTERFACE when an entry exists at the michael@0: * specified index, but the requested interface is not michael@0: * available. michael@0: * @throws NS_ERROR_ILLEGAL_VALUE when index > length-1 michael@0: * michael@0: */ michael@0: void queryElementAt(in unsigned long index, michael@0: in nsIIDRef uuid, michael@0: [iid_is(uuid), retval] out nsQIResult result); michael@0: michael@0: /** michael@0: * indexOf() michael@0: * michael@0: * Get the position of a specific element. Note that since null is michael@0: * a valid input, exceptions are used to indicate that an element michael@0: * is not found. michael@0: * michael@0: * @param startIndex The initial element to search in the array michael@0: * To start at the beginning, use 0 as the michael@0: * startIndex michael@0: * @param element The element you are looking for michael@0: * @returns a number >= startIndex which is the position of the michael@0: * element in the array. michael@0: * @throws NS_ERROR_FAILURE if the element was not in the array. michael@0: */ michael@0: unsigned long indexOf(in unsigned long startIndex, michael@0: in nsISupports element); michael@0: michael@0: /** michael@0: * enumerate the array michael@0: * michael@0: * @returns a new enumerator positioned at the start of the array michael@0: * @throws NS_ERROR_FAILURE if the array is empty (to make it easy michael@0: * to detect errors), or NS_ERROR_OUT_OF_MEMORY if out of memory. michael@0: */ michael@0: nsISimpleEnumerator enumerate(); michael@0: };