Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes
nsStringEnumerator Class Reference
Inheritance diagram for nsStringEnumerator:
Inheritance graph
[legend]
Collaboration diagram for nsStringEnumerator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsStringEnumerator (const nsStringArray *aArray, PRBool aOwnsArray)
 nsStringEnumerator (const nsCStringArray *aArray, PRBool aOwnsArray)
 nsStringEnumerator (const nsStringArray *aArray, nsISupports *aOwner)
 nsStringEnumerator (const nsCStringArray *aArray, nsISupports *aOwner)
NS_DECL_ISUPPORTS
NS_DECL_NSIUTF8STRINGENUMERATOR
NS_IMETHOD 
GetNext (nsAString &aResult)
boolean hasMore ()
AString getNext ()
boolean hasMore ()
AUTF8String getNext ()
boolean hasMoreElements ()
 Called to determine whether or not the enumerator has any elements that can be returned via getNext().
nsISupports getNext ()
 Called to retrieve the next element in the enumerator.

Private Member Functions

 ~nsStringEnumerator ()
PRUint32 Count ()

Private Attributes

union {
const nsStringArray * mArray
const nsCStringArray * mCArray
}; 
PRUint32 mIndex
nsCOMPtr< nsISupports > mOwner
PRPackedBool mOwnsArray
PRPackedBool mIsUnicode

Detailed Description

Definition at line 52 of file nsStringEnumerator.cpp.


Constructor & Destructor Documentation

nsStringEnumerator::nsStringEnumerator ( const nsStringArray *  aArray,
PRBool  aOwnsArray 
) [inline]

Definition at line 57 of file nsStringEnumerator.cpp.

                                                                       :
        mArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_TRUE)
    {}
nsStringEnumerator::nsStringEnumerator ( const nsCStringArray *  aArray,
PRBool  aOwnsArray 
) [inline]

Definition at line 61 of file nsStringEnumerator.cpp.

                                                                        :
        mCArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_FALSE)
    {}
nsStringEnumerator::nsStringEnumerator ( const nsStringArray *  aArray,
nsISupports *  aOwner 
) [inline]

Definition at line 65 of file nsStringEnumerator.cpp.

                                                                         :
        mArray(aArray), mIndex(0), mOwner(aOwner), mOwnsArray(PR_FALSE), mIsUnicode(PR_TRUE)
    {}
nsStringEnumerator::nsStringEnumerator ( const nsCStringArray *  aArray,
nsISupports *  aOwner 
) [inline]

Definition at line 69 of file nsStringEnumerator.cpp.

                                                                          :
        mCArray(aArray), mIndex(0), mOwner(aOwner), mOwnsArray(PR_FALSE), mIsUnicode(PR_FALSE)
    {}

Definition at line 82 of file nsStringEnumerator.cpp.

                          {
        if (mOwnsArray) {
            // const-casting is safe here, because the NS_New*
            // constructors make sure mOwnsArray is consistent with
            // the constness of the objects
            if (mIsUnicode)
                delete NS_CONST_CAST(nsStringArray*,mArray);
            else
                delete NS_CONST_CAST(nsCStringArray*,mCArray);
        }
    }

Member Function Documentation

PRUint32 nsStringEnumerator::Count ( void  ) [inline, private]

Definition at line 99 of file nsStringEnumerator.cpp.

                            {
        return mIsUnicode ? mArray->Count() : mCArray->Count();
    }
AString nsIStringEnumerator::getNext ( ) [inherited]
AUTF8String nsIUTF8StringEnumerator::getNext ( ) [inherited]
NS_IMETHODIMP nsStringEnumerator::GetNext ( nsAString &  aResult)

Definition at line 134 of file nsStringEnumerator.cpp.

{
    if (mIsUnicode) {
        nsSupportsStringImpl* stringImpl = new nsSupportsStringImpl();
        if (!stringImpl) return NS_ERROR_OUT_OF_MEMORY;
        
        stringImpl->SetData(*mArray->StringAt(mIndex++));
        *aResult = stringImpl;
    }
    else {
        nsSupportsCStringImpl* cstringImpl = new nsSupportsCStringImpl();
        if (!cstringImpl) return NS_ERROR_OUT_OF_MEMORY;

        cstringImpl->SetData(*mCArray->CStringAt(mIndex++));
        *aResult = cstringImpl;
    }
    NS_ADDREF(*aResult);
    return NS_OK;
}

Here is the call graph for this function:

nsISupports nsISimpleEnumerator::getNext ( ) [inherited]

Called to retrieve the next element in the enumerator.

The "next" element is the first element upon the first call. Must be pre-ceeded by a call to hasMoreElements() which returns PR_TRUE. This method is generally called within a loop to iterate over the elements in the enumerator.

See also:
hasMoreElements()
Returns:
NS_OK if the call succeeded in returning a non-null value through the out parameter. NS_ERROR_FAILURE if there are no more elements to enumerate.
the next element in the enumeration.

Here is the caller graph for this function:

Called to determine whether or not the enumerator has any elements that can be returned via getNext().

This method is generally used to determine whether or not to initiate or continue iteration over the enumerator, though it can be called without subsequent getNext() calls. Does not affect internal state of enumerator.

See also:
getNext()
Returns:
PR_TRUE if there are remaining elements in the enumerator. PR_FALSE if there are no more elements in the enumerator.

Here is the caller graph for this function:


Member Data Documentation

union { ... } [private]

Definition at line 103 of file nsStringEnumerator.cpp.

Definition at line 111 of file nsStringEnumerator.cpp.

nsCOMPtr<nsISupports> nsStringEnumerator::mOwner [private]

Definition at line 109 of file nsStringEnumerator.cpp.

Definition at line 110 of file nsStringEnumerator.cpp.


The documentation for this class was generated from the following file: