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: #include "nsIRDFDataSource.idl" michael@0: #include "nsIRDFResource.idl" michael@0: #include "nsIRDFNode.idl" michael@0: #include "nsISimpleEnumerator.idl" michael@0: michael@0: // A wrapper for manipulating RDF containers michael@0: [scriptable, uuid(D4214E90-FB94-11D2-BDD8-00104BDE6048)] michael@0: interface nsIRDFContainer : nsISupports { michael@0: readonly attribute nsIRDFDataSource DataSource; michael@0: readonly attribute nsIRDFResource Resource; michael@0: michael@0: /** michael@0: * Initialize the container wrapper to the specified resource michael@0: * using the specified datasource for context. michael@0: */ michael@0: void Init(in nsIRDFDataSource aDataSource, in nsIRDFResource aContainer); michael@0: michael@0: /** michael@0: * Return the number of elements in the container. Note that this michael@0: * may not always be accurate due to aggregation. michael@0: */ michael@0: long GetCount(); michael@0: michael@0: /** michael@0: * Return an enumerator that can be used to enumerate the contents michael@0: * of the container in ascending order. michael@0: */ michael@0: nsISimpleEnumerator GetElements(); michael@0: michael@0: /** michael@0: * Append an element to the container, assigning it the next michael@0: * available ordinal. michael@0: */ michael@0: void AppendElement(in nsIRDFNode aElement); michael@0: michael@0: /** michael@0: * Remove the first occurence of the specified element from the michael@0: * container. If aRenumber is 'true', then the underlying RDF graph michael@0: * will be 're-numbered' to account for the removal. michael@0: */ michael@0: void RemoveElement(in nsIRDFNode aElement, in boolean aRenumber); michael@0: michael@0: /** michael@0: * Insert aElement at the specified index. If aRenumber is 'true', then michael@0: * the underlying RDF graph will be 're-numbered' to accomodate the new michael@0: * element. michael@0: */ michael@0: void InsertElementAt(in nsIRDFNode aElement, in long aIndex, in boolean aRenumber); michael@0: michael@0: /** michael@0: * Remove the element at the specified index. If aRenumber is 'true', then michael@0: * the underlying RDF graph will be 're-numbered' to account for the michael@0: * removal. michael@0: * michael@0: * @return the element that was removed. michael@0: */ michael@0: nsIRDFNode RemoveElementAt(in long aIndex, in boolean aRenumber); michael@0: michael@0: /** michael@0: * Determine the index of an element in the container. michael@0: * michael@0: * @return The index of the specified element in the container. If michael@0: * the element is not contained in the container, this function michael@0: * returns '-1'. michael@0: */ michael@0: long IndexOf(in nsIRDFNode aElement); michael@0: }; michael@0: michael@0: %{C++ michael@0: nsresult michael@0: NS_NewRDFContainer(nsIRDFContainer** aResult); michael@0: michael@0: nsresult michael@0: NS_NewRDFContainer(nsIRDFDataSource* aDataSource, michael@0: nsIRDFResource* aResource, michael@0: nsIRDFContainer** aResult); michael@0: michael@0: /** michael@0: * Create a cursor on a container that enumerates its contents in michael@0: * order michael@0: */ michael@0: nsresult michael@0: NS_NewContainerEnumerator(nsIRDFDataSource* aDataSource, michael@0: nsIRDFResource* aContainer, michael@0: nsISimpleEnumerator** aResult); michael@0: michael@0: michael@0: %}