PageRenderTime 77ms CodeModel.GetById 73ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/gecko_sdk/idl/nsIArray.idl

http://firefox-mac-pdf.googlecode.com/
IDL | 126 lines | 13 code | 6 blank | 107 comment | 0 complexity | 4c756c64b121b57e274b366c140b9dfc MD5 | raw file
  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 interface.
 16 *
 17 * The Initial Developer of the Original Code is
 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 <alecf@netscape.com>
 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#include "nsISupports.idl"
 40
 41interface nsISimpleEnumerator;
 42
 43/**
 44 * nsIArray
 45 *
 46 * An indexed collection of elements. Provides basic functionality for
 47 * retrieving elements at a specific position, searching for
 48 * elements. Indexes are zero-based, such that the last element in the
 49 * array is stored at the index length-1.
 50 *
 51 * For an array which can be modified, see nsIMutableArray below.
 52 *
 53 * Neither interface makes any attempt to protect the individual
 54 * elements from modification. The convention is that the elements of
 55 * the array should not be modified. Documentation within a specific
 56 * interface should describe variations from this convention.
 57 *
 58 * It is also convention that if an interface provides access to an
 59 * nsIArray, that the array should not be QueryInterfaced to an
 60 * nsIMutableArray for modification. If the interface in question had
 61 * intended the array to be modified, it would have returned an
 62 * nsIMutableArray!
 63 *
 64 * null is a valid entry in the array, and as such any nsISupports
 65 * parameters may be null, except where noted.
 66 *
 67 * @status FROZEN
 68 */
 69[scriptable, uuid(114744d9-c369-456e-b55a-52fe52880d2d)]
 70interface nsIArray : nsISupports
 71{
 72    /**
 73     * length
 74     *
 75     * number of elements in the array.
 76     */
 77    readonly attribute unsigned long length;
 78
 79    /**
 80     * queryElementAt()
 81     *
 82     * Retrieve a specific element of the array, and QueryInterface it
 83     * to the specified interface. null is a valid result for
 84     * this method, but exceptions are thrown in other circumstances
 85     * 
 86     * @param index position of element
 87     * @param uuid the IID of the requested interface
 88     * @param result the object, QI'd to the requested interface
 89     *
 90     * @throws NS_ERROR_NO_INTERFACE when an entry exists at the
 91     *         specified index, but the requested interface is not
 92     *         available.
 93     * @throws NS_ERROR_ILLEGAL_VALUE when index > length-1
 94     *
 95     */
 96    void queryElementAt(in unsigned long index,
 97                        in nsIIDRef uuid,
 98                        [iid_is(uuid), retval] out nsQIResult result);
 99    
100    /**
101     * indexOf()
102     * 
103     * Get the position of a specific element. Note that since null is
104     * a valid input, exceptions are used to indicate that an element
105     * is not found.
106     * 
107     * @param startIndex The initial element to search in the array
108     *                   To start at the beginning, use 0 as the
109     *                   startIndex
110     * @param element    The element you are looking for
111     * @returns a number >= startIndex which is the position of the
112     *          element in the array.
113     * @throws NS_ERROR_NOT_FOUND if the element was not in the array.
114     */
115    unsigned long indexOf(in unsigned long startIndex,
116                          in nsISupports element);
117
118    /**
119     * enumerate the array
120     *
121     * @returns a new enumerator positioned at the start of the array
122     * @throws NS_ERROR_FAILURE if the array is empty (to make it easy
123     *         to detect errors)
124     */
125    nsISimpleEnumerator enumerate();
126};