1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/rdf/base/idl/nsIRDFContainer.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,94 @@ 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 +#include "nsIRDFDataSource.idl" 1.11 +#include "nsIRDFResource.idl" 1.12 +#include "nsIRDFNode.idl" 1.13 +#include "nsISimpleEnumerator.idl" 1.14 + 1.15 +// A wrapper for manipulating RDF containers 1.16 +[scriptable, uuid(D4214E90-FB94-11D2-BDD8-00104BDE6048)] 1.17 +interface nsIRDFContainer : nsISupports { 1.18 + readonly attribute nsIRDFDataSource DataSource; 1.19 + readonly attribute nsIRDFResource Resource; 1.20 + 1.21 + /** 1.22 + * Initialize the container wrapper to the specified resource 1.23 + * using the specified datasource for context. 1.24 + */ 1.25 + void Init(in nsIRDFDataSource aDataSource, in nsIRDFResource aContainer); 1.26 + 1.27 + /** 1.28 + * Return the number of elements in the container. Note that this 1.29 + * may not always be accurate due to aggregation. 1.30 + */ 1.31 + long GetCount(); 1.32 + 1.33 + /** 1.34 + * Return an enumerator that can be used to enumerate the contents 1.35 + * of the container in ascending order. 1.36 + */ 1.37 + nsISimpleEnumerator GetElements(); 1.38 + 1.39 + /** 1.40 + * Append an element to the container, assigning it the next 1.41 + * available ordinal. 1.42 + */ 1.43 + void AppendElement(in nsIRDFNode aElement); 1.44 + 1.45 + /** 1.46 + * Remove the first occurence of the specified element from the 1.47 + * container. If aRenumber is 'true', then the underlying RDF graph 1.48 + * will be 're-numbered' to account for the removal. 1.49 + */ 1.50 + void RemoveElement(in nsIRDFNode aElement, in boolean aRenumber); 1.51 + 1.52 + /** 1.53 + * Insert aElement at the specified index. If aRenumber is 'true', then 1.54 + * the underlying RDF graph will be 're-numbered' to accomodate the new 1.55 + * element. 1.56 + */ 1.57 + void InsertElementAt(in nsIRDFNode aElement, in long aIndex, in boolean aRenumber); 1.58 + 1.59 + /** 1.60 + * Remove the element at the specified index. If aRenumber is 'true', then 1.61 + * the underlying RDF graph will be 're-numbered' to account for the 1.62 + * removal. 1.63 + * 1.64 + * @return the element that was removed. 1.65 + */ 1.66 + nsIRDFNode RemoveElementAt(in long aIndex, in boolean aRenumber); 1.67 + 1.68 + /** 1.69 + * Determine the index of an element in the container. 1.70 + * 1.71 + * @return The index of the specified element in the container. If 1.72 + * the element is not contained in the container, this function 1.73 + * returns '-1'. 1.74 + */ 1.75 + long IndexOf(in nsIRDFNode aElement); 1.76 +}; 1.77 + 1.78 +%{C++ 1.79 +nsresult 1.80 +NS_NewRDFContainer(nsIRDFContainer** aResult); 1.81 + 1.82 +nsresult 1.83 +NS_NewRDFContainer(nsIRDFDataSource* aDataSource, 1.84 + nsIRDFResource* aResource, 1.85 + nsIRDFContainer** aResult); 1.86 + 1.87 +/** 1.88 + * Create a cursor on a container that enumerates its contents in 1.89 + * order 1.90 + */ 1.91 +nsresult 1.92 +NS_NewContainerEnumerator(nsIRDFDataSource* aDataSource, 1.93 + nsIRDFResource* aContainer, 1.94 + nsISimpleEnumerator** aResult); 1.95 + 1.96 + 1.97 +%}