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


C++ CArchive::WriteCount方法代码示例

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


在下文中一共展示了CArchive::WriteCount方法的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 );
		}
	}
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:57,代码来源:DownloadWithSources.cpp

示例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 );
		}
	}
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:57,代码来源:DownloadWithSources.cpp

示例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 );
		}
	}
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:56,代码来源:XML.cpp

示例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() );
		}
	}
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:29,代码来源:LibraryMaps.cpp

示例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 );
		}
	}
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:34,代码来源:GraphLine.cpp

示例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);
		}
	}
}
开发者ID:jbeaurain,项目名称:omaha_vs2010,代码行数:26,代码来源:list_o.cpp

示例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 );
		}
	}
}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:33,代码来源:GraphLine.cpp

示例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) );
			}
		}
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:59,代码来源:LibraryHistory.cpp

示例9: Serialize

void CAlbumFolder::Serialize(CArchive& ar, int nVersion)
{
	POSITION pos;

	if ( ar.IsStoring() )
	{
		ar << m_sSchemaURI;

		ar.WriteCount( m_pXML != NULL ? 1 : 0 );
		if ( m_pXML ) m_pXML->Serialize( ar );

		ar << m_bCollSHA1;
		if ( m_bCollSHA1 ) ar.Write( &m_pCollSHA1, sizeof(SHA1) );

		ar << m_sName;
		ar << m_bExpanded;
		ar << m_bAutoDelete;
		ar << m_sBestView;

		ar.WriteCount( GetFolderCount() );

		for ( pos = GetFolderIterator() ; pos ; )
		{
			CAlbumFolder* pFolder = GetNextFolder( pos );
			pFolder->Serialize( ar, nVersion );
		}

		ar.WriteCount( GetFileCount() );

		for ( pos = GetFileIterator() ; pos ; )
		{
			CLibraryFile* pFile = GetNextFile( pos );
			ar << pFile->m_nIndex;
		}
	}
	else
	{
		CLibraryFile* pCollection = NULL;

		if ( m_pParent != NULL )
		{
			ar >> m_sSchemaURI;
			m_pSchema = SchemaCache.Get( m_sSchemaURI );
		}
		else
		{
开发者ID:ericfillipe1,项目名称:shareaza-code,代码行数:46,代码来源:AlbumFolder.cpp

示例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];
        }
    }
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:18,代码来源:obarr.cpp

示例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 );
    }
}
开发者ID:qing3962,项目名称:peerproject,代码行数:42,代码来源:WndSearch.cpp

示例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];
	}
}
开发者ID:jbeaurain,项目名称:omaha_vs2010,代码行数:20,代码来源:array_s.cpp

示例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);
		}
	}
}
开发者ID:EISALab,项目名称:AMGAgroundwater,代码行数:22,代码来源:tree_ob.cpp

示例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;
		}
	}
}
开发者ID:jbeaurain,项目名称:omaha_vs2010,代码行数:39,代码来源:array_w.cpp

示例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);
		}
	}
}
开发者ID:rickerliang,项目名称:OpenNT,代码行数:37,代码来源:map_wo.cpp


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