Back to index

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

List of all members.

Public Member Functions

 nsMsgDBEnumerator (nsMsgDatabase *db, nsIMdbTable *table, nsMsgDBEnumeratorFilter filter, void *closure)
virtual ~nsMsgDBEnumerator ()
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.

Public Attributes

NS_DECL_ISUPPORTS
NS_DECL_NSISIMPLEENUMERATOR
typedef nsresult(* 
nsMsgDBEnumeratorFilter )(nsIMsgDBHdr *hdr, void *closure)

Protected Member Functions

nsresult GetRowCursor ()
nsresult PrefetchNext ()

Protected Attributes

nsMsgDatabasemDB
nsIMdbTableRowCursormRowCursor
nsIMsgDBHdrmResultHdr
PRBool mDone
PRBool mNextPrefetched
nsMsgDBEnumeratorFilter mFilter
nsCOMPtr< nsIMdbTablemTable
voidmClosure

Detailed Description

Definition at line 2580 of file nsMsgDatabase.cpp.


Constructor & Destructor Documentation

Definition at line 2607 of file nsMsgDatabase.cpp.

Here is the call graph for this function:

Definition at line 2619 of file nsMsgDatabase.cpp.


Member Function Documentation

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:

Definition at line 2630 of file nsMsgDatabase.cpp.

{
  mDone = PR_FALSE;
  
  if (!mDB || !mTable)
    return NS_ERROR_NULL_POINTER;
              
  return mTable->GetTableRowCursor(mDB->GetEnv(), -1, &mRowCursor);
}

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:

Definition at line 2659 of file nsMsgDatabase.cpp.

{
  nsresult rv = NS_OK;
  nsIMdbRow* hdrRow;
  mdb_pos rowPos;
  PRUint32 flags;
  
  if (!mRowCursor)
  {
    rv = GetRowCursor();
    if (NS_FAILED(rv))
      return rv;
  }
  
  do
  {
    NS_IF_RELEASE(mResultHdr);
    mResultHdr = nsnull;
    rv = mRowCursor->NextRow(mDB->GetEnv(), &hdrRow, &rowPos);
    if (!hdrRow)
    {
      mDone = PR_TRUE;
      return NS_ERROR_FAILURE;
    }
    if (NS_FAILED(rv)) 
    {
      mDone = PR_TRUE;
      return rv;
    }
    //Get key from row
    mdbOid outOid;
    nsMsgKey key=0;
    if (hdrRow->GetOid(mDB->GetEnv(), &outOid) == NS_OK)
      key = outOid.mOid_Id;
    
    rv = mDB->GetHdrFromUseCache(key, &mResultHdr);
    if (NS_SUCCEEDED(rv) && mResultHdr)
      hdrRow->Release();
    else
      rv = mDB->CreateMsgHdr(hdrRow, key, &mResultHdr);
    if (NS_FAILED(rv))
      return rv;
    
    if (mResultHdr)
      mResultHdr->GetFlags(&flags);
    else
      flags = 0;
  } 
  while (mFilter && NS_FAILED(mFilter(mResultHdr, mClosure)) && !(flags & MSG_FLAG_EXPUNGED));
  
  if (mResultHdr) 
  {
    mNextPrefetched = PR_TRUE;
    return NS_OK;
  }
  return NS_ERROR_FAILURE;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 2604 of file nsMsgDatabase.cpp.

Definition at line 2597 of file nsMsgDatabase.cpp.

Definition at line 2600 of file nsMsgDatabase.cpp.

Definition at line 2602 of file nsMsgDatabase.cpp.

Definition at line 2601 of file nsMsgDatabase.cpp.

Definition at line 2599 of file nsMsgDatabase.cpp.

Definition at line 2598 of file nsMsgDatabase.cpp.

Definition at line 2603 of file nsMsgDatabase.cpp.

Definition at line 2588 of file nsMsgDatabase.cpp.


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