Back to index

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

#include <nsGlobalHistory.h>

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

List of all members.

Public Member Functions

 AutoCompleteEnumerator (nsGlobalHistory *aHistory, mdb_column aURLColumn, mdb_column aCommentColumn, mdb_column aHiddenColumn, mdb_column aTypedColumn, PRBool aMatchOnlyTyped, const nsAString &aSelectValue, AutocompleteExclude *aExclude)
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 ~AutoCompleteEnumerator ()
virtual PRBool IsResult (nsIMdbRow *aRow)
virtual nsresult ConvertToISupports (nsIMdbRow *aRow, nsISupports **aResult)

Protected Attributes

nsGlobalHistorymHistory
mdb_column mURLColumn
mdb_column mHiddenColumn
mdb_column mTypedColumn
mdb_column mCommentColumn
AutocompleteExcludemExclude
const nsAString & mSelectValue
PRBool mMatchOnlyTyped
nsIMdbEnvmEnv

Detailed Description

Definition at line 437 of file nsGlobalHistory.h.


Constructor & Destructor Documentation

Definition at line 4054 of file nsGlobalHistory.cpp.

{
}
nsGlobalHistory::AutoCompleteEnumerator::AutoCompleteEnumerator ( nsGlobalHistory aHistory,
mdb_column  aURLColumn,
mdb_column  aCommentColumn,
mdb_column  aHiddenColumn,
mdb_column  aTypedColumn,
PRBool  aMatchOnlyTyped,
const nsAString &  aSelectValue,
AutocompleteExclude aExclude 
) [inline]

Definition at line 452 of file nsGlobalHistory.h.

                                                          :
      mHistory(aHistory),
      mURLColumn(aURLColumn),
      mHiddenColumn(aHiddenColumn),
      mTypedColumn(aTypedColumn),
      mCommentColumn(aCommentColumn),
      mExclude(aExclude),
      mSelectValue(aSelectValue), 
      mMatchOnlyTyped(aMatchOnlyTyped) {}

Member Function Documentation

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

Implements nsMdbTableEnumerator.

Definition at line 4078 of file nsGlobalHistory.cpp.

{
  nsCAutoString url;
  mHistory->GetRowValue(aRow, mURLColumn, url);
  nsAutoString comments;
  mHistory->GetRowValue(aRow, mCommentColumn, comments);

  nsCOMPtr<nsIAutoCompleteItem> newItem(do_CreateInstance(NS_AUTOCOMPLETEITEM_CONTRACTID));
  NS_ENSURE_TRUE(newItem, NS_ERROR_FAILURE);

  newItem->SetValue(NS_ConvertUTF8toUCS2(url.get()));
  newItem->SetParam(aRow);
  newItem->SetComment(comments.get());

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

Implements nsMdbTableEnumerator.

Definition at line 4060 of file nsGlobalHistory.cpp.

Here is the call graph for this function:


Member Data Documentation

Definition at line 444 of file nsGlobalHistory.h.

nsIMdbEnv * nsMdbTableEnumerator::mEnv [protected, inherited]

Definition at line 79 of file nsGlobalHistory.h.

Definition at line 445 of file nsGlobalHistory.h.

Definition at line 442 of file nsGlobalHistory.h.

Definition at line 440 of file nsGlobalHistory.h.

Definition at line 447 of file nsGlobalHistory.h.

Definition at line 446 of file nsGlobalHistory.h.

Definition at line 443 of file nsGlobalHistory.h.

Definition at line 441 of file nsGlobalHistory.h.


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