Пример #1
0
void ADOU::Serialize(CArchive &ar)
{
	if (ar.IsStoring())
	{
		int i;
		ar << cn << dn;

		//Initialization needed: domain
		
		ar << users.size();
		for (i = 0; i < users.size(); i++)
		{
			users[i]->Serialize(ar);
		}
		
		ar << groups.size();
		for (i = 0; i < groups.size(); i++)
		{
			groups[i]->Serialize(ar);
		}
		
		ar << computers.size();
		for (i = 0; i < computers.size(); i++)
		{
			computers[i]-> Serialize(ar);
		}
		
		ar << ous.size();
		for (i = 0; i < ous.size(); i++)
		{
			ous[i] ->Serialize(ar);
		}
	}
	else
	{
		int i;
		int iSize;
		ar >> cn >> dn;
		
		ar >> iSize;
		for (i = 0; i < iSize; i ++)
		{
			ADUser* pUser = new ADUser();
			pUser->domain = domain;
			pUser->Serialize(ar);
			users.push_back(pUser);
		}
		
		ar >> iSize;
		for (i = 0; i < iSize; i ++)
		{
			ADGroup* pGroup = new ADGroup();
			pGroup->domain = domain;
			pGroup->Serialize(ar);
			groups.push_back(pGroup);
		}
		
		ar >> iSize;
		for (i = 0; i < iSize; i ++)
		{
			ADComputer* pComputer = new ADComputer();
			pComputer->domain = domain;
			pComputer->Serialize(ar);
			computers.push_back(pComputer);
		}
		
		ar >> iSize;
		for (i = 0; i < iSize; i ++)
		{
			ADOU* pOU = new ADOU();
			pOU->domain = domain;
			pOU->Serialize(ar);
			ous.push_back(pOU);
		}
	}
	
	ADObject::Serialize(ar);
}
Пример #2
0
//****************************************************************************************
BOOL CBCGPMenuHash::SaveMenuBar (HMENU hMenu, CBCGPToolBar* pBar)
{
	ASSERT_VALID (pBar);

	if (pBar->GetCount () == 0)
	{
		return FALSE;
	}

	HANDLE hFileOld = NULL;
	if (m_StoredMenues.Lookup (hMenu, hFileOld))
	{
		//--------------------
		// Free unused handle:
		//--------------------
		::CloseHandle (hFileOld);
	}

	//---------------------
	// Get the temp path...
	//---------------------
	CString strTempPath;
	GetTempPath (MAX_PATH, strTempPath.GetBuffer (MAX_PATH));
	strTempPath.ReleaseBuffer();

	//-------------------------------------------
	// Create a temporary file for the output....
	//-------------------------------------------
	CString strTempName;
	GetTempFileName (strTempPath, _T("BCG"), 0, strTempName.GetBuffer (MAX_PATH));
	strTempName.ReleaseBuffer ();

	HANDLE hFile = ::CreateFile (strTempName, GENERIC_READ | GENERIC_WRITE,
		0, NULL, CREATE_ALWAYS, 
		FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, NULL);
	if (hFile == INVALID_HANDLE_VALUE)
	{
		TRACE(_T("Can't create temporary file!\n"));
		return FALSE;
	}

	try
	{
		//---------------------------------
		// Write a menubar context to file:
		//---------------------------------
		#if _MSC_VER >= 1300
			CFile file (hFile);
		#else
			CFile file ((HFILE) hFile);
		#endif

		CArchive ar (&file, CArchive::store);

		m_bIsActive = TRUE;

		pBar->Serialize (ar);
		ar.Flush ();

		m_bIsActive = FALSE;
    }
	catch (CArchiveException* pEx)
	{
		TRACE(_T("Archive exception in CBCGPMenuHash::SaveMenuBar ()!\n"));
		pEx->Delete ();
        ::CloseHandle(hFile);

		m_bIsActive = FALSE;
		return FALSE;
	}
	catch (CMemoryException* pEx)
	{
		TRACE(_T("Memory exception in CBCGPMenuHash::SaveMenuBar ()!\n"));
		pEx->Delete ();
        ::CloseHandle(hFile);

		m_bIsActive = FALSE;
		return FALSE;
	}
	catch (CFileException* pEx)
	{
		TRACE(_T("File exception in CBCGPMenuHash::SaveMenuBar ()!\n"));
		pEx->Delete ();
        ::CloseHandle(hFile);

		m_bIsActive = FALSE;
		return FALSE;
	}

	m_StoredMenues.SetAt (hMenu, hFile);
	return TRUE;
}
Пример #3
0
// CStream
void CStream_ReadObject(CArchive& self, CSerializable::Ptr& obj)
{
	self.ReadObject(obj.get());
}
Пример #4
0
/*******************************************************************************
 Function Name  : nSerialize
 Input(s)       : omArchive - CArchive class. Serialisation stream
 Output         : -
 Functionality  : This function will serialise this class using CArchive stream
 Member of      : CGraphElement
 Author(s)      : Raja N
 Date Created   : 01.12.2004
 Modifications  : ArunKumar K
                  28.10.2010
                  Addition of m_eDisplayType variable for serialization.
*******************************************************************************/
int CGraphElement::nSerialize(CArchive& omArch)
{
    int nReturn = 0;

    // If it is storing
    try
    {
        if( omArch.IsStoring() )
        {
            // Save properties one after another
            // Message ID
            omArch << m_nMsgID  ;
            // Frame Format - Standard
            omArch << m_nFrameFormat;
            // Element Name String
            omArch << m_omStrElementName;
            // Type of the element val
            omArch << m_nValueType;
            // Line type of the elemen
            omArch << m_nLineType;
            // Line Color of the eleme
            omArch << m_nLineColor;
            // Sample point symbol typ
            omArch << m_nPointType;
            // Sample point symbol col
            omArch << m_nPointColor;
            // Visible or Not
            omArch << m_bVisible;
            // Enabled or not
            omArch << m_bEnabled;
        }
        // This is for loading
        else
        {
            // Load properties one after another
            omArch >> m_nMsgID;
            // Frame Format - Standard
            omArch >> m_nFrameFormat;
            // Element Name String
            omArch >> m_omStrElementName;
            // Type of the element val
            omArch >> m_nValueType;
            // Line type of the elemen
            omArch >> m_nLineType;
            // Line Color of the eleme
            omArch >> m_nLineColor;
            // Sample point symbol typ
            omArch >> m_nPointType;
            // Sample point symbol col
            omArch >> m_nPointColor;
            // Visible or Not
            omArch >> m_bVisible;
            // Enabled or not
            omArch >> m_bEnabled;
        }
    }
    catch(CArchiveException* poArchExcep)
    {
        // Get the Exception code and delete the dynamic object
        nReturn = poArchExcep->m_cause;
        poArchExcep->Delete();
    }

    // Return the result
    return nReturn;
}
Пример #5
0
void CPictureInfoTag::Archive(CArchive& ar)
{
  if (ar.IsStoring())
  {
    ar << m_isLoaded;
    ar << m_isInfoSetExternally;
    ar << m_exifInfo.ApertureFNumber;
    ar << CStdString(m_exifInfo.CameraMake);
    ar << CStdString(m_exifInfo.CameraModel);
    ar << m_exifInfo.CCDWidth;
    ar << GetInfo(SLIDE_EXIF_COMMENT); // Store and restore the comment charset converted
    ar << CStdString(m_exifInfo.Description);
    ar << CStdString(m_exifInfo.DateTime);
    for (int i = 0; i < 10; i++)
      ar << m_exifInfo.DateTimeOffsets[i];
    ar << m_exifInfo.DigitalZoomRatio;
    ar << m_exifInfo.Distance;
    ar << m_exifInfo.ExposureBias;
    ar << m_exifInfo.ExposureMode;
    ar << m_exifInfo.ExposureProgram;
    ar << m_exifInfo.ExposureTime;
    ar << m_exifInfo.FlashUsed;
    ar << m_exifInfo.FocalLength;
    ar << m_exifInfo.FocalLength35mmEquiv;
    ar << m_exifInfo.GpsInfoPresent;
    ar << CStdString(m_exifInfo.GpsAlt);
    ar << CStdString(m_exifInfo.GpsLat);
    ar << CStdString(m_exifInfo.GpsLong);
    ar << m_exifInfo.Height;
    ar << m_exifInfo.IsColor;
    ar << m_exifInfo.ISOequivalent;
    ar << m_exifInfo.LargestExifOffset;
    ar << m_exifInfo.LightSource;
    ar << m_exifInfo.MeteringMode;
    ar << m_exifInfo.numDateTimeTags;
    ar << m_exifInfo.Orientation;
    ar << m_exifInfo.Process;
    ar << m_exifInfo.ThumbnailAtEnd;
    ar << m_exifInfo.ThumbnailOffset;
    ar << m_exifInfo.ThumbnailSize;
    ar << m_exifInfo.ThumbnailSizeOffset;
    ar << m_exifInfo.Whitebalance;
    ar << m_exifInfo.Width;
    ar << m_dateTimeTaken;

    ar << CStdString(m_iptcInfo.Author);
    ar << CStdString(m_iptcInfo.Byline);
    ar << CStdString(m_iptcInfo.BylineTitle);
    ar << CStdString(m_iptcInfo.Caption);
    ar << CStdString(m_iptcInfo.Category);
    ar << CStdString(m_iptcInfo.City);
    ar << CStdString(m_iptcInfo.Urgency);
    ar << CStdString(m_iptcInfo.CopyrightNotice);
    ar << CStdString(m_iptcInfo.Country);
    ar << CStdString(m_iptcInfo.CountryCode);
    ar << CStdString(m_iptcInfo.Credit);
    ar << CStdString(m_iptcInfo.Date);
    ar << CStdString(m_iptcInfo.Headline);
    ar << CStdString(m_iptcInfo.Keywords);
    ar << CStdString(m_iptcInfo.ObjectName);
    ar << CStdString(m_iptcInfo.ReferenceService);
    ar << CStdString(m_iptcInfo.Source);
    ar << CStdString(m_iptcInfo.SpecialInstructions);
    ar << CStdString(m_iptcInfo.State);
    ar << CStdString(m_iptcInfo.SupplementalCategories);
    ar << CStdString(m_iptcInfo.TransmissionReference);
    ar << CStdString(m_iptcInfo.TimeCreated);
    ar << CStdString(m_iptcInfo.SubLocation);
    ar << CStdString(m_iptcInfo.ImageType);
  }
  else
  {
    ar >> m_isLoaded;
    ar >> m_isInfoSetExternally;
    ar >> m_exifInfo.ApertureFNumber;
    GetStringFromArchive(ar, m_exifInfo.CameraMake, sizeof(m_exifInfo.CameraMake));
    GetStringFromArchive(ar, m_exifInfo.CameraModel, sizeof(m_exifInfo.CameraModel));
    ar >> m_exifInfo.CCDWidth;
    GetStringFromArchive(ar, m_exifInfo.Comments, sizeof(m_exifInfo.Comments));
    m_exifInfo.CommentsCharset = EXIF_COMMENT_CHARSET_CONVERTED; // Store and restore the comment charset converted
    GetStringFromArchive(ar, m_exifInfo.Description, sizeof(m_exifInfo.Description));
    GetStringFromArchive(ar, m_exifInfo.DateTime, sizeof(m_exifInfo.DateTime));
    for (int i = 0; i < 10; i++)
      ar >> m_exifInfo.DateTimeOffsets[i];
    ar >> m_exifInfo.DigitalZoomRatio;
    ar >> m_exifInfo.Distance;
    ar >> m_exifInfo.ExposureBias;
    ar >> m_exifInfo.ExposureMode;
    ar >> m_exifInfo.ExposureProgram;
    ar >> m_exifInfo.ExposureTime;
    ar >> m_exifInfo.FlashUsed;
    ar >> m_exifInfo.FocalLength;
    ar >> m_exifInfo.FocalLength35mmEquiv;
    ar >> m_exifInfo.GpsInfoPresent;
    GetStringFromArchive(ar, m_exifInfo.GpsAlt, sizeof(m_exifInfo.GpsAlt));
    GetStringFromArchive(ar, m_exifInfo.GpsLat, sizeof(m_exifInfo.GpsLat));
    GetStringFromArchive(ar, m_exifInfo.GpsLong, sizeof(m_exifInfo.GpsLong));
    ar >> m_exifInfo.Height;
    ar >> m_exifInfo.IsColor;
    ar >> m_exifInfo.ISOequivalent;
    ar >> m_exifInfo.LargestExifOffset;
    ar >> m_exifInfo.LightSource;
    ar >> m_exifInfo.MeteringMode;
    ar >> m_exifInfo.numDateTimeTags;
    ar >> m_exifInfo.Orientation;
    ar >> m_exifInfo.Process;
    ar >> m_exifInfo.ThumbnailAtEnd;
    ar >> m_exifInfo.ThumbnailOffset;
    ar >> m_exifInfo.ThumbnailSize;
    ar >> m_exifInfo.ThumbnailSizeOffset;
    ar >> m_exifInfo.Whitebalance;
    ar >> m_exifInfo.Width;
    ar >> m_dateTimeTaken;

    GetStringFromArchive(ar, m_iptcInfo.Author, sizeof(m_iptcInfo.Author));
    GetStringFromArchive(ar, m_iptcInfo.Byline, sizeof(m_iptcInfo.Byline));
    GetStringFromArchive(ar, m_iptcInfo.BylineTitle, sizeof(m_iptcInfo.BylineTitle));
    GetStringFromArchive(ar, m_iptcInfo.Caption, sizeof(m_iptcInfo.Caption));
    GetStringFromArchive(ar, m_iptcInfo.Category, sizeof(m_iptcInfo.Category));
    GetStringFromArchive(ar, m_iptcInfo.City, sizeof(m_iptcInfo.City));
    GetStringFromArchive(ar, m_iptcInfo.Urgency, sizeof(m_iptcInfo.Urgency));
    GetStringFromArchive(ar, m_iptcInfo.CopyrightNotice, sizeof(m_iptcInfo.CopyrightNotice));
    GetStringFromArchive(ar, m_iptcInfo.Country, sizeof(m_iptcInfo.Country));
    GetStringFromArchive(ar, m_iptcInfo.CountryCode, sizeof(m_iptcInfo.CountryCode));
    GetStringFromArchive(ar, m_iptcInfo.Credit, sizeof(m_iptcInfo.Credit));
    GetStringFromArchive(ar, m_iptcInfo.Date, sizeof(m_iptcInfo.Date));
    GetStringFromArchive(ar, m_iptcInfo.Headline, sizeof(m_iptcInfo.Headline));
    GetStringFromArchive(ar, m_iptcInfo.Keywords, sizeof(m_iptcInfo.Keywords));
    GetStringFromArchive(ar, m_iptcInfo.ObjectName, sizeof(m_iptcInfo.ObjectName));
    GetStringFromArchive(ar, m_iptcInfo.ReferenceService, sizeof(m_iptcInfo.ReferenceService));
    GetStringFromArchive(ar, m_iptcInfo.Source, sizeof(m_iptcInfo.Source));
    GetStringFromArchive(ar, m_iptcInfo.SpecialInstructions, sizeof(m_iptcInfo.SpecialInstructions));
    GetStringFromArchive(ar, m_iptcInfo.State, sizeof(m_iptcInfo.State));
    GetStringFromArchive(ar, m_iptcInfo.SupplementalCategories, sizeof(m_iptcInfo.SupplementalCategories));
    GetStringFromArchive(ar, m_iptcInfo.TransmissionReference, sizeof(m_iptcInfo.TransmissionReference));
    GetStringFromArchive(ar, m_iptcInfo.TimeCreated, sizeof(m_iptcInfo.TimeCreated));
    GetStringFromArchive(ar, m_iptcInfo.SubLocation, sizeof(m_iptcInfo.SubLocation));
    GetStringFromArchive(ar, m_iptcInfo.ImageType, sizeof(m_iptcInfo.ImageType));
  }
}
void CBCGPRecurrence::Serialize (CArchive& ar)
{
	CObject::Serialize (ar);

	if (ar.IsStoring ())
	{
		ASSERT_VALID (m_pRule);

		ar << m_pRule;
		ar << (DWORD)m_Exceptions.GetCount ();

		POSITION Pos = m_Exceptions.GetStartPosition ();
		COleDateTime Key;
		XBCGPRecurrenceException* Val = NULL;

		while (Pos != NULL)
		{
			m_Exceptions.GetNextAssoc (Pos, Key, Val);

			ar << Key;
			ar << Val->m_dtStart;
			ar << Val->m_dtFinish;
			ar << Val->m_Deleted;

			if (!Val->m_Deleted)
			{
				ar << &(Val->m_Properties);
			}
		}
	}
	else
	{
		RemoveExceptions ();

		CBCGPRecurrenceBaseRule* pRule = NULL;
		ar >> pRule;

		ASSERT_VALID (pRule);

		SetRule (pRule);

		delete pRule;

		DWORD dwCount = 0;
		ar >> dwCount;

		for (DWORD i = 0; i < dwCount; i++)
		{
			COleDateTime Key;
			ar >> Key;

			XBCGPRecurrenceException* Val = new XBCGPRecurrenceException;
			ar >> Val->m_dtStart;
			ar >> Val->m_dtFinish;
			ar >> Val->m_Deleted;

			if (!Val->m_Deleted)
			{
				CBCGPAppointmentPropertyList* pList = NULL;
				ar >> pList;
				
				Val->m_Properties.CopyFrom (*pList);

				delete pList;
			}

			m_Exceptions[Key] = Val;
		}
	}
Пример #7
0
/*******************************************************************************
 Function Name  : nSerialize
 Input(s)       : omArchive - CArchive class. Serialisation stream
 Output         : -
 Functionality  : This function will serialise this class using CArchive stream
 Member of      : CGraphParameters
 Author(s)      : Raja N
 Date Created   : 01.12.2004
 Modifications  : 
*******************************************************************************/
int CGraphParameters::nSerialize(CArchive& omArchive)
{
    int nReturn = 0;
    try
    {
        // If it is storing
        if( omArchive.IsStoring() )
        {
            // Set the def
            omArchive << m_nBufferSize;
            // Display ref
            omArchive << m_nRefreshRate;
            // View Style 
            // Frame Color
            omArchive << m_nFrameColor;
            // Frame Style
            omArchive << m_nFrameStyle;
            // Plot Area C
            omArchive << m_nPlotAreaColor;
            // Grid Color
            omArchive << m_nGridColor;
            // Axis Color
            omArchive << m_nAxisColor;
            // X Grid Line
            omArchive << m_nXGridLines;
            // Y Grid Line
            omArchive << m_nYGridLines;
            // User Select
            omArchive << m_nActiveAxis;
            // User Select
            omArchive << m_nAction ;
            // Grid Settin
            omArchive << m_bShowGrid;
        }
        // This is for loading
        else
        {
            // Set the def
            omArchive >> m_nBufferSize;
            // Display ref
            omArchive >> m_nRefreshRate;
            // View Style 
            // Frame Color
            omArchive >> m_nFrameColor;
            // Frame Style
            omArchive >> m_nFrameStyle;
            // Plot Area C
            omArchive >> m_nPlotAreaColor;
            // Grid Color
            omArchive >> m_nGridColor;
            // Axis Color
            omArchive >> m_nAxisColor;
            // X Grid Line
            omArchive >> m_nXGridLines;
            // Y Grid Line
            omArchive >> m_nYGridLines;
            // User Select
            omArchive >> m_nActiveAxis;
            // User Select
            omArchive >> m_nAction ;
            // Grid Settin
            omArchive >> m_bShowGrid;
        }
    }
    catch(CArchiveException* poArchExcep)
    {
        // Get the Error Code and delete dynamic object
        nReturn = poArchExcep->m_cause;
        poArchExcep->Delete();
    }
    // Return the result
    return nReturn;
}
Пример #8
0
//
// PreloadPBNFile()
//
// - preload the PBN file and strip comments
//
int CEasyBDoc::PreloadPBNFile(CArchive& ar, CStringArray& strLines)
{
	int numLinesRead = 0;
	strLines.RemoveAll();

	// read in the file
	CString strBuf;
	int nSize = ar.GetFile()->GetLength();
	PBYTE pBuf = (PBYTE) strBuf.GetBuffer(nSize);
	int numBytesRead = ar.Read(pBuf, nSize);
	ASSERT(numBytesRead == nSize);
	strBuf.ReleaseBuffer(nSize);

	// check for export tag
	int nPos = strBuf.Find(_T("% EXPORT"));
	if (nPos < 0)   // NCR_PBNI allow as first line (was < 1)
	{
		AfxMessageBox("The Files is not in PBN Export format.");
//		AfxThrowFileException(CFileException::generic);
		isExportFile = false;  // NCR_PBNI Not export file - fewer tags required
	}

	// remove comments
	nPos = strBuf.Find(_T('{'));
	while(nPos >= 0)
	{
		// see if this comment started a new line
		bool bNewLine = false;
		if ((nPos > 0) && ((strBuf[nPos-1] == _T('\n')) || (strBuf[nPos-1] == _T('\r'))))
			bNewLine = true;

		// find the end of the comment section
		CString strMid = strBuf.Mid(nPos);
		int nEnd = strMid.Find(_T('}'));
		ASSERT(nEnd >= 0);

		// search for the next nonspace character
		nEnd++;
		int nLen = strMid.GetLength();
		// NCR test if comment at end of file
		if(nLen == nEnd)
			break;		// NCR exit if at end
		while ((nEnd < nLen) && (_istspace(strMid[nEnd])))
			nEnd++;

		// and trim and re-combine
		if ((nEnd < nLen) && (strMid[nEnd] == _T('[')) && !bNewLine)
			strBuf = strBuf.Left(nPos) + _T('\n') + strMid.Mid(nEnd);
		else
			strBuf = strBuf.Left(nPos) + strMid.Mid(nEnd);
		nPos = strBuf.Find(_T('{'));
	} // end while() removing comment

	// remove '!' suffixes
	strBuf.Remove(_T('!'));

	// remove any question marks that are not preceded by a quote character
	// '?' characters may be used in tag values as well as used for quality ratings
	for(int i=0;i<strBuf.GetLength();i++)
	{
		if ((i > 0) && (strBuf[i] == _T('?')) && (strBuf[i-1] != _T('\"')))
		{
			strBuf = strBuf.Left(i) + strBuf.Mid(i+1);
			i--;
		}
	}

	// organize into lines
	int nLen, nIndex = -1;
	BOOL bEmptyLineAdded = FALSE;
	do
	{
		// locate the end of the current line
		nLen = strBuf.GetLength();
		nIndex = -1;
		for(int i=0;i<nLen;i++)
		{
			if ((strBuf[i] == _T('\r')) || (strBuf[i] == _T('\n')))
			{
				nIndex = i;
				break;
			}
		}
		// add the line if not empty
		if (nIndex >= 0)
		{
			// add the string if it's not a comment
			if (strBuf[0] != _T('%'))
			{
				// test for an empty line by removing whitespace
				CString strTest = strBuf.Left(nIndex);
				strTest.TrimLeft();
				if (strTest.IsEmpty())
				{
					if (!bEmptyLineAdded)
					{
						strLines.Add(_T(""));
						bEmptyLineAdded = TRUE;
						numLinesRead++;
					}
				}
				else
				{
					// it's a nonblank line
					// trim any rest-of-line comments
					int nPos = strTest.Find(_T(';'));
					if (nPos >= 0)
						strTest = strTest.Left(nPos);

					// and add the line
					strLines.Add(strTest);
					bEmptyLineAdded = FALSE;
					numLinesRead++;
				}
			}

			// and skip over the CF/LF pair
			int nCharCount = 0;
			while ( (nIndex < nLen) && ((strBuf[nIndex] == _T('\r')) || (strBuf[nIndex] == _T('\n'))) )
			{
				nIndex++;
				nCharCount++;
			}

			// if more than one CR/LF pair (or two LF's) was found, add an empty line
			if ( ( (nCharCount > 2) || ((nIndex >= 2) && (strBuf[nIndex-1] == _T('\n')) && (strBuf[nIndex-2] == _T('\n'))) ) && 
				   (!bEmptyLineAdded))
			{
				strLines.Add(_T(""));
				numLinesRead++;
				bEmptyLineAdded = TRUE;
			}

			// chop off the part of the string that was read
			if (nIndex < nLen)
			{
				strBuf = strBuf.Mid(nIndex);
			}
			else
			{
				// reached the end of file
				strBuf.Empty();
				// add an empty line just to make sure
				strLines.Add(_T(""));
				numLinesRead++;
				bEmptyLineAdded = TRUE;
			}
		}
	}
	while ((nIndex >= 0) && !strBuf.IsEmpty());

	// done
	return numLinesRead;
}
Пример #9
0
BOOL CEasyBDoc::ReadFilePLL(CArchive& ar) 
{	
	const int DealDataLen = 772;   // number of bytes for a deal
	// read in the file
	CString strBuf;
	int nSize = ar.GetFile()->GetLength();
	PBYTE pBuf = (PBYTE) strBuf.GetBuffer(nSize);
	int numBytesRead = ar.Read(pBuf, nSize);
	ASSERT(numBytesRead == nSize);

    // Check first 2 bytes
	if(pBuf[0] != 0x01 || pBuf[1] != 0x04) {
		AfxMessageBox("The File is not in PLL format.");
		AfxThrowFileException(CFileException::generic);
	}

	int nbrDeals = numBytesRead / DealDataLen;
	if(nbrDeals > 1) {
		AfxMessageBox("EasyBridge currently only reads first deal.");
	}
	// Ok, now parse the hands - we'll only get the first deal
	pGameRecord = new CGameRecord;
	
	const int FirstByte = 48;  // first byte of hands
	int dealer = pBuf[FirstByte + 32]; // 0=N, 1=E, 2=S, 3=W
	const Position PPL2EB[] = {NORTH, EAST, SOUTH, WEST};
	dealer = PPL2EB[dealer];  // convert
	pGameRecord->m_nDealer = dealer;  // save

	int vulner = pBuf[FirstByte + 33];
	CString theDeal[4][4];      // hands and suits
	const int bb[] = {1,2,4,8,16,32,64,128}; // bit test masks
	const char * LowFaceValue[] = {"2", "3", "4", "5", "6", "7", "8", "9"};
	const char * HighFaceValue[] = {"T", "J", "Q", "K", "A"};

	for(int jj = 0; jj < 16; jj++) {
		char byte1 = pBuf[FirstByte+(jj*2)+1];  // High card flags T-A
		char byte2 = pBuf[FirstByte+(jj*2)+0];  // Low card flags 2-9 
		int handIdx = jj / 4;
		int suitIdx = 3 - (jj % 4);
		// First get the High cards from byte1
    	int kk; // NCR-FFS added here, removed below
		for(/*int*/ kk = 4; kk >=0; kk--) {
			if((byte1 & bb[kk]) != 0)
				theDeal[handIdx][suitIdx] += HighFaceValue[kk];
		} // end for(kk) thru High card byte
		// now the low cards
		for(kk = 7; kk >=0; kk--) {
			if((byte2 & bb[kk]) != 0)
				theDeal[handIdx][suitIdx] += LowFaceValue[kk];
		} // end for(kk) thru Low card byte

	} // end jj

	// Now build the deal a la PBN
	CString aDeal = "N:";
	for (int i = 0; i < 4; i++) {
		aDeal += theDeal[i][0] + "." +theDeal[i][1] + "." +theDeal[i][2] + "." +theDeal[i][3] 
			      + ((i < 3) ? " " : "");  // nothing at the end
    }
/*
	// Hard code for testing
	pGameRecord->m_nDealer = NORTH; //SOUTH=0, WEST=1, NORTH=2, EAST=3,
	pGameRecord->m_nVulnerability = EAST_WEST; //NEITHER=-1, NORTH_SOUTH=0, EAST_WEST=1, BOTH=2
	// Following deal from N-Sbid1H_Make4H.pbn
	CString aDeal = "S:KQ62.Q97.K765.52 94.AKJ4.Q92.JT97 875.852.AJT3.K63 AJT3.T63.84.AQ84";

	// Following from EasyBridgeGame2.pbn   hand order: W N E S
//	CString aDeal = "W:6.A852.KT43.Q965 A532.94.AJ85.A74 KQJ87.3.Q62.KT83 T94.KQJT76.97.J2";
//	pGameRecord->m_nDealer = EAST; //SOUTH=0, WEST=1, NORTH=2, EAST=3,
*/
	pGameRecord->SetTagValue("DEAL", aDeal);  //NOTE ALL CAPS for Keys!!! <<<<<<
	pGameRecord->SetTagValue("BOARD", "1");   // Hardcoded value ???

//	AssignCardsPBN(aDeal);  // use this method
//	theApp.SetValue(tbGameInProgress, FALSE);

	pGameRecord->AnalyzePlayRecord();
//	if(pGameRecord->IsValid()) {  // this only for PBN
		m_gameRecords.Add(pGameRecord);
//	}

	return TRUE;
}
Пример #10
0
void CProtoHapticDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
		ar << m_shapeCount;
		int i;
		for (i= 0; i<m_shapeCount; i++) {
			ar << m_shapes[i]->getType();
			m_shapes[i]->Serialize(ar);
		}

		ar << m_memoCount;
		for (i= 0; i<m_memoCount; i++) {
			m_memos[i]->Serialize(ar);
		}
		ar << m_simSpeed
		   << m_airResistance
		   << m_gravity;
		if(m_hideMemos) ar << 1; else ar << 0;

		if(m_dynamicSurfaceChange) ar << 1; else ar << 0;
	}
	else
	{
		POSITION pos = GetFirstViewPosition();
		while (pos != NULL)
		{
			CView* pView = GetNextView(pos);
			((CProtoHapticView*)pView)->Pause();
			((CProtoHapticView*)pView)->Deselect();
			((CProtoHapticView*)pView)->Play();
		}
		
		// Render an empty scene and syc, so that shape callbacks
		// (which access shape data about to be deleted) are not called by rendering thread
		// after data has been deleted by client thread
		hlBeginFrame ();
		hlEndFrame ();

		clean(); //Destroy existing document

		m_historyCount= 0;
		m_shapeCount= 0;
		m_memoCount= 0;

		dWorldDestroy(m_worldID);
		m_worldID= dWorldCreate();

		//dSpaceDestroy(m_spaceID);
		m_spaceID= dHashSpaceCreate(0);

		int count;
		ar >> count;
		int i;
		for (i= 0; i<count; i++)
		{	
			int shapeType;
			CShape* s= NULL;
			ar >> shapeType;
			if(shapeType==SHAPE_CUBE)		s= new CCube(1,1,1);
			if(shapeType==SHAPE_SPHERE)		s= new CSphere(1,1,1);
			if(shapeType==SHAPE_CYLINDER)	s= new CCylinder(1,1,1);
			if(shapeType==SHAPE_COMPOSITE)	s= new CComposite();
			if(shapeType==SHAPE_TRIANGLE)	s= new CTriangle();
			if(shapeType==SHAPE_TORUS)		s= new CTorus();
			
			// Unknown shape type
			if ( s == NULL )
			{
				MessageBox ( 0, "There was an error whilst reading the specified file: Unknown Shape.", "Error", MB_OK );
				return;
			}
			else
			{
				s->Serialize(ar);
				AddShape(s);
			}
		}

		ar >> count;
		for(i= 0; i<count; i++)
		{
			CMemo* m;
			m= new CMemo();
			m->Serialize(ar);
			addMemo(m);
		}
		ar >> m_simSpeed
		   >> m_airResistance
		   >> m_gravity;
		ar >> i;
		if(i==1) 
			m_hideMemos= true; 
		else 
			m_hideMemos= false;

		// Dynamic surface change in view mode (Version > 4)
		ar >> i;
		if(i==1) 
			m_dynamicSurfaceChange= true; 
		else 
			m_dynamicSurfaceChange= false;

		pos = GetFirstViewPosition();
		while (pos != NULL)
		{
			CView* pView = GetNextView(pos);
			((CProtoHapticView*)pView)->CenterCamera();
		} 
	}
}
Пример #11
0
void CResourceMapDoc::Serialize(CArchive& ar)
{
    if (ar.IsStoring())
    {
        // There is nothing to save.
        int x = 0;
    }
    else
    {
        CFile *pFile = ar.GetFile();

        // Set the current directory, so we know where to look for the resource files.
        // If not, clicking on an item in the recent documents list won't work
        CString path = pFile->GetFilePath();
        path.MakeLower();
        int iFileOffset = path.Find(TEXT("\\resource.map"));
        if (iFileOffset > 0)
        {
            path.SetAt(iFileOffset, 0); // Null terminate it

            // Set this folder as our new game folder
            CResourceMap &map = theApp.GetResourceMap();
            map.SetGameFolder(path);

            // Close it.  We only wanted the path.
            pFile->Close();

            // Clear the current view.
            _DeleteAllResourceData();
            _DeleteAllPics();

            CResourceEnumerator *pEnum;
            if (SUCCEEDED(map.CreateEnumerator(RTF_PIC, &pEnum)))
            {
                CResourceData *pData;
                while (S_OK == pEnum->Next(&pData))
                {
                    // TODO: try catch, and free pData?

                    // Add these resource datas.
                    _resources.Add(pData);

                    // And create a pic from them.
                    CPic *ppic = new CPic();
                    if (ppic)
                    {
                        if (SUCCEEDED(ppic->InitFromResource(pData)))
                        {
                            _pics.Add(ppic);
                        }
                        else
                        {
                            delete ppic;
                        }
                    }
                }

#ifdef DEBUG
                INT_PTR iSizeMemory = 0;
                for (INT_PTR i = 0; i < _pics.GetSize(); i++)
                {
                    CPic *ppic = _pics.GetAt(i);
                    iSizeMemory += ppic->GetMemorySize();
                }
                TCHAR sz[MAX_PATH];
                StringCchPrintf(sz, ARRAYSIZE(sz), TEXT("Memory size of pics: %d"), iSizeMemory);
                OutputDebugString(sz);
#endif 

                SetModifiedFlag(TRUE);
                UpdateAllViews(NULL, VIEWUPDATEHINT_RESOURCEMAPCHANGED);

                delete pEnum;
            }

        }
        else
        {
            AfxMessageBox(TEXT("SCI game resources must be called resource.map"), MB_OK | MB_ICONEXCLAMATION);
        }
    }
}
Пример #12
0
void CdIpmDoc::Serialize(CArchive& ar)
{
	CString caption;
	m_connectedInfo.Serialize(ar);

	if (ar.IsStoring())
	{
		ar << m_hNode;
		ar << m_hReplMonHandle;
		ar << m_nOIVers;

		// filter structure
		ar.Write(&m_sFilter, sizeof(m_sFilter));

		// splitbar
		if (m_bShowTree )
		{
			POSITION pos = GetFirstViewPosition();
			CView *pView = GetNextView(pos);
			ASSERT (pView);
			CSplitterWnd *pSplit = (CSplitterWnd *)pView->GetParent();
			ASSERT (pSplit);
			pSplit->GetColumnInfo(0, m_cxCur, m_cxMin);
		}
		ar << m_cxCur;
		ar << m_cxMin;

		ASSERT (m_pTabDialog);
		CuIpmPropertyData* pData = m_pTabDialog->GetDialogData();
		CuIpmProperty* pCurrentProperty = m_pTabDialog->GetCurrentProperty();
		if (pCurrentProperty) 
		{
			pCurrentProperty->SetPropertyData (pData);
			ar << pCurrentProperty;
		}

		ar << m_strSelectKey;
		ar << m_bShowTree;
	}
	else
	{
		m_bLoaded = TRUE;

		ar >> m_hNode; // Note : OpenNodeStruct() MUST NOT BE CALLED!
		ar >> m_hReplMonHandle;
		ar >> m_nOIVers;
		IPM_SetDbmsVersion(m_nOIVers);

		// filter structure
		ar.Read(&m_sFilter, sizeof(m_sFilter));

		// splitbar
		ar >> m_cxCur;
		ar >> m_cxMin;

		if (m_pCurrentProperty)
		{
			delete m_pCurrentProperty;
			m_pCurrentProperty = NULL;
		}
		ar >> m_pCurrentProperty;
		ar >> m_strSelectKey;
		ar >> m_bShowTree;
	}
	m_arrItemPath.Serialize(ar);
	IPM_SerializeChache(ar);

	// global data for the tree, including tree lines
	// ex - m_pTreeGD->Serialize(ar);
	if (ar.IsStoring())
	{
		ar << m_pTreeGD;
	}
	else
	{
		delete m_pTreeGD; // memory leak otherwise
		ar >> m_pTreeGD;
		m_pTreeGD->SetPSFilter(&m_sFilter);
		m_pTreeGD->SetDocument(this);
	}
}
Пример #13
0
BOOL CDrawDoc::StoreForPrinting(CArchive& ar)
{
	// setting up EMF DC, using default printer as reference	
	HDC hPrt = ((CDrawApp*)AfxGetApp()) -> GetDefaultPrinterIC() ;
	if (!hPrt) return FALSE;
	RECT rect={0, 0, GetDeviceCaps(hPrt,HORZSIZE)*100, GetDeviceCaps(hPrt,VERTSIZE)*100};
	CDC dc;
	if (! (dc.m_hDC = CreateEnhMetaFile(hPrt, NULL, &rect, NULL))) return FALSE;
	dc.SetAttribDC(dc.m_hDC);

	// recording meta file
	POSITION pos = GetFirstViewPosition();
	CDrawView* pView = (CDrawView*)GetNextView(pos);
	if (pView == NULL) return FALSE;
	CDrawView::m_IsRecording = TRUE;
	pView -> OnPrepareDC(&dc, NULL);
	Draw(&dc, pView);
	CDrawView::m_IsRecording = FALSE;             
	HENHMETAFILE hEmf = CloseEnhMetaFile(dc.m_hDC);

	// storing EMF into archive
	DWORD size = GetEnhMetaFileBits(hEmf, NULL, NULL);
	if (size == 0) return FALSE;
	HGLOBAL hglobal = GlobalAlloc(GMEM_MOVEABLE, size);
	if (hglobal == NULL) return FALSE;
	LPBYTE buf = (LPBYTE)GlobalLock(hglobal);
	if (buf == NULL) return FALSE;
	if (GetEnhMetaFileBits(hEmf,size,buf) != size) return FALSE;

	SEPFILEHEADER header;

	// set EMF size (header)
	header.dwEmfSize = size;

	// get text objects count
	pos = m_objects.GetHeadPosition();
	DWORD count=0;
	while (pos != NULL)
		{
		CDrawText* pObj = (CDrawText*)(m_objects.GetNext(pos));
		if (pObj->GetLogFontCopy() != NULL)	
			count++;
		}
	// set text records (header)
	header.dwTextRecords = count;

	// set page size (in logical) (header)
	header.sizePage = GetSize();

	// write header
	ar.Write(&header,sizeof(SEPFILEHEADER));

	// write EMF into archive
	ar.Write(buf, size);
	GlobalUnlock(hglobal);
	GlobalFree(hglobal);
	DeleteEnhMetaFile(hEmf);
	
		
	// Save text objects for job-info realization and printing

	// write text records into archive
	pos = m_objects.GetHeadPosition();
	while (pos != NULL)
		{
		CDrawText* pObj = (CDrawText*)(m_objects.GetNext(pos));
		LOGFONT *plf;
		if ((plf=pObj->GetLogFontCopy()) != NULL)	// is text object
			{
			TEXTBOX tbox;
			tbox.position = pObj->m_position;
			tbox.color = pObj->m_color;
			tbox.align = pObj->m_align;
			tbox.lf = pObj->m_lf;
			strncpy(tbox.text,pObj->m_text,SEPMAXTEXT);
			ar.Write(&tbox,sizeof(TEXTBOX));
			} 
		}
	return TRUE;
}		
Пример #14
0
void CPathDoc::Serialize(CArchive& ar)
{
	POSITION pos;
	WORD nCount;
	WORD w;

	// General items to store
	if (ar.IsStoring())
	{
		ar << gGPSOriginLat;
		ar << gGPSOriginLong;
	}
	else
	{
		ar >> gGPSOriginLat;
		ar >> gGPSOriginLong;
	}

	// SegmentStruct Read/Write
	if (ar.IsStoring())
	{
		nCount = (WORD)m_SegmentList.GetCount();
		ar << nCount;
		pos = m_SegmentList.GetHeadPosition();
		while (pos != NULL)
		{
			CSegmentStruct* pSegmentStruct = m_SegmentList.GetNext(pos);

			ar << pSegmentStruct->m_SegmentName;
			w = (WORD)pSegmentStruct->m_SegmentFromWaypointID; ar << w;
			w = (WORD)pSegmentStruct->m_SegmentToWaypointID; ar << w;
			ar << pSegmentStruct->m_SegmentBehavior;
			ar << pSegmentStruct->m_SegmentSpeed;
			w = (WORD)pSegmentStruct->m_SegmentDirection; ar << w;
			w = (WORD)pSegmentStruct->m_SegmentDistanceFeet; ar << w;
			w = (WORD)pSegmentStruct->m_SegmentDistanceInches; ar << w;
			w = (WORD)pSegmentStruct->m_SegmentFollowDistance; ar << w;
			w = (WORD)pSegmentStruct->m_SegmentAvoidDistance; ar << w;
			w = (WORD)pSegmentStruct->m_SegmentFollowLeftRight; ar << w;

			w = (WORD)pSegmentStruct->m_CompassCorrection; ar << w;

			nCount--;
		}
		ASSERT(nCount == 0);
	}
	else
	{
		ar >> nCount;
		while (nCount-- > 0)
		{
			CSegmentStruct* pSegmentStruct = new CSegmentStruct;

			ar >> pSegmentStruct->m_SegmentName;
			ar >> w; pSegmentStruct->m_SegmentFromWaypointID = w;
			ar >> w; pSegmentStruct->m_SegmentToWaypointID = w;
			ar >> pSegmentStruct->m_SegmentBehavior;
			ar >> pSegmentStruct->m_SegmentSpeed;
			ar >> w; pSegmentStruct->m_SegmentDirection = w;
			ar >> w; pSegmentStruct->m_SegmentDistanceFeet = w;
			ar >> w; pSegmentStruct->m_SegmentDistanceInches = w;
			ar >> w; pSegmentStruct->m_SegmentFollowDistance = w;
			ar >> w; pSegmentStruct->m_SegmentAvoidDistance = w;
			ar >> w; pSegmentStruct->m_SegmentFollowLeftRight = w;

			// Change following 2 lines to read old path files
			//pSegmentStruct->m_CompassCorrection = 0;
			ar >> w; pSegmentStruct->m_CompassCorrection = w;

			m_SegmentList.AddTail(pSegmentStruct);
		}
	}

	// WaypointStruct Read/Write
	if (ar.IsStoring())
	{
		nCount = (WORD)m_WaypointList.GetCount();
		ar << nCount;
		pos = m_WaypointList.GetHeadPosition();
		while (pos != NULL)
		{
			CWaypointStruct* pWaypointStruct = m_WaypointList.GetNext(pos);

			ar << pWaypointStruct->m_WaypointName;
			w = (WORD)pWaypointStruct->m_WaypointID; ar << w;
			w = (WORD)pWaypointStruct->m_WaypointLocationFeetX; ar << w;
			w = (WORD)pWaypointStruct->m_WaypointLocationInchesX; ar << w;
			w = (WORD)pWaypointStruct->m_WaypointLocationFeetY; ar << w;
			w = (WORD)pWaypointStruct->m_WaypointLocationInchesY; ar << w;

			ar << pWaypointStruct->m_WaypointLandmarkType1;
			w = (WORD)pWaypointStruct->m_WaypointLandmarkDirection1; ar << w;
			w = (WORD)pWaypointStruct->m_WaypointLandmarkRange1; ar << w;
			w = (WORD)pWaypointStruct->m_WaypointLandmarkHeight1; ar << w;

			ar << pWaypointStruct->m_WaypointLandmarkType2;
			w = (WORD)pWaypointStruct->m_WaypointLandmarkDirection2; ar << w;
			w = (WORD)pWaypointStruct->m_WaypointLandmarkRange2; ar << w;
			w = (WORD)pWaypointStruct->m_WaypointLandmarkHeight2; ar << w;

			ar << pWaypointStruct->m_WaypointLandmarkType3;
			w = (WORD)pWaypointStruct->m_WaypointLandmarkDirection3; ar << w;
			w = (WORD)pWaypointStruct->m_WaypointLandmarkRange3; ar << w;
			w = (WORD)pWaypointStruct->m_WaypointLandmarkHeight3; ar << w;

			nCount--;
		}
		ASSERT(nCount == 0);
	}
	else
	{
		ar >> nCount;
		while (nCount-- > 0)
		{
			CWaypointStruct* pWaypointStruct = new CWaypointStruct;

			ar >> pWaypointStruct->m_WaypointName;
			ar >> w; pWaypointStruct->m_WaypointID = w;
			ar >> w; pWaypointStruct->m_WaypointLocationFeetX = w;
			ar >> w; pWaypointStruct->m_WaypointLocationInchesX = w;
			ar >> w; pWaypointStruct->m_WaypointLocationFeetY = w;
			ar >> w; pWaypointStruct->m_WaypointLocationInchesY = w;

			ar >> pWaypointStruct->m_WaypointLandmarkType1;
			ar >> w; pWaypointStruct->m_WaypointLandmarkDirection1 = w;
			ar >> w; pWaypointStruct->m_WaypointLandmarkRange1 = w;
			ar >> w; pWaypointStruct->m_WaypointLandmarkHeight1 = w;

			ar >> pWaypointStruct->m_WaypointLandmarkType2;
			ar >> w; pWaypointStruct->m_WaypointLandmarkDirection2 = w;
			ar >> w; pWaypointStruct->m_WaypointLandmarkRange2 = w;
			ar >> w; pWaypointStruct->m_WaypointLandmarkHeight2 = w;

			ar >> pWaypointStruct->m_WaypointLandmarkType3;
			ar >> w; pWaypointStruct->m_WaypointLandmarkDirection3 = w;
			ar >> w; pWaypointStruct->m_WaypointLandmarkRange3 = w;
			ar >> w; pWaypointStruct->m_WaypointLandmarkHeight3 = w;

			m_WaypointList.AddTail(pWaypointStruct);
		}
	}

}
Пример #15
0
void CGWorldOpenGL::WriteGWorldToVRML(CArchive& file,STATIONSHOW SS)
{
    char szBuffer[128];
    file.WriteString("#VRML V1.0 ascii\n");
    //We should probably just use the defaults and make things run faster instead of setting
    //a light source.
    file.WriteString("Separator {\n\tDEF SceneInfo Info {\n\t\tstring ");
    file<<'"';
    file.WriteString("Modeled using On Station 3.1");
    file<<'"';
    file.WriteString("\n\t}\n}\n");

    int iTriangleGroupCount=m_TriangleGroupArray.GetSize();
    for (int i=0; i<iTriangleGroupCount; i++)
    {
        sprintf(szBuffer,"DEF TriangleStrip%i Separator {\n",i+1);
        file.WriteString(szBuffer);
        CGWorldTriangleGroup const * pGroup=m_TriangleGroupArray.GetAt(i);
        pGroup->DumpToVRML(file);
        file.WriteString("}\n");
    }

    //Next, do the fixed points if appropriate
    int iFixedPointCount=m_ConstraintArray.GetSize();
    CPosMatrix ptPos;
    CPosMatrix transformedPos;
    for (i=0; i<iFixedPointCount; i++)
    {
        sprintf(szBuffer,"DEF FixedPoint%i Separator {\n",i+1);
        file.WriteString(szBuffer);

        const CGWorldOpenGLConstraint & fixedPoint=m_ConstraintArray.GetAt(i);
        file.WriteString("\tMaterial {\n\t\tdiffuseColor 1.0 0.0 0.0\n\t}\n");
        sprintf(szBuffer,"\tTranslation {\n\t\ttranslation %f %f %f\n\t}\n",fixedPoint.position[0],fixedPoint.position[1],fixedPoint.position[2]);
        file.WriteString(szBuffer);
        file.WriteString("\tSphere {\n\t\tradius 3\n\t}\n");
        file.WriteString("}\n");
    }
}
Пример #16
0
void CMusicInfoTag::Archive(CArchive& ar)
{
  if (ar.IsStoring())
  {
    ar << m_strURL;
    ar << m_strTitle;
    ar << m_artist;
    ar << m_strAlbum;
    ar << m_albumArtist;
    ar << m_genre;
    ar << m_iDuration;
    ar << m_iTrack;
    ar << m_bLoaded;
    ar << m_dwReleaseDate;
    ar << m_strMusicBrainzTrackID;
    ar << m_musicBrainzArtistID;
    ar << m_strMusicBrainzAlbumID;
    ar << m_musicBrainzAlbumArtistID;
    ar << m_strMusicBrainzTRMID;
    ar << m_lastPlayed;
    ar << m_dateAdded;
    ar << m_strComment;
    ar << m_strMood;
    ar << m_rating;
    ar << m_iTimesPlayed;
    ar << m_iAlbumId;
    ar << m_iDbId;
    ar << m_type;
    ar << m_strLyrics;
    ar << m_bCompilation;
    ar << m_listeners;
    ar << m_coverArt;
    ar << m_cuesheet;
    ar << static_cast<int>(m_albumReleaseType);
  }
  else
  {
    ar >> m_strURL;
    ar >> m_strTitle;
    ar >> m_artist;
    ar >> m_strAlbum;
    ar >> m_albumArtist;
    ar >> m_genre;
    ar >> m_iDuration;
    ar >> m_iTrack;
    ar >> m_bLoaded;
    ar >> m_dwReleaseDate;
    ar >> m_strMusicBrainzTrackID;
    ar >> m_musicBrainzArtistID;
    ar >> m_strMusicBrainzAlbumID;
    ar >> m_musicBrainzAlbumArtistID;
    ar >> m_strMusicBrainzTRMID;
    ar >> m_lastPlayed;
    ar >> m_dateAdded;
    ar >> m_strComment;
    ar >> m_strMood;
    ar >> m_rating;
    ar >> m_iTimesPlayed;
    ar >> m_iAlbumId;
    ar >> m_iDbId;
    ar >> m_type;
    ar >> m_strLyrics;
    ar >> m_bCompilation;
    ar >> m_listeners;
    ar >> m_coverArt;
    ar >> m_cuesheet;

    int albumReleaseType;
    ar >> albumReleaseType;
    m_albumReleaseType = static_cast<CAlbum::ReleaseType>(albumReleaseType);
  }
}
Пример #17
0
void CGWorldTriangleFan::DumpToVRML(CArchive& file) const
{
    char szBuffer[256];
    //write material properties
    sprintf(szBuffer,"\tMaterial {\n\t\tdiffuseColor %f %f %f\n\t\tambientColor %f %f %f\n\t}\n",	((float)GetRValue(m_crColor))/255.0f,((float)GetGValue(m_crColor))/255.0f,((float)GetBValue(m_crColor))/255.0f,	((float)GetRValue(m_crColor))/255.0f,((float)GetGValue(m_crColor))/255.0f,((float)GetBValue(m_crColor))/255.0f);
    file.WriteString(szBuffer);

    file.WriteString("\tCoordinate3	{\n\t\tpoint [\n");

    for (int i=0; i<m_iNumVertices; i++)
    {
        sprintf(szBuffer,"\t\t\t%f %f %f",m_pVertices[i].m_fPos[0],m_pVertices[i].m_fPos[1],m_pVertices[i].m_fPos[2]);
        file.WriteString(szBuffer);
        if (i!=m_iNumVertices-1)
        {
            file.WriteString(",\n");
        }
        else
        {
            file.WriteString("\n");
        }
    }
    file.WriteString("\t\t]\n\t}\n");
    file.WriteString("\tIndexedFaceSet {\n\t\tcoordIndex [\n");
    for (i=0; i<m_iNumVertices; i++)
    {
        sprintf(szBuffer,"\t\t\t%i,%i,%i,-1",0,(i+1)%m_iNumVertices,(i+2)%m_iNumVertices);
        file.WriteString(szBuffer);
        if (i!=m_iNumVertices-1)
        {
            file.WriteString(",\n");
        }
        else
        {
            file.WriteString("\n");
        }
    }
    file.WriteString("\t\t]\n\t}\n");
}
Пример #18
0
void CFormula::WriteFormula(CArchive& ar, bool use_new_OHF_style) 
{
	CString		s = "";
	int			i = 0, N = (int) _formula.mFunction.GetSize();
	char		nowtime[26] = {0};

	//  First write the standard formula functions...
	//  These are functions and symbols, that
	//	* are essential to control the behaviour 
	//	  of (nearly) every poker bot.
	//	* configure some very important constants.
	//  
	s.Format("##%s##\r\n\r\n", get_time(nowtime)); ar.WriteString(s);

	for (i=0; i<N; i++) 
		if (_formula.mFunction[i].func == "notes") 
			ar.WriteString("##notes##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n"); 

	for (i=0; i<N; i++) 
		if (_formula.mFunction[i].func == "dll")
			ar.WriteString("##dll##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");

	s.Format("##bankroll##\r\n%f\r\n\r\n", _formula.dBankroll); ar.WriteString(s);
	
	s.Format("##defcon##\r\n%f\r\n\r\n", _formula.dDefcon); ar.WriteString(s);
	
	s.Format("##rake##\r\n%f\r\n\r\n", _formula.dRake); ar.WriteString(s);
	
	s.Format("##nit##\r\n%d\r\n\r\n", (int) _formula.dNit); ar.WriteString(s);
	
	for (i=0; i<N; i++) 
		if (_formula.mFunction[i].func == "f$alli")
			ar.WriteString("##f$alli##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
	
	for (i=0; i<N; i++) 
		if (_formula.mFunction[i].func == "f$swag") 
			ar.WriteString("##f$swag##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
	
	for (i=0; i<N; i++) 
		if (_formula.mFunction[i].func == "f$srai") 
			ar.WriteString("##f$srai##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
	
	for (i=0; i<N; i++) 
		if (_formula.mFunction[i].func == "f$rais") 
			ar.WriteString("##f$rais##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
	
	for (i=0; i<N; i++) 
		if (_formula.mFunction[i].func == "f$call") 
			ar.WriteString("##f$call##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
	
	for (i=0; i<N; i++) 
		if (_formula.mFunction[i].func == "f$prefold") 
			ar.WriteString("##f$prefold##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
	
	// New standard formulas are
	//   * f$delay
	//   * f$chat
	//
	// Old standard formulas are:
	//   * f$evrais 
	//   * f§evcall
	//
	if (use_new_OHF_style)
	{
		for (i=0; i<N; i++) 
			if (_formula.mFunction[i].func == "f$delay") 
				ar.WriteString("##f$delay##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
	
		for (i=0; i<N; i++) 
			if (_formula.mFunction[i].func == "f$chat") 
				ar.WriteString("##f$chat##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
	}
	else
	{
		for (i=0; i<N; i++) 
			if (_formula.mFunction[i].func == "f$evrais") 
				ar.WriteString("##f$evrais##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
	
		for (i=0; i<N; i++) 
			if (_formula.mFunction[i].func == "f$evcall") 
				ar.WriteString("##f$evcall##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
	}

	for (i=0; i<N; i++) 
		if (_formula.mFunction[i].func == "f$P") 
			ar.WriteString("##f$P##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
	
	for (i=0; i<N; i++) 
		if (_formula.mFunction[i].func == "f$play") 
			ar.WriteString("##f$play##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
	
	for (i=0; i<N; i++) 
		if (_formula.mFunction[i].func == "f$test") 
			ar.WriteString("##f$test##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
	
	for (i=0; i<N; i++) 
		if (_formula.mFunction[i].func == "f$debug") 
			ar.WriteString("##f$debug##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");

	// handlists for both ohf and old whf style
	for (i=0; i<(int) _formula.mHandList.GetSize(); i++) 
		ar.WriteString("##" + _formula.mHandList[i].list + "##\r\n" + _formula.mHandList[i].list_text + "\r\n\r\n");

	// User defined functions for new ohf style only.
	// We don't ever have to save them, as for a conversion
	// we only have to generate an ohf file and (for technical reasons)
	// recreate the old whf (which is already open for storing).
	//
	if (use_new_OHF_style)
	{
		for (i=0; i<(int) _formula.mFunction.GetSize(); i++) 
		{
			if (_formula.mFunction[i].func != "notes" &&
				_formula.mFunction[i].func != "dll" &&
				_formula.mFunction[i].func != "f$alli" &&
				_formula.mFunction[i].func != "f$swag" &&
				_formula.mFunction[i].func != "f$srai" &&
				_formula.mFunction[i].func != "f$rais" &&
				_formula.mFunction[i].func != "f$call" &&
				_formula.mFunction[i].func != "f$prefold" &&
				_formula.mFunction[i].func != "f$delay" &&
				_formula.mFunction[i].func != "f$chat" &&
				_formula.mFunction[i].func != "f$P" &&
				_formula.mFunction[i].func != "f$play" &&
				_formula.mFunction[i].func != "f$test" &&
				_formula.mFunction[i].func != "f$debug" ) 
			{
				ar.WriteString("##" + _formula.mFunction[i].func + "##\r\n" + _formula.mFunction[i].func_text + "\r\n\r\n");
			}
		}
	}
}
Пример #19
0
void CVideoInfoTag::Archive(CArchive& ar)
{
  if (ar.IsStoring())
  {
    ar << m_director;
    ar << m_writingCredits;
    ar << m_genre;
    ar << m_country;
    ar << m_strTagLine;
    ar << m_strPlotOutline;
    ar << m_strPlot;
    ar << m_strPictureURL.m_spoof;
    ar << m_strPictureURL.m_xml;
    ar << m_fanart.m_xml;
    ar << m_strTitle;
    ar << m_strSortTitle;
    ar << m_strVotes;
    ar << m_studio;
    ar << m_strTrailer;
    ar << (int)m_cast.size();
    for (unsigned int i=0;i<m_cast.size();++i)
    {
      ar << m_cast[i].strName;
      ar << m_cast[i].strRole;
      ar << m_cast[i].order;
      ar << m_cast[i].thumb;
      ar << m_cast[i].thumbUrl.m_xml;
    }

    ar << m_strSet;
    ar << m_iSetId;
    ar << m_tags;
    ar << m_duration;
    ar << m_strFile;
    ar << m_strPath;
    ar << m_strIMDBNumber;
    ar << m_strMPAARating;
    ar << m_strFileNameAndPath;
    ar << m_strOriginalTitle;
    ar << m_strEpisodeGuide;
    ar << m_premiered;
    ar << m_strStatus;
    ar << m_strProductionCode;
    ar << m_firstAired;
    ar << m_strShowTitle;
    ar << m_strAlbum;
    ar << m_artist;
    ar << m_playCount;
    ar << m_lastPlayed;
    ar << m_iTop250;
    ar << m_iYear;
    ar << m_iSeason;
    ar << m_iEpisode;
    ar << m_strUniqueId;
    ar << m_fRating;
    ar << m_iDbId;
    ar << m_iFileId;
    ar << m_iSpecialSortSeason;
    ar << m_iSpecialSortEpisode;
    ar << m_iBookmarkId;
    ar << m_iTrack;
    ar << dynamic_cast<IArchivable&>(m_streamDetails);
    ar << m_showLink;
    ar << m_fEpBookmark;
    ar << m_basePath;
    ar << m_parentPathID;
    ar << m_resumePoint.timeInSeconds;
    ar << m_resumePoint.totalTimeInSeconds;
    ar << m_iIdShow;
    ar << m_strShowPath;
    ar << m_dateAdded.GetAsDBDateTime();
    ar << m_type;
    ar << m_iIdSeason;
  }
  else
  {
    ar >> m_director;
    ar >> m_writingCredits;
    ar >> m_genre;
    ar >> m_country;
    ar >> m_strTagLine;
    ar >> m_strPlotOutline;
    ar >> m_strPlot;
    ar >> m_strPictureURL.m_spoof;
    ar >> m_strPictureURL.m_xml;
    ar >> m_fanart.m_xml;
    ar >> m_strTitle;
    ar >> m_strSortTitle;
    ar >> m_strVotes;
    ar >> m_studio;
    ar >> m_strTrailer;
    int iCastSize;
    ar >> iCastSize;
    m_cast.reserve(iCastSize);
    for (int i=0;i<iCastSize;++i)
    {
      SActorInfo info;
      ar >> info.strName;
      ar >> info.strRole;
      ar >> info.order;
      ar >> info.thumb;
      CStdString strXml;
      ar >> strXml;
      info.thumbUrl.ParseString(strXml);
      m_cast.push_back(info);
    }

    ar >> m_strSet;
    ar >> m_iSetId;
    ar >> m_tags;
    ar >> m_duration;
    ar >> m_strFile;
    ar >> m_strPath;
    ar >> m_strIMDBNumber;
    ar >> m_strMPAARating;
    ar >> m_strFileNameAndPath;
    ar >> m_strOriginalTitle;
    ar >> m_strEpisodeGuide;
    ar >> m_premiered;
    ar >> m_strStatus;
    ar >> m_strProductionCode;
    ar >> m_firstAired;
    ar >> m_strShowTitle;
    ar >> m_strAlbum;
    ar >> m_artist;
    ar >> m_playCount;
    ar >> m_lastPlayed;
    ar >> m_iTop250;
    ar >> m_iYear;
    ar >> m_iSeason;
    ar >> m_iEpisode;
    ar >> m_strUniqueId;
    ar >> m_fRating;
    ar >> m_iDbId;
    ar >> m_iFileId;
    ar >> m_iSpecialSortSeason;
    ar >> m_iSpecialSortEpisode;
    ar >> m_iBookmarkId;
    ar >> m_iTrack;
    ar >> dynamic_cast<IArchivable&>(m_streamDetails);
    ar >> m_showLink;
    ar >> m_fEpBookmark;
    ar >> m_basePath;
    ar >> m_parentPathID;
    ar >> m_resumePoint.timeInSeconds;
    ar >> m_resumePoint.totalTimeInSeconds;
    ar >> m_iIdShow;
    ar >> m_strShowPath;

    CStdString dateAdded;
    ar >> dateAdded;
    m_dateAdded.SetFromDBDateTime(dateAdded);
    ar >> m_type;
    ar >> m_iIdSeason;
  }
}
Пример #20
0
// Reading a part of a formula, which may be spread
// between two files in case of an old style whf / whx formula.
void CFormula::ReadFormulaFile(CArchive& ar, bool ignoreFirstLine)
{
	CString		strOneLine = ""; 
	int			content = 0;
	char		funcname[256] = {0};
	int			start = 0, end = 0;
		
	SFunction	func;	
	SHandList	list;		

	CSLock lock(m_critsec);

	// Ignore first line (date/time)
	if (ignoreFirstLine)
		ar.ReadString(strOneLine);

	// read data in, one line at a time
	strOneLine = "";
	content = FTnone;
	func.func = "";
	while(ar.ReadString(strOneLine)) 
	{ 

		// If this line marks the beginning of a function, then save the previously
		// collected function, and start a new one
		if (strOneLine.Mid(0,2)=="##") 
		{

			// Save the previously collected function
			if (content == FTlist) 
			{
				// Strip the LFCR off the last line (we need to add CRLF for all but the last line)
				list.list_text.TrimRight("\r\n");
				_formula.mHandList.Add(list); 
			}
			else if (content == FTfunc) 
			{
				func.func_text.TrimRight("\r\n");
				_formula.mFunction.Add(func);
			}


			// Get the function name				
			start = strOneLine.Find("##",0);

			// No need to check the result of start,
			// as this code gets executed only,
			// if a line starts with "##"	
			end = strOneLine.Find("##", start+2);

			// Checking for malformed function header
			// without trailing "##"
			if (end == -1) 
			{
				// Trying to continue gracefully.				
				// Skipping is not possible,
				// as this crashes the formula editor.											
				strcpy_s(funcname, 256, strOneLine.GetString()+start+2);
				funcname[strOneLine.GetLength()]='\0';
				CString the_ErrorMessage = "Malformed function header!\nMissing trailing '##'.\n" 
					+ strOneLine + "\n"
					+ "Trying to continue...";
				MessageBox(0, the_ErrorMessage, "Syntax Error", 
					MB_OK | MB_ICONEXCLAMATION);
			}

			else 
			{
				strcpy_s(funcname, 256, strOneLine.GetString()+start+2);
				funcname[end-2]='\0';
			}

			if (strcmp(funcname, "bankroll") == 0) { _formula.dBankroll = 0.0; content = FTbankroll; }
			
			else if (strcmp(funcname, "defcon") == 0) { _formula.dDefcon = 0.0; content = FTdefcon; }
			
			else if (strcmp(funcname, "rake") == 0) { _formula.dRake = 0.0; content = FTrake; }
			
			else if (strcmp(funcname, "nit") == 0) { _formula.dNit = 0.0; content = FTnit; }
			
			else if (memcmp(funcname, "list", 4) == 0) 
			{ 
				content = FTlist;
				list.list = funcname;
				list.list_text = "";
			}

			else 
			{
				content = FTfunc;
				func.func = funcname;
				func.func_text = "";
				func.dirty = true;
			}
		}

		// Get the function content
		else 
		{
			switch (content) 
			{
				 case FTbankroll:
					 if (strOneLine.GetLength())
						 _formula.dBankroll = atof(strOneLine.GetString());
					 break;
				 case FTdefcon:
					 if (strOneLine.GetLength())
						 _formula.dDefcon = atof(strOneLine.GetString());
					 break;
				 case FTrake:
					 if (strOneLine.GetLength())
						 _formula.dRake = atof(strOneLine.GetString());
					 break;
				 case FTnit:
					 if (strOneLine.GetLength())
						 _formula.dNit = atof(strOneLine.GetString());
					 break;
				 case FTlist:
					 list.list_text.Append(strOneLine); list.list_text.Append("\r\n");
					 break;
				 case FTfunc:
					 func.func_text.Append(strOneLine); func.func_text.Append("\r\n");
					 break;
			}
		}	
	}  

	// Add the last list/function to the CArray on EOF, if it was a list being processed
	if (content == FTlist) 
	{
		list.list_text.TrimRight("\r\n");
		_formula.mHandList.Add(list); 
	}
	else if (content == FTfunc) 
	{
		func.func_text.TrimRight("\r\n");
		_formula.mFunction.Add(func);
	}
}
Пример #21
0
void CSecureRule::Serialize(CArchive& ar, int /*nVersion*/)
{
	if ( ar.IsStoring() )
	{
		ar << (int)m_nType;
		ar << m_nAction;
		ar << m_sComment;

		ar.Write( &m_pGUID, sizeof( GUID ) );

		ar << m_nExpire;
		ar << m_nEver;

		if ( m_nType == srAddress )
		{
			ar.Write( m_nIP, 4 );
			ar.Write( m_nMask, 4 );
		}
		else
		{
			ar << GetContentWords();
		}
	}
	else // Loading
	{
		int nType;
		ar >> nType;
		m_nType = (RuleType)nType;

		ar >> m_nAction;
		ar >> m_sComment;

		//if ( nVersion < 4 )
		//	CoCreateGuid( &m_pGUID );
		//else
			ReadArchive( ar, &m_pGUID, sizeof( GUID ) );

		ar >> m_nExpire;
		ar >> m_nEver;

		if ( m_nType == srAddress )
		{
			ReadArchive( ar, m_nIP, 4 );
			ReadArchive( ar, m_nMask, 4 );
			MaskFix();					// Make sure old rules are updated to new format (obsolete?)
		}
		else
		{
			//if ( nVersion < 5 )		// Map RuleType enum changes
			//{
			//	BYTE foo;
			//	ar >> foo;
			//	switch ( foo )
			//	{
			//	case 1:
			//		m_nType = srContentAll;
			//		break;
			//	case 2:
			//		m_nType = srContentRegExp;
			//		break;
			//	}
			//
			//	if ( nVersion < 3 )
			//	{
			//		for ( DWORD_PTR nCount = ar.ReadCount(); nCount > 0; nCount-- )
			//		{
			//			CString strWord;
			//			ar >> strWord;
			//			strTemp += L' ' + strWord;
			//		}
			//	}
			//}

			CString str;
			ar >> str;
			SetContentWords( str );
		}
	}
}
Пример #22
0
bool CLayout::Serialize(CArchive& ar)
{
	CString ExpectedName = "CLayout";
	int     Version      = 5;

	if (!SerializeClassHeader(ExpectedName, Version, ar))
		return false;

	g_pFrame = this;
	if(ar.IsLoading())
	{
		ar >> identifier >> m_w >> m_h >> m_Name >> m_clr >> m_unboundedScrolling >> application_background;
		
		m_ObjectFrameIsLockedTo = 0;
		m_oTemporyBehaviorInfo=0;	// used inbetwen creation of tempory Behaviors for modifying properties - I use it so if an edittime function is called, we can work out from what object it is if the identifier is -1
		m_pTempMovExt=0;	// used inbetwen creation of tempory Behaviors for modifying properties - I use it so if an edittime function is called, we can work out from what object it is if the identifier is -1
		m_oControlBehaviorInfo=0;	// If you tell a Behavior to be in control of the frame editor this is used
		m_pControlBehaviorExt=0;// If you tell a Behavior to be in control of the frame editor this is used
		m_pControlBehaviorData=0;	// If you tell a Behavior to be in control of the frame editor, this is used to serialize to once unlocked.
		m_pControlBehaviorDataSize=0;
		m_ParentObjectFrameIsLockedTo=0;

		objects.RemoveAll();
		long objCnt;

		ar >> objCnt;
		CObj *o;
		int i;
		for (i = 0; i < objCnt; i++) 
		{
			long nKey;
			ar >> nKey;
			o = new CObj();

			if (!o->Serialize(ar))
				return false;

			objects.SetAt(nKey, o);
		}

		ar >> objCnt;
		CLayer *layer;
		for (i = 0; i < objCnt; i++)
		{
			layer = new CLayer("", LAYER_NORMAL);

			if (!layer->Serialize(ar))
				return false;

			layers.AddTail(layer);
			if (i == 1)
				current_layer = layer;
		}

		if (Version < 4)
		{
			// add non-layout layer if one doesn't exist
			if (layers.GetHead()->m_layerType != LAYER_NONFRAME)
			{
				CString layer_name;
				layer_name.Format("Non-layout");
				CLayer* nonlayout_layer = new CLayer(layer_name, LAYER_NONFRAME);
				nonlayout_layer->m_state = LAYSTATE_HIDDEN;

				nonlayout_layer->m_layerID = application->m_layerID++;
				layers.AddHead(nonlayout_layer);
			}
		}

		ar >> temporary_event_sheet_id;

		// This changed in v2; make sure the function knows
		if (Version >= 2)
			layoutKeys.Serialize(ar, true);
		else
			layoutKeys.Serialize(ar, false);

		// V3: save grid details
		if (Version >= 3) {
			ar >> m_Grid >> m_SnapMovements >> m_SnapResize >> m_GridWidth >> m_GridHeight;
		}
Пример #23
0
void CMusicInfoTag::Archive(CArchive& ar)
{
  if (ar.IsStoring())
  {
    ar << m_strURL;
    ar << m_strTitle;
    ar << m_artist;
    ar << m_strArtistDesc;
    ar << m_strAlbum;
    ar << m_albumArtist;
    ar << m_strAlbumArtistDesc;
    ar << m_genre;
    ar << m_iDuration;
    ar << m_iTrack;
    ar << m_bLoaded;
    ar << m_dwReleaseDate;
    ar << m_strMusicBrainzTrackID;
    ar << m_musicBrainzArtistID;
    ar << m_strMusicBrainzAlbumID;
    ar << m_musicBrainzAlbumArtistID;
    ar << m_strMusicBrainzReleaseType;
    ar << m_lastPlayed;
    ar << m_dateAdded;
    ar << m_strComment;
    ar << (int)m_musicRoles.size();   
    for (VECMUSICROLES::const_iterator credit = m_musicRoles.begin(); credit != m_musicRoles.end(); ++credit)
    {
      ar << credit->GetRoleId();
      ar << credit->GetRoleDesc();
      ar << credit->GetArtist();
      ar << credit->GetArtistId();
    }
    ar << m_strMood;
    ar << m_strRecordLabel;
    ar << m_Rating;
    ar << m_Userrating;
    ar << m_Votes;
    ar << m_iTimesPlayed;
    ar << m_iAlbumId;
    ar << m_iDbId;
    ar << m_type;
    ar << m_strLyrics;
    ar << m_bCompilation;
    ar << m_listeners;
    ar << m_coverArt;
    ar << m_cuesheet;
    ar << static_cast<int>(m_albumReleaseType);
  }
  else
  {
    ar >> m_strURL;
    ar >> m_strTitle;
    ar >> m_artist;
    ar >> m_strArtistDesc;
    ar >> m_strAlbum;
    ar >> m_albumArtist;
    ar >> m_strAlbumArtistDesc;
    ar >> m_genre;
    ar >> m_iDuration;
    ar >> m_iTrack;
    ar >> m_bLoaded;
    ar >> m_dwReleaseDate;
    ar >> m_strMusicBrainzTrackID;
    ar >> m_musicBrainzArtistID;
    ar >> m_strMusicBrainzAlbumID;
    ar >> m_musicBrainzAlbumArtistID;
    ar >> m_strMusicBrainzReleaseType;
    ar >> m_lastPlayed;
    ar >> m_dateAdded;
    ar >> m_strComment;
    int iMusicRolesSize;
    ar >> iMusicRolesSize;
    m_musicRoles.reserve(iMusicRolesSize);
    for (int i = 0; i < iMusicRolesSize; ++i)
    {
      int idRole;
      long idArtist;
      std::string strArtist;
      std::string strRole;
      ar >> idRole;
      ar >> strRole;
      ar >> strArtist;
      ar >> idArtist;
      m_musicRoles.emplace_back(idRole, strRole, strArtist, idArtist);
    }
    ar >> m_strMood;
    ar >> m_strRecordLabel;
    ar >> m_Rating;
    ar >> m_Userrating;
    ar >> m_Votes;
    ar >> m_iTimesPlayed;
    ar >> m_iAlbumId;
    ar >> m_iDbId;
    ar >> m_type;
    ar >> m_strLyrics;
    ar >> m_bCompilation;
    ar >> m_listeners;
    ar >> m_coverArt;
    ar >> m_cuesheet;

    int albumReleaseType;
    ar >> albumReleaseType;
    m_albumReleaseType = static_cast<CAlbum::ReleaseType>(albumReleaseType);
  }
}
void CvoronoiDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: 在此添加存储代码
		if (img.IsNull())
		{
			AfxMessageBox(_T("No file to be saved!"));
		}
		else{
			
			CString strFilter;
			strFilter="位图文件|*.bmp|JPEG 图像文件|*.jpg|GIF 图像文件|*.gif|PNG 图像文件|*.png||"; 
			CFileDialog dlg(FALSE,NULL,NULL,NULL,strFilter);
			if (IDOK !=dlg.DoModal())
			 return;

			//如果保存时为指定扩展名,则添加一个
			CString strFileName;
			CString strExtension;

			strFileName=dlg.m_ofn.lpstrFile;
			if (dlg.m_ofn.nFileExtension!=0)
			{
				switch (dlg.m_ofn.nFilterIndex)
				{
				case 1:
					strExtension="BMP";
					break;
				case 2:
					strExtension="JPG";
					break;
				case 3:
					strExtension="GIF";
					break;
				case 4:
					strExtension="PNG";
					break;
				default:

					break;
				}
			strFileName =strFileName+_T(".")+strExtension;
			}
			//图像保存
			HRESULT hReslt=img.Save(strFileName);
			if (FAILED(hReslt))
			{
				AfxMessageBox(_T("Save File failed!Sorry~"));
			}
		}
	}
	else
	{
		// TODO: 在此添加加载代码
		if (!img.IsNull())
		{
			img.Destroy();
		}
		else
			img.Load(ar.GetFile()->GetFilePath());
	}
}
Пример #25
0
//*******************************************************************************
void CCmdUsageCount::Serialize (CArchive& ar)
{
	if (ar.IsLoading ())
	{
		ar >> m_nTotalUsage;
	}
Пример #26
0
///////////////////////////////////////////////////////////////////////
// Speichern / Laden
///////////////////////////////////////////////////////////////////////
void CSystemProd::Serialize(CArchive &ar)
{
	CObject::Serialize(ar);
	// wenn gespeichert wird
	if (ar.IsStoring())
	{
		ar << m_iFoodProd;
		ar << m_iMaxFoodProd;
		ar << m_iIndustryProd;
		ar << m_iPotentialIndustryProd;
		ar << m_iEnergyProd;
		ar << m_iMaxEnergyProd;
		ar << m_iPotentialEnergyProd;
		ar << m_iSecurityProd;
		ar << m_iResearchProd;
		ar << m_iTitanProd;
		ar << m_iDeuteriumProd;
		ar << m_iDuraniumProd;
		ar << m_iCrystalProd;
		ar << m_iIridiumProd;
		ar << m_iDeritiumProd;
		ar << m_iCreditsProd;
		ar << m_iMoralProd;
		ar << m_iBioTechBoni;
		ar << m_iEnergyTechBoni;
		ar << m_iCompTechBoni;
		ar << m_iPropulsionTechBoni;
		ar << m_iConstructionTechBoni;
		ar << m_iWeaponTechBoni;
		ar << m_iInnerSecurityBoni;
		ar << m_iEconomySpyBoni;
		ar << m_iEconomySabotageBoni;
		ar << m_iResearchSpyBoni;
		ar << m_iResearchSabotageBoni;
		ar << m_iMilitarySpyBoni;
		ar << m_iMilitarySabotageBoni;
		ar << m_bShipYard;
		ar << m_iBuildableShipSizes;
		ar << m_iShipYardEfficiency;
		ar << m_bBarrack;
		ar << m_iBarracksEfficiency;
		ar << m_iShieldPower;
		ar << m_iShieldPowerBoni;
		ar << m_iShipDefend;
		ar << m_iShipDefendBoni;
		ar << m_iGroundDefend;
		ar << m_iGroundDefendBoni;
		ar << m_iScanPower;
		ar << m_iScanPowerBoni;
		ar << m_iScanRange;
		ar << m_iScanRangeBoni;
		ar << m_iShipTraining;
		ar << m_iTroopTraining;
		ar << m_iResistance;
		ar << m_iAddedTradeRouts;
		ar << m_iIncomeOnTradeRoutes;
		ar << m_iShipRecycling;
		ar << m_iBuildingBuildSpeed;
		ar << m_iUpdateBuildSpeed;
		ar << m_iShipBuildSpeed;
		ar << m_iTroopBuildSpeed;
		for (int res = RESOURCES::TITAN; res <= RESOURCES::DERITIUM; res++)
			ar << m_bResourceDistributor[res];
	}
	// wenn geladen wird
	if (ar.IsLoading())
	{
		ar >> m_iFoodProd;
		ar >> m_iMaxFoodProd;
		ar >> m_iIndustryProd;
		ar >> m_iPotentialIndustryProd;
		ar >> m_iEnergyProd;
		ar >> m_iMaxEnergyProd;
		ar >> m_iPotentialEnergyProd;
		ar >> m_iSecurityProd;
		ar >> m_iResearchProd;
		ar >> m_iTitanProd;
		ar >> m_iDeuteriumProd;
		ar >> m_iDuraniumProd;
		ar >> m_iCrystalProd;
		ar >> m_iIridiumProd;
		ar >> m_iDeritiumProd;
		ar >> m_iCreditsProd;
		ar >> m_iMoralProd;
		ar >> m_iBioTechBoni;
		ar >> m_iEnergyTechBoni;
		ar >> m_iCompTechBoni;
		ar >> m_iPropulsionTechBoni;
		ar >> m_iConstructionTechBoni;
		ar >> m_iWeaponTechBoni;
		ar >> m_iInnerSecurityBoni;
		ar >> m_iEconomySpyBoni;
		ar >> m_iEconomySabotageBoni;
		ar >> m_iResearchSpyBoni;
		ar >> m_iResearchSabotageBoni;
		ar >> m_iMilitarySpyBoni;
		ar >> m_iMilitarySabotageBoni;
		ar >> m_bShipYard;
		int nBuildableShipSize;
		ar >> nBuildableShipSize;
		m_iBuildableShipSizes = (SHIP_SIZE::Typ)nBuildableShipSize;
		ar >> m_iShipYardEfficiency;
		ar >> m_bBarrack;
		ar >> m_iBarracksEfficiency;
		ar >> m_iShieldPower;
		ar >> m_iShieldPowerBoni;
		ar >> m_iShipDefend;
		ar >> m_iShipDefendBoni;
		ar >> m_iGroundDefend;
		ar >> m_iGroundDefendBoni;
		ar >> m_iScanPower;
		ar >> m_iScanPowerBoni;
		ar >> m_iScanRange;
		ar >> m_iScanRangeBoni;
		ar >> m_iShipTraining;
		ar >> m_iTroopTraining;
		ar >> m_iResistance;
		ar >> m_iAddedTradeRouts;
		ar >> m_iIncomeOnTradeRoutes;
		ar >> m_iShipRecycling;
		ar >> m_iBuildingBuildSpeed;
		ar >> m_iUpdateBuildSpeed;
		ar >> m_iShipBuildSpeed;
		ar >> m_iTroopBuildSpeed;
		for (int res = RESOURCES::TITAN; res <= RESOURCES::DERITIUM; res++)
			ar >> m_bResourceDistributor[res];
	}
Пример #27
0
void CVideoInfoTag::Archive(CArchive& ar)
{
  if (ar.IsStoring())
  {
    ar << m_director;
    ar << m_writingCredits;
    ar << m_genre;
    ar << m_country;
    ar << m_strTagLine;
    ar << m_strPlotOutline;
    ar << m_strPlot;
    ar << m_strPictureURL.m_spoof;
    ar << m_strPictureURL.m_xml;
    ar << m_fanart.m_xml;
    ar << m_strTitle;
    ar << m_strSortTitle;
    ar << m_studio;
    ar << m_strTrailer;
    ar << (int)m_cast.size();
    for (unsigned int i=0;i<m_cast.size();++i)
    {
      ar << m_cast[i].strName;
      ar << m_cast[i].strRole;
      ar << m_cast[i].order;
      ar << m_cast[i].thumb;
      ar << m_cast[i].thumbUrl.m_xml;
    }

    ar << m_strSet;
    ar << m_iSetId;
    ar << m_strSetOverview;
    ar << m_tags;
    ar << m_duration;
    ar << m_strFile;
    ar << m_strPath;
    ar << m_strMPAARating;
    ar << m_strFileNameAndPath;
    ar << m_strOriginalTitle;
    ar << m_strEpisodeGuide;
    ar << m_premiered;
    ar << m_bHasPremiered;
    ar << m_strStatus;
    ar << m_strProductionCode;
    ar << m_firstAired;
    ar << m_strShowTitle;
    ar << m_strAlbum;
    ar << m_artist;
    ar << m_playCount;
    ar << m_lastPlayed;
    ar << m_iTop250;
    ar << m_iSeason;
    ar << m_iEpisode;
    ar << (int)m_uniqueIDs.size();
    for (const auto& i : m_uniqueIDs)
    {
      ar << i.first;
      ar << (i.first == m_strDefaultUniqueID);
      ar << i.second;
    }
    ar << (int)m_ratings.size();
    for (const auto& i : m_ratings)
    {
      ar << i.first;
      ar << (i.first == m_strDefaultRating);
      ar << i.second.rating;
      ar << i.second.votes;
    }
    ar << m_iUserRating;
    ar << m_iDbId;
    ar << m_iFileId;
    ar << m_iSpecialSortSeason;
    ar << m_iSpecialSortEpisode;
    ar << m_iBookmarkId;
    ar << m_iTrack;
    ar << dynamic_cast<IArchivable&>(m_streamDetails);
    ar << m_showLink;
    ar << static_cast<int>(m_namedSeasons.size());
    for (const auto& namedSeason : m_namedSeasons)
    {
      ar << namedSeason.first;
      ar << namedSeason.second;
    }
    ar << m_EpBookmark.playerState;
    ar << m_EpBookmark.timeInSeconds;
    ar << m_basePath;
    ar << m_parentPathID;
    ar << m_resumePoint.timeInSeconds;
    ar << m_resumePoint.totalTimeInSeconds;
    ar << m_iIdShow;
    ar << m_dateAdded.GetAsDBDateTime();
    ar << m_type;
    ar << m_iIdSeason;
  }
  else
  {
    ar >> m_director;
    ar >> m_writingCredits;
    ar >> m_genre;
    ar >> m_country;
    ar >> m_strTagLine;
    ar >> m_strPlotOutline;
    ar >> m_strPlot;
    ar >> m_strPictureURL.m_spoof;
    ar >> m_strPictureURL.m_xml;
    ar >> m_fanart.m_xml;
    ar >> m_strTitle;
    ar >> m_strSortTitle;
    ar >> m_studio;
    ar >> m_strTrailer;
    int iCastSize;
    ar >> iCastSize;
    m_cast.reserve(iCastSize);
    for (int i=0;i<iCastSize;++i)
    {
      SActorInfo info;
      ar >> info.strName;
      ar >> info.strRole;
      ar >> info.order;
      ar >> info.thumb;
      std::string strXml;
      ar >> strXml;
      info.thumbUrl.ParseString(strXml);
      m_cast.push_back(info);
    }

    ar >> m_strSet;
    ar >> m_iSetId;
    ar >> m_strSetOverview;
    ar >> m_tags;
    ar >> m_duration;
    ar >> m_strFile;
    ar >> m_strPath;
    ar >> m_strMPAARating;
    ar >> m_strFileNameAndPath;
    ar >> m_strOriginalTitle;
    ar >> m_strEpisodeGuide;
    ar >> m_premiered;
    ar >> m_bHasPremiered;
    ar >> m_strStatus;
    ar >> m_strProductionCode;
    ar >> m_firstAired;
    ar >> m_strShowTitle;
    ar >> m_strAlbum;
    ar >> m_artist;
    ar >> m_playCount;
    ar >> m_lastPlayed;
    ar >> m_iTop250;
    ar >> m_iSeason;
    ar >> m_iEpisode;
    int iUniqueIDSize;
    ar >> iUniqueIDSize;
    for (int i = 0; i < iUniqueIDSize; ++i)
    {
      std::string value;
      std::string name;
      bool defaultUniqueID;
      ar >> name;
      ar >> defaultUniqueID;
      ar >> value;
      SetUniqueID(value, name);
      if (defaultUniqueID)
        m_strDefaultUniqueID = name;
    }
    int iRatingSize;
    ar >> iRatingSize;
    for (int i = 0; i < iRatingSize; ++i)
    {
      CRating rating;
      std::string name;
      bool defaultRating;
      ar >> name;
      ar >> defaultRating;
      ar >> rating.rating;
      ar >> rating.votes;
      SetRating(rating, name);
      if (defaultRating)
        m_strDefaultRating = name;
    }
    ar >> m_iUserRating;
    ar >> m_iDbId;
    ar >> m_iFileId;
    ar >> m_iSpecialSortSeason;
    ar >> m_iSpecialSortEpisode;
    ar >> m_iBookmarkId;
    ar >> m_iTrack;
    ar >> dynamic_cast<IArchivable&>(m_streamDetails);
    ar >> m_showLink;

    int namedSeasonSize;
    ar >> namedSeasonSize;
    for (int i = 0; i < namedSeasonSize; ++i)
    {
      int seasonNumber;
      ar >> seasonNumber;
      std::string seasonName;
      ar >> seasonName;
      m_namedSeasons.insert(std::make_pair(seasonNumber, seasonName));
    }
    ar >> m_EpBookmark.playerState;
    ar >> m_EpBookmark.timeInSeconds;
    ar >> m_basePath;
    ar >> m_parentPathID;
    ar >> m_resumePoint.timeInSeconds;
    ar >> m_resumePoint.totalTimeInSeconds;
    ar >> m_iIdShow;

    std::string dateAdded;
    ar >> dateAdded;
    m_dateAdded.SetFromDBDateTime(dateAdded);
    ar >> m_type;
    ar >> m_iIdSeason;
  }
}
Пример #28
0
void NNLayer::Serialize(CArchive &ar)
{
	VectorNeurons::iterator nit;
	VectorWeights::iterator wit;
	VectorConnections::iterator cit;
	
	int ii, jj;
	
	if (ar.IsStoring())
	{
		// TODO: add storing code here
		
		ar.WriteString( label.c_str() );
		ar.WriteString( _T("\r\n") );  // ar.ReadString will look for \r\n when loading from the archive
		ar << m_Neurons.size();
		ar << m_Weights.size();
		
		
		
		for ( nit=m_Neurons.begin(); nit<m_Neurons.end(); nit++ )
		{
			NNNeuron& n = *(*nit);
			ar.WriteString( n.label.c_str() );
			ar.WriteString( _T("\r\n") );
			ar << n.m_Connections.size();
			
			for ( cit=n.m_Connections.begin(); cit<n.m_Connections.end(); cit++ )
			{
				ar << (*cit).NeuronIndex;
				ar << (*cit).WeightIndex;
			}
		}
		
		for ( wit=m_Weights.begin(); wit<m_Weights.end(); wit++ )
		{
			ar.WriteString( (*wit)->label.c_str() );
			ar.WriteString( _T("\r\n") );
			ar << (*wit)->value;
		}
		
		
	}
	else
	{
		// TODO: add loading code here
		
		CString str;
		ar.ReadString( str );
		
		label = str;
		
		int iNumNeurons, iNumWeights, iNumConnections;
		double value;
		
		NNNeuron* pNeuron;
		NNWeight* pWeight;
		NNConnection conn;
		
		ar >> iNumNeurons;
		ar >> iNumWeights;
		
		for ( ii=0; ii<iNumNeurons; ++ii )
		{
			ar.ReadString( str );
			pNeuron = new NNNeuron( (LPCTSTR)str );
			m_Neurons.push_back( pNeuron );
			
			ar >> iNumConnections;
			
			for ( jj=0; jj<iNumConnections; ++jj )
			{
				ar >> conn.NeuronIndex;
				ar >> conn.WeightIndex;
				
				pNeuron->AddConnection( conn );
			}
		}
		
		for ( jj=0; jj<iNumWeights; ++jj )
		{
			ar.ReadString( str );
			ar >> value;
			
			pWeight = new NNWeight( (LPCTSTR)str, value );
			m_Weights.push_back( pWeight );
		}
		
	}
	
}
Пример #29
0
void CStream_WriteObject(CArchive& self, CSerializable::Ptr& obj)
{
	self.WriteObject(obj.get());
}
Пример #30
0
	void CHandler::deserialize(CArchive &archive) {
		conditions = archive.readCObArray();
		side_effects = archive.readCObArray();
	}