Exemplo n.º 1
0
void CHostBrowser::Serialize(CArchive& ar, int nVersion)	// BROWSER_SER_VERSION
{
	BOOL bProfilePresent = FALSE;

	if ( ar.IsStoring() )
	{
		ar << m_bNewBrowse;
		ar << m_pAddress.S_un.S_addr;
		ar << m_nPort;
		ar << m_bMustPush;
		ar << m_bCanPush;
		SerializeOut( ar, m_oPushID );
		SerializeOut( ar, m_oClientID );
		ar << m_sNick;
		ar << m_bCanChat;
		ar << m_sServer;
		ar << m_nProtocol;
		ar << m_nHits;
		ar << (DWORD)m_nLength;
		ar << m_nReceived;

		bProfilePresent = ( m_pProfile != NULL );
		ar << bProfilePresent;
	}
	else // Loading
	{
		Stop();

		ar >> m_bNewBrowse;
		ar >> m_pAddress.S_un.S_addr;
		ar >> m_nPort;
		ar >> m_bMustPush;
		ar >> m_bCanPush;
		SerializeIn( ar, m_oPushID, 31 );
		SerializeIn( ar, m_oClientID, 31 );
		ar >> m_sNick;
		ar >> m_bCanChat;
		ar >> m_sServer;
		ar >> m_nProtocol;
		ar >> m_nHits;
		DWORD nLength = 0;
		ar >> nLength;
		m_nLength = nLength;	// To QWORD
		ar >> m_nReceived;
		ar >> bProfilePresent;

		m_pVendor = VendorCache.LookupByName( m_sServer );

		delete m_pProfile;
		m_pProfile = new CGProfile();
	}

	if ( bProfilePresent )
	{
		if ( m_pProfile == NULL )
			m_pProfile = new CGProfile();
		if ( m_pProfile )
			m_pProfile->Serialize( ar, nVersion );
	}
}
Exemplo n.º 2
0
inline void SerializeIn(QDataStream& s, Ranges::List< Ranges::Range<quint64>, ListTraits >& rhs)
{
	quint64 nTotal, nRemaining;
    quint64 nFragments;

	s >> nTotal >> nRemaining >> nFragments;

	{
		Ranges::List< Ranges::Range<quint64>, ListTraits > oNewRange(nTotal);
		rhs.swap(oNewRange);
	}

	for( ; nFragments--; )
	{
		const Ranges::Range<quint64>& fragment = SerializeIn(s);

		if( fragment.end() > nTotal )
		{
			s.setStatus(QDataStream::ReadCorruptData);
			break;
		}
		else
		{
			rhs.insert(rhs.end(), fragment);
		}
	}

	if( s.status() == QDataStream::Ok && rhs.length_sum() != nRemaining )
	{
		s.setStatus(QDataStream::ReadCorruptData);
	}
}
void COptionTreeWrapper::Serialize(CHashString objName, vector<CHashString> objTypes, IArchive &ar, bool bRead)
{
	if (m_mTrees[objName.GetUniqueID()].m_Tree == NULL)
	{
		m_mTrees[objName.GetUniqueID()].m_Tree = new COptionTree();
		m_mTrees[objName.GetUniqueID()].m_Tree->Create(m_Style, m_Rect, m_pParentWnd, m_TreeOptions, m_ID);
		m_mTrees[objName.GetUniqueID()].m_Root = m_mTrees[objName.GetUniqueID()].m_Tree->InsertItem(new COptionTreeItem());		
		CString label;
		label = objName.GetString();
		label += _T("(");
		label += objTypes[0].GetString();
		label += _T(")");
		m_mTrees[objName.GetUniqueID()].m_Root->SetLabelText(label);
		for (UINT i=0; i<objTypes.size(); i++)
		{
			CreateTree(objTypes[i].GetString(), objName);
		}
		m_vRootNames.push_back(objName);
	}
	if (bRead)
	{
		SerializeIn(ar, objName);
	}
	else
	{
		SerializeOut(ar, objName);
	}
	ExpandOneRoot(objName);
}
Exemplo n.º 4
0
	//---------------------------------------------------------------------------------------------------
	size_t SerializeIn(const node_type& reader, cSubTexture& value)
	{
		auto * app_ptr = &pgn::mainapp();
		std::string name;
		size_t ok = SerializeIn(reader, name);
		if (!ok) return 0;

		std::string lib, tex, subtex;
		cTexture::SplitName(name, lib, tex, subtex);
		auto * tlib = mainapp()->Resources<cTextureLib>(lib);
		if (!tlib) return 0;
		
		auto tex_atlas = tlib->FindByName(lib + ":" + tex);
		if (tex_atlas == tlib->Textures().end()) return 0;
		
		auto rect_ptr = tex_atlas->second->Rect(subtex);
		if (!rect_ptr) return 0;

		value = cSubTexture(tex_atlas->first, *rect_ptr);
		return ok;
	}
Exemplo n.º 5
0
void CDownloadSource::Serialize(CArchive& ar, int nVersion /* DOWNLOAD_SER_VERSION */)
{
	if ( ar.IsStoring() )
	{
		ar << m_sURL;
		ar << m_nProtocol;
		
		SerializeOut( ar, m_oGUID );
		
		ar << m_nPort;
		if ( m_nPort ) ar.Write( &m_pAddress, sizeof(m_pAddress) );
		ar << m_nServerPort;
		if ( m_nServerPort ) ar.Write( &m_pServerAddress, sizeof(m_pServerAddress) );
		
		ar << m_sName;
		ar << m_nIndex;
		ar << m_bHashAuth;
		ar << m_bSHA1;
		ar << m_bTiger;
		ar << m_bED2K;
		ar << m_bBTH;
		ar << m_bMD5;
		
		ar << m_sServer;
		ar << m_sNick;
		ar << m_sCountry;
		ar << m_sCountryName;
		ar << m_nSpeed;
		ar << m_bPushOnly;
		ar << m_bCloseConn;
		ar << m_bReadContent;
		ar.Write( &m_tLastSeen, sizeof(FILETIME) );
		
        SerializeOut2( ar, m_oPastFragments );

		ar << m_bClientExtended;
		ar << m_bMetaIgnore;
	}
	else if ( nVersion >= 21 )
	{
		ar >> m_sURL;
		ar >> m_nProtocol;
		
		SerializeIn( ar, m_oGUID, nVersion);
		
		ar >> m_nPort;
		if ( m_nPort ) ReadArchive( ar, &m_pAddress, sizeof(m_pAddress) );
		ar >> m_nServerPort;
		if ( m_nServerPort ) ReadArchive( ar, &m_pServerAddress, sizeof(m_pServerAddress) );
		
		ar >> m_sName;
		ar >> m_nIndex;
		ar >> m_bHashAuth;
		ar >> m_bSHA1;
		ar >> m_bTiger;
		ar >> m_bED2K;
		if ( nVersion >= 37 )
		{
			ar >> m_bBTH;
			ar >> m_bMD5;
		}