当前位置: 首页>>代码示例>>C++>>正文


C++ nsCOMPtr::GetNext方法代码示例

本文整理汇总了C++中nsCOMPtr::GetNext方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCOMPtr::GetNext方法的具体用法?C++ nsCOMPtr::GetNext怎么用?C++ nsCOMPtr::GetNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nsCOMPtr的用法示例。


在下文中一共展示了nsCOMPtr::GetNext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

NS_IMETHODIMP
nsUnionEnumerator::GetNext(nsISupports** aResult)
{
    NS_PRECONDITION(aResult != 0, "null ptr");
    if (! aResult)
        return NS_ERROR_NULL_POINTER;

    if (mConsumed)
        return NS_ERROR_UNEXPECTED;

    if (! mAtSecond)
        return mFirstEnumerator->GetNext(aResult);

    return mSecondEnumerator->GetNext(aResult);
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:15,代码来源:nsEnumeratorUtils.cpp

示例2: GetNext

nsMsgKey MsgMapiListContext::GetNext ()
{
  nsMsgKey key = nsMsgKey_None;
  PRBool    keepTrying = TRUE;
  
//  NS_ASSERTION (m_msgEnumerator && m_db, "need enumerator and db");
  if (m_msgEnumerator && m_db)
  {
    
    do 
    {
      keepTrying = FALSE;  
      nsCOMPtr <nsISupports> hdrISupports;
      nsCOMPtr <nsIMsgDBHdr> msgHdr;
      if (NS_SUCCEEDED(m_msgEnumerator->GetNext(getter_AddRefs(hdrISupports))) && hdrISupports)
      {
        msgHdr = do_QueryInterface(hdrISupports);
        msgHdr->GetMessageKey(&key);
        
        // Check here for IMAP message...if not, just return...
        if (!IsIMAPHost())
          return key;
        
        // If this is an IMAP message, we have to make sure we have a valid
        // body to work with.
        PRUint32  flags = 0;
        
        (void) msgHdr->GetFlags(&flags);
        if (flags & MSG_FLAG_OFFLINE) 
          return key;
        
        // Ok, if we get here, we have an IMAP message without a body!
        // We need to keep trying by calling the GetNext member recursively...
        keepTrying = TRUE;
      }
    } while (keepTrying);
  }
  
  return key;
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:40,代码来源:msgMapiImp.cpp

示例3: while

NS_IMETHODIMP
ContainerEnumeratorImpl::HasMoreElements(bool* aResult)
{
    NS_ASSERTION(aResult != nullptr, "null ptr");
    if (! aResult)
        return NS_ERROR_NULL_POINTER;

    nsresult rv;

    // If we've already queued up a next value, then we know there are more elements.
    if (mResult) {
        *aResult = true;
        return NS_OK;
    }

    // Otherwise, we need to grovel

    // Figure out the upper bound so we'll know when we're done. Since it's
    // possible that we're targeting a composite datasource, we'll need to
    // "GetTargets()" and take the maximum value of "nextVal" to know the
    // upper bound.
    //
    // Remember that since nextVal is the next index that we'd assign
    // to an element in a container, it's *one more* than count of
    // elements in the container.
    int32_t max = 0;

    nsCOMPtr<nsISimpleEnumerator> targets;
    rv = mDataSource->GetTargets(mContainer, kRDF_nextVal, true, getter_AddRefs(targets));
    if (NS_FAILED(rv)) return rv;

    while (1) {
        bool hasmore;
        targets->HasMoreElements(&hasmore);
        if (! hasmore)
            break;

        nsCOMPtr<nsISupports> isupports;
        targets->GetNext(getter_AddRefs(isupports));

        nsCOMPtr<nsIRDFLiteral> nextValLiteral = do_QueryInterface(isupports);
        if (! nextValLiteral)
             continue;

         const char16_t *nextValStr;
         nextValLiteral->GetValueConst(&nextValStr);

         nsresult err;
         int32_t nextVal = nsAutoString(nextValStr).ToInteger(&err);

         if (nextVal > max)
             max = nextVal;
    }

    // Now pre-fetch our next value into mResult.
    while (mCurrent || mNextIndex < max) {

        // If mCurrent has been depleted, then conjure up a new one
        if (! mCurrent) {
            rv = gRDFC->IndexToOrdinalResource(mNextIndex, getter_AddRefs(mOrdinalProperty));
            if (NS_FAILED(rv)) return rv;

            rv = mDataSource->GetTargets(mContainer, mOrdinalProperty, true, getter_AddRefs(mCurrent));
            if (NS_FAILED(rv)) return rv;

            ++mNextIndex;
        }

        if (mCurrent) {
            bool hasMore;
            rv = mCurrent->HasMoreElements(&hasMore);
            if (NS_FAILED(rv)) return rv;

            // Is the current enumerator depleted? If so, iterate to
            // the next index.
            if (! hasMore) {
                mCurrent = nullptr;
                continue;
            }

            // "Peek" ahead and pull out the next target.
            nsCOMPtr<nsISupports> result;
            rv = mCurrent->GetNext(getter_AddRefs(result));
            if (NS_FAILED(rv)) return rv;

            mResult = do_QueryInterface(result, &rv);
            if (NS_FAILED(rv)) return rv;

            *aResult = true;
            return NS_OK;
        }
    }

    // If we get here, we ran out of elements. The cursor is empty.
    *aResult = false;
    return NS_OK;
}
开发者ID:mozilla,项目名称:releases-comm-central,代码行数:97,代码来源:nsContainerEnumerator.cpp


注:本文中的nsCOMPtr::GetNext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。