Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes
nsGlobalHistory::URLEnumerator Class Reference

#include <nsGlobalHistory.h>

Inheritance diagram for nsGlobalHistory::URLEnumerator:
Inheritance graph
[legend]
Collaboration diagram for nsGlobalHistory::URLEnumerator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 URLEnumerator (mdb_column aURLColumn, mdb_column aHiddenColumn, mdb_column aSelectColumn=mdb_column(0), void *aSelectValue=nsnull, PRInt32 aSelectValueLen=0)
 URLEnumerator (mdb_column aURLColumn, mdb_column aHiddenColumn, mdb_column aSelectColumn=mdb_column(0), void *aSelectValue=nsnull, PRInt32 aSelectValueLen=0)
NS_DECL_ISUPPORTS NS_IMETHOD HasMoreElements (PRBool *_result)
NS_DECL_ISUPPORTS NS_IMETHOD HasMoreElements (PRBool *_result)
NS_IMETHOD GetNext (nsISupports **_result)
NS_IMETHOD GetNext (nsISupports **_result)
virtual nsresult Init (nsIMdbEnv *aEnv, nsIMdbTable *aTable)
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

virtual ~URLEnumerator ()
virtual PRBool IsResult (nsIMdbRow *aRow)
virtual nsresult ConvertToISupports (nsIMdbRow *aRow, nsISupports **aResult)
virtual ~URLEnumerator ()
virtual PRBool IsResult (nsIMdbRow *aRow)
virtual nsresult ConvertToISupports (nsIMdbRow *aRow, nsISupports **aResult)

Protected Attributes

mdb_column mURLColumn
mdb_column mHiddenColumn
mdb_column mSelectColumn
voidmSelectValue
PRInt32 mSelectValueLen
nsIMdbEnvmEnv

Detailed Description

Definition at line 384 of file nsGlobalHistory.h.


Constructor & Destructor Documentation

Definition at line 3780 of file nsGlobalHistory.cpp.

{
  nsMemory::Free(mSelectValue);
}
nsGlobalHistory::URLEnumerator::URLEnumerator ( mdb_column  aURLColumn,
mdb_column  aHiddenColumn,
mdb_column  aSelectColumn = mdb_column(0),
void aSelectValue = nsnull,
PRInt32  aSelectValueLen = 0 
) [inline]

Definition at line 396 of file nsGlobalHistory.h.

                                               :
      mURLColumn(aURLColumn),
      mHiddenColumn(aHiddenColumn),
      mSelectColumn(aSelectColumn),
      mSelectValue(aSelectValue),
      mSelectValueLen(aSelectValueLen)
    {}
virtual nsGlobalHistory::URLEnumerator::~URLEnumerator ( ) [protected, virtual]
nsGlobalHistory::URLEnumerator::URLEnumerator ( mdb_column  aURLColumn,
mdb_column  aHiddenColumn,
mdb_column  aSelectColumn = mdb_column(0),
void aSelectValue = nsnull,
PRInt32  aSelectValueLen = 0 
) [inline]

Definition at line 390 of file nsGlobalHistory.h.

                                               :
      mURLColumn(aURLColumn),
      mHiddenColumn(aHiddenColumn),
      mSelectColumn(aSelectColumn),
      mSelectValue(aSelectValue),
      mSelectValueLen(aSelectValueLen)
    {}

Member Function Documentation

virtual nsresult nsGlobalHistory::URLEnumerator::ConvertToISupports ( nsIMdbRow aRow,
nsISupports **  aResult 
) [protected, virtual]

Implements nsMdbTableEnumerator.

nsresult nsGlobalHistory::URLEnumerator::ConvertToISupports ( nsIMdbRow aRow,
nsISupports **  aResult 
) [protected, virtual]

Implements nsMdbTableEnumerator.

Definition at line 3817 of file nsGlobalHistory.cpp.

{
  mdb_err err;

  mdbYarn yarn;
  err = aRow->AliasCellYarn(mEnv, mURLColumn, &yarn);
  if (err != 0) return NS_ERROR_FAILURE;

  // Since the URLEnumerator always returns the value of the URL
  // column, we create an RDF resource.
  nsresult rv;
  nsCOMPtr<nsIRDFResource> resource;
  const char* startPtr = (const char*) yarn.mYarn_Buf;
  rv = gRDFService->GetResource(
            Substring(startPtr, startPtr+yarn.mYarn_Fill),
            getter_AddRefs(resource));
  if (NS_FAILED(rv)) return rv;

  *aResult = resource;
  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:

NS_IMETHOD nsMdbTableEnumerator::GetNext ( nsISupports **  _result) [inherited]
NS_IMETHODIMP nsMdbTableEnumerator::GetNext ( nsISupports **  _result) [inherited]

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, inherited]
nsresult nsMdbTableEnumerator::Init ( nsIMdbEnv aEnv,
nsIMdbTable aTable 
) [virtual, inherited]

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 nsGlobalHistory::URLEnumerator::IsResult ( nsIMdbRow aRow) [protected, virtual]

Implements nsMdbTableEnumerator.

PRBool nsGlobalHistory::URLEnumerator::IsResult ( nsIMdbRow aRow) [protected, virtual]

Implements nsMdbTableEnumerator.

Definition at line 3787 of file nsGlobalHistory.cpp.

{
  if (HasCell(mEnv, aRow, mHiddenColumn))
    return PR_FALSE;
  
  if (mSelectColumn) {
    mdb_err err;

    mdbYarn yarn;
    err = aRow->AliasCellYarn(mEnv, mURLColumn, &yarn);
    if (err != 0) return PR_FALSE;

    // Do bitwise comparison
    PRInt32 count = PRInt32(yarn.mYarn_Fill);
    if (count != mSelectValueLen)
      return PR_FALSE;

    const char* p = (const char*) yarn.mYarn_Buf;
    const char* q = (const char*) mSelectValue;

    while (--count >= 0) {
      if (*p++ != *q++)
        return PR_FALSE;
    }
  }

  return PR_TRUE;
}

Here is the call graph for this function:


Member Data Documentation

nsIMdbEnv * nsMdbTableEnumerator::mEnv [protected, inherited]

Definition at line 79 of file nsGlobalHistory.h.

Definition at line 388 of file nsGlobalHistory.h.

Definition at line 389 of file nsGlobalHistory.h.

Definition at line 390 of file nsGlobalHistory.h.

Definition at line 391 of file nsGlobalHistory.h.

Definition at line 387 of file nsGlobalHistory.h.


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