Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
nsMdbTableEnumerator Class Reference

#include <nsGlobalHistory.h>

Inheritance diagram for nsMdbTableEnumerator:
Inheritance graph
[legend]
Collaboration diagram for nsMdbTableEnumerator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS NS_IMETHOD HasMoreElements (PRBool *_result)
NS_IMETHOD GetNext (nsISupports **_result)
virtual nsresult Init (nsIMdbEnv *aEnv, nsIMdbTable *aTable)
NS_DECL_ISUPPORTS NS_IMETHOD HasMoreElements (PRBool *_result)
NS_IMETHOD GetNext (nsISupports **_result)
virtual nsresult Init (nsIMdbEnv *aEnv, nsIMdbTable *aTable)
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.

Protected Member Functions

 nsMdbTableEnumerator ()
virtual ~nsMdbTableEnumerator ()
virtual PRBool IsResult (nsIMdbRow *aRow)=0
virtual nsresult ConvertToISupports (nsIMdbRow *aRow, nsISupports **aResult)=0
 nsMdbTableEnumerator ()
virtual ~nsMdbTableEnumerator ()
virtual PRBool IsResult (nsIMdbRow *aRow)=0
virtual nsresult ConvertToISupports (nsIMdbRow *aRow, nsISupports **aResult)=0

Protected Attributes

nsIMdbEnvmEnv

Private Attributes

nsIMdbTablemTable
nsIMdbTableRowCursormCursor
nsIMdbRowmCurrent

Detailed Description

Definition at line 73 of file nsGlobalHistory.h.


Constructor & Destructor Documentation

Definition at line 364 of file nsGlobalHistory.cpp.

virtual nsMdbTableEnumerator::~nsMdbTableEnumerator ( ) [protected, virtual]

Member Function Documentation

virtual nsresult nsMdbTableEnumerator::ConvertToISupports ( nsIMdbRow aRow,
nsISupports **  aResult 
) [protected, pure virtual]
virtual nsresult nsMdbTableEnumerator::ConvertToISupports ( nsIMdbRow aRow,
nsISupports **  aResult 
) [protected, pure virtual]
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:

NS_IMETHOD nsMdbTableEnumerator::GetNext ( nsISupports **  _result)
NS_IMETHODIMP nsMdbTableEnumerator::GetNext ( nsISupports **  _result)

Definition at line 445 of file nsGlobalHistory.cpp.

{
  nsresult rv;

  PRBool hasMore;
  rv = HasMoreElements(&hasMore);
  if (NS_FAILED(rv)) return rv;

  if (! hasMore)
    return NS_ERROR_UNEXPECTED;

  rv = ConvertToISupports(mCurrent, _result);

  NS_RELEASE(mCurrent);
  mCurrent = nsnull;

  return rv;
}

Here is the call graph for this function:

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 414 of file nsGlobalHistory.cpp.

{
  if (! mCurrent) {
    mdb_err err;

    while (1) {
      mdb_pos pos;
      err = mCursor->NextRow(mEnv, &mCurrent, &pos);
      if (err != 0) return NS_ERROR_FAILURE;

      // If there are no more rows, then bail.
      if (! mCurrent)
        break;

      // If this is a result, the stop.
      if (IsResult(mCurrent))
        break;

      // Otherwise, drop the ref to the row we retrieved, and continue
      // on to the next one.
      NS_RELEASE(mCurrent);
      mCurrent = nsnull;
    }
  }

  *_result = (mCurrent != nsnull);
  return NS_OK;
}

Here is the caller graph for this function:

virtual nsresult nsMdbTableEnumerator::Init ( nsIMdbEnv aEnv,
nsIMdbTable aTable 
) [virtual]
nsresult nsMdbTableEnumerator::Init ( nsIMdbEnv aEnv,
nsIMdbTable aTable 
) [virtual]

Definition at line 374 of file nsGlobalHistory.cpp.

{
  NS_PRECONDITION(aEnv != nsnull, "null ptr");
  if (! aEnv)
    return NS_ERROR_NULL_POINTER;

  NS_PRECONDITION(aTable != nsnull, "null ptr");
  if (! aTable)
    return NS_ERROR_NULL_POINTER;

  mEnv = aEnv;
  NS_ADDREF(mEnv);

  mTable = aTable;
  NS_ADDREF(mTable);

  mdb_err err;
  err = mTable->GetTableRowCursor(mEnv, -1, &mCursor);
  if (err != 0) return NS_ERROR_FAILURE;

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

virtual PRBool nsMdbTableEnumerator::IsResult ( nsIMdbRow aRow) [protected, pure virtual]
virtual PRBool nsMdbTableEnumerator::IsResult ( nsIMdbRow aRow) [protected, pure virtual]

Member Data Documentation

Definition at line 85 of file nsGlobalHistory.h.

Definition at line 84 of file nsGlobalHistory.h.

Definition at line 79 of file nsGlobalHistory.h.

Definition at line 83 of file nsGlobalHistory.h.


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