VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/ds/nsStringEnumerator.h@ 4837

Last change on this file since 4837 was 1, checked in by vboxsync, 54 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
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 String Enumerator.
16 *
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corp.
19 * Portions created by the Initial Developer are Copyright (C) 2003
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 "nsIStringEnumerator.h"
40#include "nsVoidArray.h"
41
42// nsIStringEnumerator/nsIUTF8StringEnumerator implementations
43//
44// Currently all implementations support both interfaces. The
45// constructors below provide the most common interface for the given
46// type (i.e. nsIStringEnumerator for PRUnichar* strings, and so
47// forth) but any resulting enumerators can be queried to the other
48// type. Internally, the enumerators will hold onto the type that was
49// passed in and do conversion if GetNext() for the other type of
50// string is called.
51
52// There are a few different types of enumerators:
53
54//
55// These enumerators hold a pointer to the array. Be careful
56// because modifying the array may confuse the iterator, especially if
57// you insert or remove elements in the middle of the array.
58//
59
60// The non-adopting enumerator requires that the array sticks around
61// at least as long as the enumerator does. These are for constant
62// string arrays that the enumerator does not own, this could be used
63// in VERY specialized cases such as when the provider KNOWS that the
64// string enumerator will be consumed immediately, or will at least
65// outlast the array.
66// For example:
67//
68// nsCStringArray array;
69// array.AppendCString("abc");
70// array.AppendCString("def");
71// NS_NewStringEnumerator(&enumerator, &array, PR_TRUE);
72//
73// // call some internal method which iterates the enumerator
74// InternalMethod(enumerator);
75// NS_RELEASE(enumerator);
76//
77NS_COM nsresult
78NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
79 const nsCStringArray* aArray);
80
81NS_COM nsresult
82NS_NewStringEnumerator(nsIStringEnumerator** aResult,
83 const nsStringArray* aArray);
84
85// Adopting string enumerators assume ownership of the array and will
86// call |operator delete| on the array when the enumerator is destroyed
87// this is useful when the provider creates an array soley for the
88// purpose of creating the enumerator.
89// For example:
90//
91// nsCStringArray* array = new nsCStringArray;
92// array->AppendString("abcd");
93// NS_NewAdoptingStringEnumerator(&result, array);
94NS_COM nsresult
95NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult,
96 nsStringArray* aArray);
97
98NS_COM nsresult
99NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
100 nsCStringArray* aArray);
101
102
103// these versions take a refcounted "owner" which will be addreffed
104// when the enumerator is created, and destroyed when the enumerator
105// is released. This allows providers to give non-owning pointers to
106// ns*StringArray member variables without worrying about lifetime
107// issues
108// For example:
109//
110// nsresult MyClass::Enumerate(nsIUTF8StringEnumerator** aResult) {
111// mCategoryList->AppendString("abcd");
112// return NS_NewStringEnumerator(aResult, mCategoryList, this);
113// }
114//
115NS_COM nsresult
116NS_NewStringEnumerator(nsIStringEnumerator** aResult,
117 const nsStringArray* aArray,
118 nsISupports* aOwner);
119NS_COM nsresult
120NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
121 const nsCStringArray* aArray,
122 nsISupports* aOwner);
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use