sbTArrayStringEnumerator.cpp
Go to the documentation of this file.
1 /*
2 //
3 // BEGIN SONGBIRD GPL
4 //
5 // This file is part of the Songbird web player.
6 //
7 // Copyright(c) 2005-2008 POTI, Inc.
8 // http://songbirdnest.com
9 //
10 // This file may be licensed under the terms of of the
11 // GNU General Public License Version 2 (the "GPL").
12 //
13 // Software distributed under the License is distributed
14 // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
15 // express or implied. See the GPL for the specific language
16 // governing rights and limitations.
17 //
18 // You should have received a copy of the GPL along with this
19 // program. If not, go to http://www.gnu.org/licenses/gpl.html
20 // or write to the Free Software Foundation, Inc.,
21 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 //
23 // END SONGBIRD GPL
24 //
25 */
26 
28 
30 
32 sbTArrayStringEnumerator::New(const sbStringArray & aStringArray) {
33  return new sbTArrayStringEnumerator(&aStringArray);
34 }
35 
36 sbTArrayStringEnumerator::sbTArrayStringEnumerator(const sbStringArray* aStringArray) :
37  mNextIndex(0)
38 {
39  mStringArray.InsertElementsAt(0, *aStringArray);
40 };
41 
42 sbTArrayStringEnumerator::sbTArrayStringEnumerator(const sbCStringArray* aStringArray) :
43  mNextIndex(0)
44 {
45  for ( PRUint32 index = 0; index < aStringArray->Length(); index ++ ) {
46  mStringArray.AppendElement(NS_ConvertUTF8toUTF16((*aStringArray)[index]));
47  }
48 };
49 
50 NS_IMETHODIMP
51 sbTArrayStringEnumerator::HasMore(PRBool *_retval)
52 {
53  *_retval = mNextIndex < mStringArray.Length();
54  return NS_OK;
55 };
56 
57 NS_IMETHODIMP
58 sbTArrayStringEnumerator::GetNext(nsAString& _retval)
59 {
60  if (mNextIndex < mStringArray.Length()) {
61  _retval = mStringArray[mNextIndex];
62  mNextIndex++;
63  return NS_OK;
64  }
65  else {
66  return NS_ERROR_NOT_AVAILABLE;
67  }
68 };
69 
70 NS_IMPL_ISUPPORTS1(sbTArrayCStringEnumerator, nsIUTF8StringEnumerator)
71 
72 sbTArrayCStringEnumerator::sbTArrayCStringEnumerator(const sbStringArray* aStringArray) :
73  mNextIndex(0)
74 {
75  for ( PRUint32 index = 0; index < aStringArray->Length(); index ++ ) {
76  mCStringArray.AppendElement(NS_ConvertUTF16toUTF8((*aStringArray)[index]));
77  }
78 };
79 
80 sbTArrayCStringEnumerator::sbTArrayCStringEnumerator(const sbCStringArray* aCStringArray) :
81  mNextIndex(0)
82 {
83  mCStringArray.InsertElementsAt(0, *aCStringArray);
84 };
85 
86 NS_IMETHODIMP
87 sbTArrayCStringEnumerator::HasMore(PRBool *_retval)
88 {
89  *_retval = mNextIndex < mCStringArray.Length();
90  return NS_OK;
91 };
92 
93 NS_IMETHODIMP
94 sbTArrayCStringEnumerator::GetNext(nsACString& _retval)
95 {
96  if (mNextIndex < mCStringArray.Length()) {
97  _retval = mCStringArray[mNextIndex];
98  mNextIndex++;
99  return NS_OK;
100  }
101  else {
102  return NS_ERROR_NOT_AVAILABLE;
103  }
104 };
105 
106 
return NS_OK
NS_DECL_ISUPPORTS NS_DECL_NSIUTF8STRINGENUMERATOR sbTArrayCStringEnumerator(const sbStringArray *aStringArray)
NS_IMPL_ISUPPORTS1(sbDeviceCapabilitiesUtils, sbIDeviceCapabilitiesUtils) sbDeviceCapabilitiesUtils
sbTArrayStringEnumerator(const sbStringArray *aStringArray)