|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "nsISupports.idl" |
|
7 #include "nsIRDFDataSource.idl" |
|
8 #include "nsIRDFResource.idl" |
|
9 #include "nsIRDFNode.idl" |
|
10 #include "nsISimpleEnumerator.idl" |
|
11 |
|
12 // A wrapper for manipulating RDF containers |
|
13 [scriptable, uuid(D4214E90-FB94-11D2-BDD8-00104BDE6048)] |
|
14 interface nsIRDFContainer : nsISupports { |
|
15 readonly attribute nsIRDFDataSource DataSource; |
|
16 readonly attribute nsIRDFResource Resource; |
|
17 |
|
18 /** |
|
19 * Initialize the container wrapper to the specified resource |
|
20 * using the specified datasource for context. |
|
21 */ |
|
22 void Init(in nsIRDFDataSource aDataSource, in nsIRDFResource aContainer); |
|
23 |
|
24 /** |
|
25 * Return the number of elements in the container. Note that this |
|
26 * may not always be accurate due to aggregation. |
|
27 */ |
|
28 long GetCount(); |
|
29 |
|
30 /** |
|
31 * Return an enumerator that can be used to enumerate the contents |
|
32 * of the container in ascending order. |
|
33 */ |
|
34 nsISimpleEnumerator GetElements(); |
|
35 |
|
36 /** |
|
37 * Append an element to the container, assigning it the next |
|
38 * available ordinal. |
|
39 */ |
|
40 void AppendElement(in nsIRDFNode aElement); |
|
41 |
|
42 /** |
|
43 * Remove the first occurence of the specified element from the |
|
44 * container. If aRenumber is 'true', then the underlying RDF graph |
|
45 * will be 're-numbered' to account for the removal. |
|
46 */ |
|
47 void RemoveElement(in nsIRDFNode aElement, in boolean aRenumber); |
|
48 |
|
49 /** |
|
50 * Insert aElement at the specified index. If aRenumber is 'true', then |
|
51 * the underlying RDF graph will be 're-numbered' to accomodate the new |
|
52 * element. |
|
53 */ |
|
54 void InsertElementAt(in nsIRDFNode aElement, in long aIndex, in boolean aRenumber); |
|
55 |
|
56 /** |
|
57 * Remove the element at the specified index. If aRenumber is 'true', then |
|
58 * the underlying RDF graph will be 're-numbered' to account for the |
|
59 * removal. |
|
60 * |
|
61 * @return the element that was removed. |
|
62 */ |
|
63 nsIRDFNode RemoveElementAt(in long aIndex, in boolean aRenumber); |
|
64 |
|
65 /** |
|
66 * Determine the index of an element in the container. |
|
67 * |
|
68 * @return The index of the specified element in the container. If |
|
69 * the element is not contained in the container, this function |
|
70 * returns '-1'. |
|
71 */ |
|
72 long IndexOf(in nsIRDFNode aElement); |
|
73 }; |
|
74 |
|
75 %{C++ |
|
76 nsresult |
|
77 NS_NewRDFContainer(nsIRDFContainer** aResult); |
|
78 |
|
79 nsresult |
|
80 NS_NewRDFContainer(nsIRDFDataSource* aDataSource, |
|
81 nsIRDFResource* aResource, |
|
82 nsIRDFContainer** aResult); |
|
83 |
|
84 /** |
|
85 * Create a cursor on a container that enumerates its contents in |
|
86 * order |
|
87 */ |
|
88 nsresult |
|
89 NS_NewContainerEnumerator(nsIRDFDataSource* aDataSource, |
|
90 nsIRDFResource* aContainer, |
|
91 nsISimpleEnumerator** aResult); |
|
92 |
|
93 |
|
94 %} |