本文整理汇总了C++中CArchive::ReadCount方法的典型用法代码示例。如果您正苦于以下问题:C++ CArchive::ReadCount方法的具体用法?C++ CArchive::ReadCount怎么用?C++ CArchive::ReadCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CArchive
的用法示例。
在下文中一共展示了CArchive::ReadCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Serialize
void CDownloadWithSources::Serialize(CArchive& ar, int nVersion)
{
CDownloadBase::Serialize( ar, nVersion );
if ( ar.IsStoring() )
{
ar.WriteCount( GetSourceCount() );
for ( CDownloadSource* pSource = GetFirstSource() ; pSource ; pSource = pSource->m_pNext )
{
pSource->Serialize( ar, nVersion );
}
ar.WriteCount( m_pXML != NULL ? 1 : 0 );
if ( m_pXML ) m_pXML->Serialize( ar );
}
else
{
for ( int nSources = ar.ReadCount() ; nSources ; nSources-- )
{
// Create new source
CDownloadSource* pSource = new CDownloadSource( (CDownload*)this );
// Add to the list
m_nSourceCount ++;
pSource->m_pPrev = m_pSourceLast;
pSource->m_pNext = NULL;
if ( m_pSourceLast != NULL )
{
m_pSourceLast->m_pNext = pSource;
m_pSourceLast = pSource;
}
else
{
m_pSourceFirst = m_pSourceLast = pSource;
}
// Load details from disk
pSource->Serialize( ar, nVersion );
// Extract ed2k client ID from url (m_pAddress) because it wasn't saved
if ( ( !pSource->m_nPort ) && ( _tcsnicmp( pSource->m_sURL, _T("ed2kftp://"), 10 ) == 0 ) )
{
CString strURL = pSource->m_sURL.Mid(10);
if ( strURL.GetLength())
_stscanf( strURL, _T("%lu"), &pSource->m_pAddress.S_un.S_addr );
}
}
if ( ar.ReadCount() )
{
m_pXML = new CXMLElement();
m_pXML->Serialize( ar );
}
}
}
示例2: Serialize
void CDownloadWithSources::Serialize(CArchive& ar, int nVersion) // DOWNLOAD_SER_VERSION
{
CDownloadBase::Serialize( ar, nVersion );
CQuickLock pLock( Transfers.m_pSection );
if ( ar.IsStoring() )
{
DWORD_PTR nSources = GetCount();
if ( nSources > Settings.Downloads.SourcesWanted )
nSources = Settings.Downloads.SourcesWanted;
ar.WriteCount( nSources );
for ( POSITION posSource = GetIterator() ; posSource && nSources ; nSources-- )
{
CDownloadSource* pSource = GetNext( posSource );
pSource->Serialize( ar, nVersion );
}
ar.WriteCount( m_pXML != NULL ? 1 : 0 );
if ( m_pXML ) m_pXML->Serialize( ar );
}
else // Loading
{
for ( DWORD_PTR nSources = ar.ReadCount() ; nSources ; nSources-- )
{
// Create new source
//CDownloadSource* pSource = new CDownloadSource( (CDownload*)this );
CAutoPtr< CDownloadSource > pSource( new CDownloadSource( static_cast< CDownload* >( this ) ) );
if ( ! pSource )
AfxThrowMemoryException();
// Load details from disk
pSource->Serialize( ar, nVersion );
// Extract ed2k client ID from url (m_pAddress) because it wasn't saved
if ( ! pSource->m_nPort && _tcsnicmp( pSource->m_sURL, _T("ed2kftp://"), 10 ) == 0 )
{
CString strURL = pSource->m_sURL.Mid(10);
if ( ! strURL.IsEmpty() )
_stscanf( strURL, _T("%lu"), &pSource->m_pAddress.S_un.S_addr );
}
InternalAdd( pSource.Detach() );
}
if ( ar.ReadCount() )
{
m_pXML = new CXMLElement();
if ( ! m_pXML )
AfxThrowMemoryException();
m_pXML->Serialize( ar );
}
}
}
示例3: Serialize
void CXMLElement::Serialize(CArchive& ar)
{
CXMLNode::Serialize( ar );
if ( ar.IsStoring() )
{
ar.WriteCount( GetAttributeCount() );
for ( POSITION pos = GetAttributeIterator() ; pos ; )
{
GetNextAttribute( pos )->Serialize( ar );
}
ar.WriteCount( GetElementCount() );
for ( POSITION pos = GetElementIterator() ; pos ; )
{
GetNextElement( pos )->Serialize( ar );
}
}
else // Loading
{
for ( int nCount = (int)ar.ReadCount() ; nCount > 0 ; nCount-- )
{
CXMLAttribute* pAttribute = new CXMLAttribute( this );
pAttribute->Serialize( ar );
// Skip attribute if name is missing
if ( pAttribute->m_sName.IsEmpty() )
{
delete pAttribute;
continue;
}
CString strNameLower( pAttribute->m_sName );
strNameLower.MakeLower();
// Delete the old attribute if one exists
CXMLAttribute* pExisting;
if ( m_pAttributes.Lookup( strNameLower, pExisting ) )
delete pExisting;
m_pAttributes.SetAt( strNameLower, pAttribute );
if ( ! m_pAttributesInsertion.Find( strNameLower ) )
m_pAttributesInsertion.AddTail( strNameLower ); // Track output order workaround
}
for ( int nCount = (int)ar.ReadCount() ; nCount > 0 ; nCount-- )
{
CXMLElement* pElement = new CXMLElement( this );
pElement->Serialize( ar );
m_pElements.AddTail( pElement );
}
}
}
示例4: pFile
void CLibraryMaps::Serialize2(CArchive& ar, int nVersion)
{
if ( nVersion < 18 ) return;
if ( ar.IsStoring() )
{
ar.WriteCount( m_pDeleted.GetCount() );
for ( POSITION pos = m_pDeleted.GetHeadPosition() ; pos ; )
{
m_pDeleted.GetNext( pos )->Serialize( ar, nVersion );
}
}
else // Loading
{
for ( DWORD_PTR nCount = ar.ReadCount() ; nCount > 0 ; nCount-- )
{
//CLibraryFile* pFile = new CLibraryFile( NULL );
CAutoPtr< CLibraryFile > pFile( new CLibraryFile( NULL ) );
if ( ! pFile )
AfxThrowMemoryException();
pFile->Serialize( ar, nVersion );
if ( ! LibraryMaps.LookupFileByHash( pFile ) )
Library.AddFile( pFile.Detach() );
}
}
}
示例5: Serialize
void CLineGraph::Serialize(CArchive& ar)
{
if ( ar.IsStoring() )
{
ar << m_bShowAxis;
ar << m_bShowGrid;
ar << m_bShowLegend;
ar << m_nSpeed;
ar << max( m_nScale, MIN_GRID_SIZE_HORZ );
ar.WriteCount( GetItemCount() );
for ( POSITION pos = GetItemIterator() ; pos ; )
{
GetNextItem( pos )->Serialize( ar );
}
}
else // Loading
{
ar >> m_bShowAxis;
ar >> m_bShowGrid;
ar >> m_bShowLegend;
ar >> m_nSpeed;
ar >> m_nScale;
m_nScale = max( m_nScale, MIN_GRID_SIZE_HORZ );
for ( DWORD_PTR nCount = ar.ReadCount() ; nCount > 0 ; nCount-- )
{
CGraphItem* pItem = new CGraphItem();
pItem->Serialize( ar );
m_pItems.AddTail( pItem );
}
}
}
示例6: Serialize
void CObList::Serialize(CArchive& ar)
{
ASSERT_VALID(this);
CObject::Serialize(ar);
if (ar.IsStoring())
{
ar.WriteCount(m_nCount);
for (CNode* pNode = m_pNodeHead; pNode != NULL; pNode = pNode->pNext)
{
ASSERT(AfxIsValidAddress(pNode, sizeof(CNode)));
ar << pNode->data;
}
}
else
{
DWORD_PTR nNewCount = ar.ReadCount();
CObject* newData;
while (nNewCount--)
{
ar >> newData;
AddTail(newData);
}
}
}
示例7: Serialize
void CLineGraph::Serialize(CArchive& ar)
{
if ( ar.IsStoring() )
{
ar << m_bShowAxis;
ar << m_bShowGrid;
ar << m_bShowLegend;
ar << m_nSpeed;
ar << m_nScale;
ar.WriteCount( GetItemCount() );
for ( POSITION pos = GetItemIterator() ; pos ; )
{
GetNextItem( pos )->Serialize( ar );
}
}
else
{
ar >> m_bShowAxis;
ar >> m_bShowGrid;
ar >> m_bShowLegend;
ar >> m_nSpeed;
ar >> m_nScale;
for ( int nCount = ar.ReadCount() ; nCount > 0 ; nCount-- )
{
CGraphItem* pItem = new CGraphItem();
pItem->Serialize( ar );
m_pItems.AddTail( pItem );
}
}
}
示例8: Serialize
void CLibraryHistory::Serialize(CArchive& ar, int nVersion)
{
if ( nVersion < 7 ) return;
int nCount = 0;
POSITION pos;
if ( ar.IsStoring() )
{
for ( pos = GetIterator() ; pos ; )
{
if ( GetNext( pos )->m_pFile != NULL ) nCount ++;
}
ar.WriteCount( nCount );
for ( pos = GetIterator() ; pos ; )
{
CLibraryRecent* pRecent = GetNext( pos );
if ( pRecent->m_pFile != NULL ) pRecent->Serialize( ar, nVersion );
}
ar << LastSeededTorrent.m_sPath;
if ( LastSeededTorrent.m_sPath.GetLength() )
{
ar << LastSeededTorrent.m_sName;
ar << LastSeededTorrent.m_tLastSeeded;
ar.Write( &LastSeededTorrent.m_pBTH, sizeof(SHA1) );
}
}
else
{
Clear();
for ( nCount = ar.ReadCount() ; nCount > 0 ; nCount-- )
{
CLibraryRecent* pRecent = new CLibraryRecent();
pRecent->Serialize( ar, nVersion );
if ( pRecent->m_pFile != NULL )
{
m_pList.AddTail( pRecent );
}
else
{
delete pRecent;
}
}
if ( nVersion > 22 )
{
ar >> LastSeededTorrent.m_sPath;
if ( LastSeededTorrent.m_sPath.GetLength() )
{
ar >> LastSeededTorrent.m_sName;
ar >> LastSeededTorrent.m_tLastSeeded;
ar.Read( &LastSeededTorrent.m_pBTH, sizeof(SHA1) );
}
}
示例9: SerializeCompound
void CDownloads::SerializeCompound(CArchive& ar)
{
ASSERT( ar.IsLoading() );
int nVersion;
ar >> nVersion;
if ( nVersion < 4 ) return;
for ( int nCount = ar.ReadCount() ; nCount > 0 ; nCount-- )
{
CDownload* pDownload = new CDownload();
m_pList.AddTail( pDownload );
pDownload->Serialize( ar, nVersion );
}
}
示例10: Serialize
void CObArray::Serialize( CArchive &ar )
/**************************************/
{
CObject::Serialize( ar );
if( ar.IsStoring() ) {
ar.WriteCount( m_nSize );
for( int i = 0; i < m_nSize; i++ ) {
ar << m_pData[i];
}
} else {
int nSize = ar.ReadCount();
SetSize( nSize );
for( int i = 0; i < nSize; i++ ) {
ar >> m_pData[i];
}
}
}
示例11: Serialize
void CSearchWnd::Serialize(CArchive& ar)
{
CQuickLock pLock( m_pMatches->m_pSection );
int nVersion = 1;
if ( ar.IsStoring() )
{
ar << nVersion;
ar.WriteCount( size() );
for ( iterator pManaged = begin() ; pManaged != end() ; ++pManaged )
{
(*pManaged)->Serialize( ar );
}
}
else // Loading
{
ar >> nVersion;
if ( nVersion != 1 ) AfxThrowUserException();
for ( DWORD_PTR nCount = ar.ReadCount() ; nCount > 0 ; nCount-- )
{
CSearchPtr pManaged( new CManagedSearch() );
pManaged->Serialize( ar );
m_oSearches.push_back( pManaged );
}
}
CBaseMatchWnd::Serialize( ar );
if ( ar.IsLoading() )
{
if ( ! empty() )
m_wndPanel.ShowSearch( m_oSearches.back() );
PostMessage( WM_TIMER, 1 );
SendMessage( WM_TIMER, 2 );
SetAlert( FALSE );
}
}
示例12: Serialize
void CStringArray::Serialize(CArchive& ar)
{
ASSERT_VALID(this);
CObject::Serialize(ar);
if (ar.IsStoring())
{
ar.WriteCount(m_nSize);
for (INT_PTR i = 0; i < m_nSize; i++)
ar << m_pData[i];
}
else
{
DWORD_PTR nOldSize = ar.ReadCount();
SetSize(nOldSize);
for (INT_PTR i = 0; i < m_nSize; i++)
ar >> m_pData[i];
}
}
示例13: Serialize
void CObBinTree::Serialize(CArchive& ar)
{
ASSERT_VALID(this);
CObject::Serialize(ar);
if (ar.IsStoring())
{
ar.WriteCount(m_nCount);
WalkTree( SerialStore, (LPVOID)&ar, TV_PREORDER );
}
else
{
DWORD nNewCount = (DWORD)ar.ReadCount();
CObject* newData;
while (nNewCount--)
{
ar >> newData;
Insert(newData);
}
}
}
示例14: Serialize
void CWordArray::Serialize(CArchive& ar)
{
UINT_PTR nWORDsLeft;
UINT nWORDsToWrite;
UINT nWORDsToRead;
LPWORD pwData;
ASSERT_VALID(this);
CObject::Serialize(ar);
if (ar.IsStoring())
{
ar.WriteCount(m_nSize);
nWORDsLeft = m_nSize;
pwData = m_pData;
while(nWORDsLeft > 0)
{
nWORDsToWrite = UINT(min(nWORDsLeft, INT_MAX/sizeof(WORD)));
ar.Write(pwData, nWORDsToWrite*sizeof(WORD));
nWORDsLeft -= nWORDsToWrite;
pwData += nWORDsToWrite;
}
}
else
{
DWORD_PTR nOldSize = ar.ReadCount();
SetSize(nOldSize);
nWORDsLeft = m_nSize;
pwData = m_pData;
while(nWORDsLeft > 0)
{
nWORDsToRead = UINT(min( nWORDsLeft, INT_MAX/sizeof(WORD)));
ar.EnsureRead(pwData, nWORDsToRead*sizeof(WORD));
nWORDsLeft -= nWORDsToRead;
pwData += nWORDsToRead;
}
}
}
示例15: Serialize
void CMapWordToOb::Serialize(CArchive& ar)
{
ASSERT_VALID(this);
CObject::Serialize(ar);
if (ar.IsStoring())
{
ar.WriteCount(m_nCount);
if (m_nCount == 0)
return; // nothing more to do
ASSERT(m_pHashTable != NULL);
for (UINT nHash = 0; nHash < m_nHashTableSize; nHash++)
{
CAssoc* pAssoc;
for (pAssoc = m_pHashTable[nHash]; pAssoc != NULL;
pAssoc = pAssoc->pNext)
{
ar << pAssoc->key;
ar << pAssoc->value;
}
}
}
else
{
DWORD nNewCount = ar.ReadCount();
WORD newKey;
CObject* newValue;
while (nNewCount--)
{
ar >> newKey;
ar >> newValue;
SetAt(newKey, newValue);
}
}
}