本文整理汇总了C++中CArchive类的典型用法代码示例。如果您正苦于以下问题:C++ CArchive类的具体用法?C++ CArchive怎么用?C++ CArchive使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CArchive类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Serialize
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: ASSERT_VALID
//****************************************************************************************
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: CStream_ReadObject
// CStream
void CStream_ReadObject(CArchive& self, CSerializable::Ptr& obj)
{
self.ReadObject(obj.get());
}
示例4: Input
/*******************************************************************************
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: Archive
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;
//.........这里部分代码省略.........
示例6: Serialize
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: Input
/*******************************************************************************
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: PreloadPBNFile
//
// 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)
//.........这里部分代码省略.........
示例9: ReadFilePLL
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: Serialize
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)
//.........这里部分代码省略.........
示例11: Serialize
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: StoreForPrinting
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;
}
示例13: Serialize
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;
//.........这里部分代码省略.........
示例14: WriteGWorldToVRML
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");
}
}
示例15: Archive
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);
}
}