本文整理汇总了C++中CList::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ CList::IsEmpty方法的具体用法?C++ CList::IsEmpty怎么用?C++ CList::IsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CList
的用法示例。
在下文中一共展示了CList::IsEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnUploadsLaunch
void CUploadsWnd::OnUploadsLaunch()
{
CSingleLock pLock( &Transfers.m_pSection, TRUE );
CList<CUploadFile*> pList;
for ( POSITION pos = UploadFiles.GetIterator() ; pos ; )
{
CUploadFile* pFile = UploadFiles.GetNext( pos );
if ( IsSelected( pFile ) ) pList.AddTail( pFile );
}
while ( ! pList.IsEmpty() )
{
CUploadFile* pFile = pList.RemoveHead();
if ( UploadFiles.Check( pFile ) )
{
CString strPath = pFile->m_sPath;
pLock.Unlock();
if ( ! CFileExecutor::Execute( strPath ) ) break;
pLock.Lock();
}
}
}
示例2: OnSecurityBan
void CUploadsWnd::OnSecurityBan()
{
CSingleLock pLock( &Transfers.m_pSection, TRUE );
CList<CUploadFile*> pList;
for ( POSITION pos = UploadFiles.GetIterator() ; pos ; )
{
CUploadFile* pFile = UploadFiles.GetNext( pos );
if ( IsSelected( pFile ) ) pList.AddTail( pFile );
}
while ( ! pList.IsEmpty() )
{
CUploadFile* pFile = pList.RemoveHead();
if ( UploadFiles.Check( pFile ) && pFile->GetActive() != NULL )
{
CUploadTransfer* pUpload = pFile->GetActive();
IN_ADDR pAddress = pUpload->m_pHost.sin_addr;
pUpload->Remove( FALSE );
pLock.Unlock();
Security.Ban( &pAddress, banSession );
pLock.Lock();
}
}
}
示例3: OnBrowseLaunch
void CUploadsWnd::OnBrowseLaunch()
{
CSingleLock pLock( &Transfers.m_pSection, TRUE );
CList<CUploadFile*> pList;
for ( POSITION pos = UploadFiles.GetIterator() ; pos ; )
{
CUploadFile* pFile = UploadFiles.GetNext( pos );
if ( IsSelected( pFile ) ) pList.AddTail( pFile );
}
while ( ! pList.IsEmpty() )
{
CUploadFile* pFile = pList.RemoveHead();
if ( UploadFiles.Check( pFile ) && pFile->GetActive() != NULL )
{
CUploadTransfer* pTransfer = pFile->GetActive();
PROTOCOLID nProtocol = pTransfer->m_nProtocol;
SOCKADDR_IN pAddress = pTransfer->m_pHost;
pLock.Unlock();
new CBrowseHostWnd( nProtocol, &pAddress );
pLock.Lock();
}
}
}
示例4: OnUploadsClear
void CUploadsWnd::OnUploadsClear()
{
CSingleLock pLock( &Transfers.m_pSection, TRUE );
CList<CUploadFile*> pList;
for ( POSITION pos = UploadFiles.GetIterator() ; pos ; )
{
CUploadFile* pFile = UploadFiles.GetNext( pos );
if ( IsSelected( pFile ) ) pList.AddTail( pFile );
}
while ( ! pList.IsEmpty() )
{
CUploadFile* pFile = pList.RemoveHead();
if ( UploadFiles.Check( pFile ) )
{
CUploadTransfer* pUpload = pFile->GetActive();
if ( pUpload != NULL && pUpload->m_nProtocol == PROTOCOL_ED2K && pUpload->m_nState != upsNull )
{
CString strFormat, strMessage;
LoadString( strFormat, IDS_UPLOAD_CANCEL_ED2K );
strMessage.Format( strFormat, (LPCTSTR)pUpload->m_sFileName );
pLock.Unlock();
UINT nResp = AfxMessageBox( strMessage, MB_ICONQUESTION|MB_YESNOCANCEL|MB_DEFBUTTON2 );
pLock.Lock();
if ( nResp == IDCANCEL ) break;
if ( nResp != IDYES || ! UploadFiles.Check( pFile ) ) continue;
}
pFile->Remove();
}
}
}
示例5: IsFinished
bool Algorithm::IsFinished(void)
{
if (m_finished) return true;
while(!m_WaitForCheckList_Row.IsEmpty())
{
int row = m_WaitForCheckList_Row.RemoveHead();
int column = m_WaitForCheckList_Column.RemoveHead();
if (!m_NeverCheck[row][column])
{
int originalcount = 0;
for (int i = 0; i < 8; ++i)
{
int newrow = row + RowOffset[i];
int newcolumn = column + ColumnOffset[i];
if (newrow >= 0 && newrow < m_rows && newcolumn >=0 && newcolumn < m_columns)
switch (m_MineMatrix[newrow][newcolumn])
{
case ORIGINAL:
++originalcount; break;
}
}
if (originalcount)
{
trow.AddTail(row); tcolumn.AddTail(column);
} else
m_NeverCheck[row][column] = true;
}
}
while (!trow.IsEmpty())
{
int row = trow.RemoveHead();
int column = tcolumn.RemoveHead();
if (!m_NeverCheck[row][column]) {
m_WaitForCheckList_Row.AddTail(row);
m_WaitForCheckList_Column.AddTail(column);
}
}
if (m_started && m_WaitForCheckList_Row.IsEmpty())
{
int originalcount2 = 0, minecount2 = 0;
for (int i = 0; i < m_rows; ++i)
for (int j = 0; j < m_columns; ++j)
switch (m_MineMatrix[i][j])
{
case ORIGINAL:
++originalcount2; break;
case MINE:
++minecount2; break;
}
return originalcount2 == 0 && minecount2 == m_RemainderMines;
} else return false;
}
示例6: OnBnClickedButtonAddA
/**
* @brief 响应鼠标单击按钮;Add
* @note 该函数总是向列表框的后面追加记录。
* @param CBCGPGridCtrl* pGridCtrlEdit 输入行
* @param CBCGPGridCtrl* pGridCtrlList 列表
* @param CList<int, int>* ListNb Nb号队列指针
* @return void
*/
void CGridCtrlOperation::OnBnClickedButtonAddA(CBCGPGridCtrl* pGridCtrlEdit, CBCGPGridCtrl* pGridCtrlList)
{
int i;
int iNb;
COleVariant oEditVariant;
CBCGPGridRow* pRowEdit = NULL; // 输入行
CBCGPGridRow* pRowNew = NULL; // 新行
int iRowID = 0;
CList<int, int> ListNb;
// 得到索引队列,增加操作
if(false == GetIndexListForAdd(pGridCtrlEdit, &ListNb))
{
return;
}
pRowEdit = pGridCtrlEdit->GetRow(0);
while(FALSE == ListNb.IsEmpty())
{
// 得到索引号
iNb = ListNb.RemoveHead();
// 索引号在列表中已经存在
if(NULL != pGridCtrlList->FindRowByData(iNb))
{
continue;
}
pRowNew = pGridCtrlList->CreateRow(pGridCtrlList->GetColumnCount());
pRowNew->SetData(iNb);
oEditVariant.vt = VT_UI4;
oEditVariant.ulVal = iNb;
oEditVariant.ChangeType(VT_BSTR);
pRowNew->GetItem(0)->SetValue(oEditVariant);
for(i = 1; i < pGridCtrlList->GetColumnCount(); i++)
{
oEditVariant= pRowEdit->GetItem(i)->GetValue();
pRowNew->GetItem(i)->SetValue(oEditVariant);
}
pGridCtrlList->AddRow(pRowNew, FALSE);
/*
if(iSelectRowIndex == -1) // 无选中行
{
pGridCtrlList->AddRow(pRowNew, FALSE);
}
else
{
pGridCtrlList->InsertRowAfter(iSelectRowIndex + iRowID, pRowNew, FALSE);
iRowID++;
}*/
}
pGridCtrlList->AdjustLayout();
}
示例7: OnUploadsLaunch
void CUploadsWnd::OnUploadsLaunch()
{
CSingleLock pTransfersLock( &Transfers.m_pSection );
if ( ! pTransfersLock.Lock( 500 ) ) return;
const BOOL bShift = ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 );
CList<CUploadFile*> pList;
for ( POSITION pos = UploadFiles.GetIterator() ; pos ; )
{
CUploadFile* pFile = UploadFiles.GetNext( pos );
if ( IsSelected( pFile ) )
pList.AddTail( pFile );
}
pTransfersLock.Unlock();
while ( ! pList.IsEmpty() )
{
pTransfersLock.Lock();
CUploadFile* pFile = pList.RemoveHead();
if ( pFile->m_sPath.IsEmpty() ) // Multifile torrent always opens folder? (ToDo: Update this path assumption when fixed elsewhere)
{
const CString strPath = Settings.Downloads.TorrentPath + _T("\\") + pFile->m_sName; // Try default multifile torrent folder (Need better detection)
pTransfersLock.Unlock();
if ( PathIsDirectory( strPath ) )
ShellExecute( GetSafeHwnd(), _T("open"), strPath, NULL, NULL, SW_SHOWNORMAL );
}
else if ( ! bShift ) // Show in Library by default
{
CPeerProjectFile oFile = *pFile;
pTransfersLock.Unlock();
CSingleLock pLibraryLock( &Library.m_pSection, TRUE );
if ( CLibraryFile* pLibFile = LibraryMaps.LookupFileByHash( &oFile ) )
{
if ( CLibraryWnd* pLibrary = CLibraryWnd::GetLibraryWindow() ) // (CLibraryWnd*)( pMainWnd->m_pWindows.Open( RUNTIME_CLASS(CLibraryWnd) ) ) )
{
pLibrary->Display( pLibFile );
}
}
}
else if ( UploadFiles.Check( pFile ) ) // Launch directly with Shift key
{
pTransfersLock.Unlock();
CFileExecutor::Execute( pFile->m_sPath );
}
}
}
示例8: OnBnClickedButtonDeleteA
/**
* 响应鼠标单击按钮;Delete
* @param CBCGPGridCtrl* pGridCtrlEdit 输入行
* @param CBCGPGridCtrl* pGridCtrlList 列表
* @return void
*/
void CGridCtrlOperation::OnBnClickedButtonDeleteA(CBCGPGridCtrl* pGridCtrlEdit, CBCGPGridCtrl* pGridCtrlList)
{
CList<int, int> ListNb;
// 得到索引队列,修改操作、删除操作、颠倒操作
if(false == GetIndexListForChangeOrDeleteOrReverse(pGridCtrlEdit, pGridCtrlList, &ListNb))
{
return;
}
while(FALSE == ListNb.IsEmpty())
{
// 得到行索引号
int iRowIndex = ListNb.RemoveTail();
pGridCtrlList->RemoveRow(iRowIndex);
}
pGridCtrlList->AdjustLayout();
}
示例9: OnBnClickedButtonChangeA
/**
* 响应鼠标单击按钮;Change
* @param CBCGPGridCtrl* pGridCtrlEdit 输入行
* @param CBCGPGridCtrl* pGridCtrlList 列表
* @return void
*/
void CGridCtrlOperation::OnBnClickedButtonChangeA(CBCGPGridCtrl* pGridCtrlEdit, CBCGPGridCtrl* pGridCtrlList)
{
int i,iRowIndex;
COleVariant oEditVariant ;
//COleVariant oListVariant ;
CString strData;
CBCGPGridRow* pRowEdit = NULL; // 输入行
CBCGPGridRow* pRowChange = NULL; // 修改行
CList<int, int> ListNb;
// 得到索引队列,修改操作、删除操作、颠倒操作
if(false == GetIndexListForChangeOrDeleteOrReverse(pGridCtrlEdit, pGridCtrlList, &ListNb))
{
return;
}
// 得到输入行
pRowEdit = pGridCtrlEdit->GetRow(0);
while(FALSE == ListNb.IsEmpty())
{
// 得到行索引号
iRowIndex = ListNb.RemoveHead();
pRowChange = pGridCtrlList->GetRow(iRowIndex);
for(i = 1; i < pGridCtrlList->GetColumnCount(); i++)
{
oEditVariant= pRowEdit->GetItem(i)->GetValue();
if(oEditVariant.vt == VT_BSTR)
{
strData = oEditVariant;
if(strData != _T("/"))
{
pRowChange->GetItem(i)->SetValue(oEditVariant);
}
}
else
{
pRowChange->GetItem(i)->SetValue(oEditVariant);
}
}
}
pGridCtrlList->AdjustLayout();
}
示例10: OnBnClickedButtonChangeB
/**
* @brief 响应鼠标单击按钮;Change
* @note 与 OnBnClickedButtonChangeA函数不同,该函数对每一列调用GetValueForTextField进行解析。
* 支持V/i的格式输入。
* @param CBCGPGridCtrl* pGridCtrlEdit 输入行
* @param CBCGPGridCtrl* pGridCtrlList 列表
* @return void
*/
void CGridCtrlOperation::OnBnClickedButtonChangeB(CBCGPGridCtrl* pGridCtrlEdit, CBCGPGridCtrl* pGridCtrlList)
{
int nIndex; // 计数器,计算当前更新的行数
int i,iRowIndex;
COleVariant oEditVariant ;
COleVariant oListVariant ;
CString strData;
CBCGPGridRow* pRowEdit = NULL; // 输入行
CBCGPGridRow* pRowChange = NULL; // 修改行
CList<int, int> ListNb;
// 得到索引队列,修改操作、删除操作、颠倒操作
if(false == GetIndexListForChangeOrDeleteOrReverse(pGridCtrlEdit, pGridCtrlList, &ListNb))
{
return;
}
// 得到输入行
pRowEdit = pGridCtrlEdit->GetRow(0);
nIndex = 0;
while(FALSE == ListNb.IsEmpty())
{
// 得到行索引号
iRowIndex = ListNb.RemoveHead();
pRowChange = pGridCtrlList->GetRow(iRowIndex);
for(i = 1; i < pGridCtrlList->GetColumnCount(); i++)
{
oEditVariant= pRowEdit->GetItem(i)->GetValue();
oListVariant= pRowChange->GetItem(i)->GetValue();
oListVariant = GetValueForTextField(&oEditVariant,&oListVariant,nIndex);
if (oEditVariant.vt == VT_BSTR)
{
oListVariant.ChangeType(VT_BSTR);
}
pRowChange->GetItem(i)->SetValue(oListVariant);
}
nIndex++;
}
pGridCtrlList->AdjustLayout();
}
示例11: CalcButtonLocations
//.........这里部分代码省略.........
stripe.buttonCount = 1;
stripe.breadth = szButton.cx; // cy for horz.
stripe.size = szButton.cy; // cx for horz.
listStripes.AddTail (stripe); // stripe with a single large button
stripe = ButtonStripe ();
}
else // usual button
{
if (stripe.breadth + szButton.cx <= nMaxSize)
{
stripe.breadth += szButton.cx;
stripe.buttonCount ++;
if (szButton.cy > stripe.size)
stripe.size = szButton.cy;
}
else
{
if (stripe.buttonCount > 0)
{
listStripes.AddTail (stripe);
}
stripe.buttonCount = 1;
stripe.breadth = szButton.cx; // cy for horz.
stripe.size = szButton.cy; // cx for horz.
}
}
}
bPrevSeparator = bSep;
}
if (stripe.buttonCount > 0)
{
listStripes.AddTail (stripe);
}
if (listStripes.IsEmpty ())
{
return CSize (0, 0);
}
if (listStripes.GetTail ().breadth == 0) // last item is separator
{
listStripes.RemoveTail ();
}
// Now calculate total size
int totalLength = m_nCaptionHeight + 4;
int maxBreadth = nMaxSize;
POSITION posStripes = listStripes.GetHeadPosition ();
while (posStripes != NULL)
{
stripe = listStripes.GetNext (posStripes);
ASSERT (stripe.buttonCount > 0);
totalLength += stripe.size;
if (stripe.breadth > maxBreadth)
{
maxBreadth = stripe.breadth;
}
}
if (!bCalcOnly)
{
CPoint ptButtonPos = rectClient.TopLeft ();
posStripes = listStripes.GetHeadPosition ();
stripe = ButtonStripe();
for (POSITION pos = m_Buttons.GetHeadPosition (); pos != NULL;)
{
示例12: DoParse
//************************************************************************************
void CBCGPOutlineParser::DoParse (const CString& strBuffer,
const int nStartOffset, const int nEndOffset,
CObList& lstResults)
{
ASSERT (nStartOffset >= 0);
ASSERT (nEndOffset < strBuffer.GetLength ());
ASSERT (nStartOffset <= nEndOffset);
m_strOut.Empty ();
CList <Lexeme, Lexeme&> lstStack;
Lexeme lexemStackTop (0, LT_Eps, 0, 0);
lstStack.AddTail (lexemStackTop);
int nOffset = nStartOffset;
while (nOffset <= nEndOffset)
{
// Get next lexem:
Lexeme lexemNext = GetNext (strBuffer, nOffset, nEndOffset);
Lexeme lexemTop = lstStack.GetTail ();
if (lexemNext.m_nType == LT_EndOfText)
{
break;
}
// Parser logic:
switch (lexemNext.m_nType)
{
case LT_BlockStart:
lstStack.AddTail (lexemNext);
break;
case LT_BlockEnd:
if (lexemTop.m_nType == LT_BlockStart &&
lexemTop.m_nBlockType == lexemNext.m_nBlockType)
{
// Push Block:
lstStack.RemoveTail ();
Lexeme lexemRes (lexemTop.m_nBlockType, LT_CompleteBlock, lexemTop.m_nStart, lexemNext.m_nEnd);
PushResult (lexemRes, lstResults);
}
else
{
lstStack.AddTail (lexemNext);
}
break;
case LT_CompleteBlock:
{
// Push Comment:
PushResult (lexemNext, lstResults);
}
break;
case LT_CustomBlock:
break;
}
}
// Finish parsing:
while (!lstStack.IsEmpty ())
{
Lexeme lexem = lstStack.RemoveTail ();
PushResult (lexem, lstResults);
}
}
示例13: ParseHelper
//.........这里部分代码省略.........
continue;
}
else if (stricmp(command, "elif") == 0 || stricmp(command, "else") == 0)
{
// If we're in nested false conditionals, then ignore.
if (nestedFalseConditionals > 0)
{
SkipToEol(codePtr);
continue;
}
}
else if (stricmp(command, "endif") == 0)
{
// If we're in nested false conditionals, then ignore.
if (nestedFalseConditionals > 0)
{
SkipToEol(codePtr);
nestedFalseConditionals--;
continue;
}
}
}
if (stricmp(command, "if") == 0 ||
stricmp(command, "elif") == 0)
{
// Our CondInfo structure.
CondInfo condInfo;
// If the command is an elif, then pop the old state.
if (tolower(command[0]) == 'e')
{
// The conditional stack can't be empty on an elif.
if (conditionalStack.IsEmpty())
{
CString err;
err.Format("!!elif used with no preceding !!if.");
throw TException(TException::CONDSTACK_EMPTY, err);
}
// Get the current conditionalStack state. We are most
// interested in retaining the m_thisLevelTrue variable.
condInfo = conditionalStack.GetTail();
// Remove the old state, because it was false.
conditionalStack.RemoveTail();
}
// if and elif are setup in this format:
// !!if var [cond] [condCheck]
// condCheck is only optional if cond doesn't exist.
// var is required.
// Get the requested dictionary entry name.
CString var = ParseToken(codePtr, &helper);
/* if (var.IsEmpty())
{
CString err;
err.Format("The variable is missing.");
throw TException(TException::IF_VAR_MISSING, err);
}
*/
CString cond = ParseToken(codePtr, &helper);
CString condCheck = ParseToken(codePtr, &helper);
/* if (!cond.IsEmpty() && condCheck.IsEmpty())
{
CString err;
示例14: OnInitDialog
BOOL CFileSharingPage::OnInitDialog()
{
CFilePropertiesPage::OnInitDialog();
m_wndTags.AddString( L"" );
{
CQuickLock oLock( UploadQueues.m_pSection );
CList< CString > pAdded;
for ( POSITION pos = UploadQueues.GetIterator(); pos; )
{
CUploadQueue* pQueue = UploadQueues.GetNext( pos );
if ( ! pQueue->m_sShareTag.IsEmpty() )
{
if ( pAdded.Find( pQueue->m_sShareTag ) == NULL )
{
pAdded.AddTail( pQueue->m_sShareTag );
m_wndTags.AddString( pQueue->m_sShareTag );
}
}
}
if ( pAdded.IsEmpty() )
{
m_wndTags.AddString( L"Release" );
m_wndTags.AddString( L"Popular" );
}
}
{
CQuickLock oLock( Library.m_pSection );
if ( CLibraryFile* pSingleFile = GetFile() )
{
m_bOverride = pSingleFile->IsSharedOverride();
m_bShare = pSingleFile->IsShared();
m_sTags = pSingleFile->m_sShareTags;
}
else
{
CLibraryListPtr pList( GetList() );
if ( pList )
{
for ( POSITION pos = pList->GetHeadPosition(); pos; )
{
if ( CLibraryFile* pFile = pList->GetNextFile( pos ) )
{
m_bOverride = pFile->IsSharedOverride();
m_bShare = pFile->IsShared();
m_sTags = pFile->m_sShareTags;
}
}
}
}
}
UpdateData( FALSE );
m_wndShare.EnableWindow( m_bOverride );
return TRUE;
}
示例15: Output
void CRemote::Output(LPCTSTR pszName)
{
if ( _tcsstr( pszName, L".." ) || _tcschr( pszName, L'/' ) ) return;
CString strValue = Settings.General.Path + L"\\Remote\\" + pszName + L".html";
CFile hFile;
if ( ! hFile.Open( strValue, CFile::modeRead ) ) return;
int nBytes = (int)hFile.GetLength();
CAutoVectorPtr< BYTE > pBytes( new BYTE[ nBytes ] );
hFile.Read( pBytes, nBytes );
hFile.Close();
LPCSTR pBody = (LPCSTR)(BYTE*)pBytes;
if ( nBytes > 3 && pBytes[0] == 0xEF && pBytes[1] == 0xBB && pBytes[2] == 0xBF )
{
// Skip BOM
pBody += 3;
nBytes -= 3;
}
CString strBody = UTF8Decode( pBody, nBytes );
CList<BOOL> pDisplayStack;
for ( BOOL bDisplay = TRUE; ; )
{
int nStart = strBody.Find( L"<%" );
if ( nStart < 0 )
{
if ( bDisplay )
m_sResponse += strBody;
break;
}
else if ( nStart >= 0 )
{
if ( bDisplay && nStart > 0 )
m_sResponse += strBody.Left( nStart );
strBody = strBody.Mid( nStart + 2 );
}
int nEnd = strBody.Find( L"%>" );
if ( nEnd < 0 ) break;
CString strKey = strBody.Left( nEnd );
strBody = strBody.Mid( nEnd + 2 );
strKey.Trim();
ToLower( strKey );
if ( strKey.IsEmpty() )
{
// Nothing
}
else if ( strKey.GetAt( 0 ) == L'=' && bDisplay )
{
strKey = strKey.Mid( 1 );
strKey.Trim();
if ( m_pKeys.Lookup( strKey, strValue ) )
m_sResponse += strValue;
}
else if ( strKey.GetAt( 0 ) == L'?' )
{
strKey = strKey.Mid( 1 );
strKey.Trim();
if ( strKey.IsEmpty() )
{
if ( ! pDisplayStack.IsEmpty() )
bDisplay = pDisplayStack.RemoveTail();
}
else
{
if ( strKey.GetAt( 0 ) == L'!' )
{
strKey = strKey.Mid( 1 );
strKey.Trim();
if ( ! m_pKeys.Lookup( strKey, strValue ) ) strValue.Empty();
pDisplayStack.AddTail( bDisplay );
bDisplay = bDisplay && strValue.IsEmpty();
}
else
{
if ( ! m_pKeys.Lookup( strKey, strValue ) ) strValue.Empty();
pDisplayStack.AddTail( bDisplay );
bDisplay = bDisplay && ! strValue.IsEmpty();
}
}
}
}
}