本文整理汇总了C++中CString::ReadFromStream方法的典型用法代码示例。如果您正苦于以下问题:C++ CString::ReadFromStream方法的具体用法?C++ CString::ReadFromStream怎么用?C++ CString::ReadFromStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::ReadFromStream方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadDynamicTypes
void CDesignCollection::ReadDynamicTypes (SUniverseLoadCtx &Ctx)
// ReadDynamicTypes
{
int i;
m_DynamicTypes.ReadFromStream(Ctx);
// Read dynamic UNIDs
m_DynamicUNIDs.DeleteAll();
DWORD dwCount;
Ctx.pStream->Read((char *)&dwCount, sizeof(DWORD));
for (i = 0; i < (int)dwCount; i++)
{
CString sName;
sName.ReadFromStream(Ctx.pStream);
DWORD dwAtom;
m_DynamicUNIDs.atom_Insert(sName, &dwAtom);
ASSERT(dwAtom == (DWORD)i);
}
}
示例2: OnReadFromStream
void CTextPainter::OnReadFromStream (SLoadCtx &Ctx)
// OnReadFromStream
//
// Reads from a stream
//
// CString m_sText
{
m_sText.ReadFromStream(Ctx.pStream);
MeasureText();
}
示例3: ValidateClass
ALERROR IEffectPainter::ValidateClass (SLoadCtx &Ctx, const CString &sOriginalClass)
// ValidateClass
//
// Reads the class string. If the class does not match the current painter,
// we read the old data and return ERR_FAIL.
{
if (Ctx.dwVersion >= 40)
{
CString sClass;
sClass.ReadFromStream(Ctx.pStream);
// If the original class doesn't match the current one, then it means
// that the design changed. In that case, we load the painter using the
// old class.
if (!strEquals(sClass, sOriginalClass))
{
// If sClass is blank, then it means that the original did not have
// an effect painter (but the current design does)
if (!sClass.IsBlank())
{
// Get the original creator
CEffectCreator *pOriginalCreator;
if (CEffectCreator::CreateFromTag(sClass, &pOriginalCreator) != NOERROR)
{
kernelDebugLogMessage("Unable to find original effect creator: %s", sClass.GetASCIIZPointer());
return ERR_FAIL;
}
// Load the original painter
IEffectPainter *pOriginalPainter = pOriginalCreator->CreatePainter();
pOriginalPainter->ReadFromStream(Ctx);
// Discard
pOriginalPainter->Delete();
delete pOriginalCreator;
}
// Done
return ERR_FAIL;
}
}
return NOERROR;
}
示例4: OnReadFromStream
void CBeam::OnReadFromStream (SLoadCtx &Ctx)
// OnReadFromStream
//
// Read object data from a stream
//
// CString CWeaponFireDesc UNID
// DWORD m_iBonus
// DWORD m_iCause
// DWORD m_iRotation
// Vector m_vPaintTo
// DWORD m_iTick
// DWORD m_iLifeLeft
// DWORD m_Source (CSpaceObject Ref)
// DWORD m_pSovereign (UNID)
// DWORD m_pHit (CSpaceObject Ref)
// DWORD m_iHitDir
{
DWORD dwLoad;
#ifdef DEBUG_LOAD
::OutputDebugString("CBeam::OnReadFromStream\n");
#endif
// Load descriptor
CString sDescUNID;
sDescUNID.ReadFromStream(Ctx.pStream);
m_pDesc = g_pUniverse->FindWeaponFireDesc(sDescUNID);
Ctx.pStream->Read((char *)&m_iBonus, sizeof(DWORD));
if (Ctx.dwVersion >= 18)
{
Ctx.pStream->Read((char *)&dwLoad, sizeof(DWORD));
m_iCause = (DestructionTypes)dwLoad;
}
else
m_iCause = killedByDamage;
Ctx.pStream->Read((char *)&m_iRotation, sizeof(DWORD));
Ctx.pStream->Read((char *)&m_vPaintTo, sizeof(CVector));
Ctx.pStream->Read((char *)&m_iTick, sizeof(DWORD));
Ctx.pStream->Read((char *)&m_iLifeLeft, sizeof(m_iLifeLeft));
m_Source.ReadFromStream(Ctx);
CSystem::ReadSovereignRefFromStream(Ctx, &m_pSovereign);
CSystem::ReadObjRefFromStream(Ctx, &m_pHit);
Ctx.pStream->Read((char *)&m_iHitDir, sizeof(DWORD));
ComputeOffsets();
}
示例5: ReadUNID
CString IEffectPainter::ReadUNID (SLoadCtx &Ctx)
// ReadUNID
//
// Returns the UNID saved to a stream
{
CString sUNID;
if (Ctx.dwVersion >= 15)
sUNID.ReadFromStream(Ctx.pStream);
else
{
DWORD dwUNID;
Ctx.pStream->Read((char *)&dwUNID, sizeof(DWORD));
sUNID = strFromInt(dwUNID, FALSE);
}
return sUNID;
}
示例6: ReadDynamicTypes
void CDesignCollection::ReadDynamicTypes (SUniverseLoadCtx &Ctx)
// ReadDynamicTypes
{
int i;
// We need to unbind because there may be some dynamic types from a previous
// game that we're about to delete.
//
// This HACK is caused by the fact that Universe::Init is also calling
// BindDesign but ReadDynamicTypes must be called before Init.
//
// A better way to fix this is to load the dynamic types into a separate
// structure and pass them into Init to be added then.
for (i = 0; i < m_AllTypes.GetCount(); i++)
m_AllTypes.GetEntry(i)->UnbindDesign();
m_AllTypes.DeleteAll();
// Read them
m_DynamicTypes.ReadFromStream(Ctx);
// Read dynamic UNIDs
m_DynamicUNIDs.DeleteAll();
DWORD dwCount;
Ctx.pStream->Read((char *)&dwCount, sizeof(DWORD));
for (i = 0; i < (int)dwCount; i++)
{
CString sName;
sName.ReadFromStream(Ctx.pStream);
DWORD dwAtom;
m_DynamicUNIDs.atom_Insert(sName, &dwAtom);
ASSERT(dwAtom == (DWORD)i);
}
}
示例7: OnReadFromStream
void IEffectPainter::OnReadFromStream (SLoadCtx &Ctx)
// OnReadFromStream
//
// This is the default for reading painter parameters. We ask the painter for
// a list of its parameters and read those.
{
int i;
// Read parameters
if (Ctx.dwVersion >= 90)
{
// Read the number of parameters
DWORD dwCount;
Ctx.pStream->Read((char *)&dwCount, sizeof(DWORD));
for (i = 0; i < (int)dwCount; i++)
{
// Read the parameter name
CString sParam;
sParam.ReadFromStream(Ctx.pStream);
// Read the value
CEffectParamDesc Value;
Value.ReadFromStream(Ctx);
// Set it
SetParam(CCreatePainterCtx(), sParam, Value);
}
}
}
示例8: ReadFromStream
void CCurrencyBlock::ReadFromStream (SLoadCtx &Ctx)
// ReadFromStream
//
// DWORD Count of currencies
// DWORD CEconomyType UNID
// LONGLONG value
{
int i;
DWORD dwCount;
Ctx.pStream->Read((char *)&dwCount, sizeof(DWORD));
for (i = 0; i < (int)dwCount; i++)
{
DWORD dwUNID;
if (Ctx.dwVersion >= 62)
{
Ctx.pStream->Read((char *)&dwUNID, sizeof(DWORD));
}
else
{
CString sCurrency;
sCurrency.ReadFromStream(Ctx.pStream);
// Previous to 62 we never stored any currency
// other than credits
dwUNID = DEFAULT_ECONOMY_UNID;
}
SEntry *pEntry = m_Block.Insert(dwUNID);
Ctx.pStream->Read((char *)&pEntry->iValue, sizeof(CurrencyValue));
}
}
示例9: CreateFromStream
void CTopologyNode::CreateFromStream (SUniverseLoadCtx &Ctx, CTopologyNode **retpNode)
// CreateFromStream
//
// Creates a node from a stream
//
// CString m_sID
// DWORD m_SystemUNID
// DWORD m_pMap (UNID)
// DWORD m_xPos
// DWORD m_yPos
// CString m_sName
// CString m_sAttributes
// DWORD m_iLevel
// DWORD m_dwID
//
// DWORD No of named gates
// CString gate: sName
// CString gate: sDestNode
// CString gate: sDestEntryPoint
//
// DWORD No of variant labels
// CString variant label
//
// CAttributeDataBlock m_Data
// DWORD flags
//
// CString m_sEpitaph
// CString m_sEndGameReason
{
int i;
DWORD dwLoad;
CTopologyNode *pNode;
CString sID;
sID.ReadFromStream(Ctx.pStream);
DWORD dwSystemUNID;
Ctx.pStream->Read((char *)&dwSystemUNID, sizeof(DWORD));
CSystemMap *pMap;
if (Ctx.dwVersion >= 6)
{
DWORD dwMapUNID;
Ctx.pStream->Read((char *)&dwMapUNID, sizeof(DWORD));
pMap = CSystemMap::AsType(g_pUniverse->FindDesignType(dwMapUNID));
}
else
pMap = NULL;
pNode = new CTopologyNode(sID, dwSystemUNID, pMap);
if (Ctx.dwVersion >= 6)
{
Ctx.pStream->Read((char *)&pNode->m_xPos, sizeof(DWORD));
Ctx.pStream->Read((char *)&pNode->m_yPos, sizeof(DWORD));
}
pNode->m_sName.ReadFromStream(Ctx.pStream);
if (Ctx.dwVersion >= 23)
pNode->m_sAttributes.ReadFromStream(Ctx.pStream);
Ctx.pStream->Read((char *)&pNode->m_iLevel, sizeof(DWORD));
Ctx.pStream->Read((char *)&pNode->m_dwID, sizeof(DWORD));
DWORD dwCount;
Ctx.pStream->Read((char *)&dwCount, sizeof(DWORD));
for (i = 0; i < (int)dwCount; i++)
{
StarGateDesc *pDesc = new StarGateDesc;
CString sName;
sName.ReadFromStream(Ctx.pStream);
pDesc->sDestNode.ReadFromStream(Ctx.pStream);
pDesc->sDestEntryPoint.ReadFromStream(Ctx.pStream);
pDesc->pDestNode = NULL;
pNode->m_NamedGates.AddEntry(sName, (CObject *)pDesc);
}
Ctx.pStream->Read((char *)&dwCount, sizeof(DWORD));
for (i = 0; i < (int)dwCount; i++)
{
CString sLabel;
sLabel.ReadFromStream(Ctx.pStream);
pNode->m_VariantLabels.Insert(sLabel);
}
if (Ctx.dwVersion >= 1)
pNode->m_Data.ReadFromStream(Ctx.pStream);
// Flags
if (Ctx.dwVersion >= 6)
Ctx.pStream->Read((char *)&dwLoad, sizeof(DWORD));
else
dwLoad = 0;
pNode->m_bKnown = (dwLoad & 0x00000001 ? true : false);
pNode->m_bMarked = false;
//.........这里部分代码省略.........
示例10: sizeof
IEffectPainter *CEffectCreator::CreatePainterFromStream (SLoadCtx &Ctx, bool bNullCreator)
// CreatePainterFromStream
//
// Load a painter from a stream
{
CEffectCreator *pCreator;
// For previous versions, we only stored UNID if we had a creator
if (Ctx.dwVersion < 43 && bNullCreator)
return NULL;
// At version 15 we started saving versions as string UNIDs. We need to do this
// because sometimes the effect creator is inside a weapon fire desc
// structure (also identified by string UNIDs).
if (Ctx.dwVersion >= 15)
{
CString sUNID;
sUNID.ReadFromStream(Ctx.pStream);
pCreator = (sUNID.IsBlank() ? NULL : CEffectCreator::FindEffectCreator(sUNID));
// Load the creator class that saved the painter
if (IEffectPainter::ValidateClass(Ctx, (pCreator ? pCreator->GetTag() : NULL_STR)) != NOERROR)
return NULL;
// Error
if (pCreator == NULL)
{
if (!sUNID.IsBlank())
kernelDebugLogMessage("Invalid painter creator: %s", sUNID.GetASCIIZPointer());
return NULL;
}
}
// Old style uses DWORD UNIDs
else
{
// The first DWORD is the UNID of the creator
DWORD dwUNID;
Ctx.pStream->Read((char *)&dwUNID, sizeof(DWORD));
if (dwUNID == 0)
return NULL;
pCreator = g_pUniverse->FindEffectType(dwUNID);
// Error
if (pCreator == NULL)
{
kernelDebugLogMessage("Invalid painter creator: %x", dwUNID);
return NULL;
}
}
// Let the creator create the object
IEffectPainter *pPainter = pCreator->CreatePainter();
// Load it
pPainter->ReadFromStream(Ctx);
// Done
return pPainter;
}
示例11: OnReadFromStream
void CMissile::OnReadFromStream (SLoadCtx &Ctx)
// OnReadFromStream
//
// Read object data from a stream
//
// CString CWeaponFireDesc UNID
// DWORD m_iBonus
// DWORD m_iCause
// DWORD m_iHitPoints
// DWORD m_iLifeLeft
// DWORD m_Source (CSpaceObject ref)
// DWORD m_pSovereign (CSovereign ref)
// DWORD m_pHit (CSpaceObject ref)
// Vector m_vHitPos
// DWORD m_iHitDir
// DWORD m_iRotation
// DWORD m_pTarget (CSpaceObject ref)
// DWORD m_iTick
//
// IEffectPainter m_pPainter
//
// DWORD Number of exhaust particles
// Vector exhaust: vPos
// Vector exhaust: vVel
//
// -- version > 0 -----------------------
// DWORD flags
// DWORD Number of saved rotations
// DWORD rotation[]
{
DWORD dwLoad;
#ifdef DEBUG_LOAD
::OutputDebugString("CMissile::OnReadFromStream\n");
#endif
// Load descriptor
CString sDescUNID;
sDescUNID.ReadFromStream(Ctx.pStream);
m_pDesc = g_pUniverse->FindWeaponFireDesc(sDescUNID);
// Load other stuff
Ctx.pStream->Read((char *)&m_iBonus, sizeof(m_iBonus));
if (Ctx.dwVersion >= 18)
{
Ctx.pStream->Read((char *)&dwLoad, sizeof(DWORD));
m_iCause = (DestructionTypes)dwLoad;
}
else
m_iCause = killedByDamage;
if (Ctx.dwVersion >= 28)
Ctx.pStream->Read((char *)&m_iHitPoints, sizeof(DWORD));
else
m_iHitPoints = 0;
Ctx.pStream->Read((char *)&m_iLifeLeft, sizeof(DWORD));
m_Source.ReadFromStream(Ctx);
Ctx.pSystem->ReadSovereignRefFromStream(Ctx, &m_pSovereign);
Ctx.pSystem->ReadObjRefFromStream(Ctx, &m_pHit);
Ctx.pStream->Read((char *)&m_vHitPos, sizeof(CVector));
Ctx.pStream->Read((char *)&m_iHitDir, sizeof(DWORD));
Ctx.pStream->Read((char *)&m_iRotation, sizeof(DWORD));
Ctx.pSystem->ReadObjRefFromStream(Ctx, &m_pTarget);
Ctx.pStream->Read((char *)&m_iTick, sizeof(DWORD));
// Load painter
m_pPainter = CEffectCreator::CreatePainterFromStream(Ctx, (m_pDesc->GetEffect() == NULL));
// Load exhaust
if (m_pDesc->m_iExhaustRate > 0)
{
int iCount = (m_pDesc->m_iExhaustLifetime / m_pDesc->m_iExhaustRate) + 1;
m_pExhaust = new TQueue<SExhaustParticle>(iCount);
}
Ctx.pStream->Read((char *)&dwLoad, sizeof(DWORD));
for (int i = 0; i < (int)dwLoad; i++)
{
CVector vPos;
CVector vVel;
Ctx.pStream->Read((char *)&vPos, sizeof(CVector));
Ctx.pStream->Read((char *)&vVel, sizeof(CVector));
if (m_pExhaust && i < m_pExhaust->GetMaxCount())
{
SExhaustParticle &Particle = m_pExhaust->GetAt(m_pExhaust->Queue());
Particle.vPos = vPos;
Particle.vVel = vVel;
}
}
// Load saved rotations
if (Ctx.dwVersion >= 1)
//.........这里部分代码省略.........
示例12: Open
ALERROR CResourceDb::Open (DWORD dwFlags)
// Open
//
// Initializes database
{
ALERROR error;
// Load the resource map, if necessary
if (m_pDb)
{
ASSERT(m_pResourceMap == NULL);
if ((error = m_pDb->Open(dwFlags)))
return error;
CString sData;
if ((error = m_pDb->ReadEntry(m_pDb->GetDefaultEntry(), &sData)))
return error;
CMemoryReadStream Stream(sData.GetASCIIZPointer(), sData.GetLength());
if ((error = Stream.Open()))
return error;
// Check the signature
DWORD dwLoad;
Stream.Read((char *)&dwLoad, sizeof(DWORD));
if (dwLoad != TDB_SIGNATURE)
return ERR_FAIL;
// Check the version
Stream.Read((char *)&dwLoad, sizeof(DWORD));
if (dwLoad > TDB_VERSION)
return ERR_FAIL;
m_iVersion = (int)dwLoad;
// Read the game file
Stream.Read((char *)&m_iGameFile, sizeof(DWORD));
// Read the game title
CString sLoad;
sLoad.ReadFromStream(&Stream);
// Read the flattened symbol table
sLoad.ReadFromStream(&Stream);
// Unflatten the symbol table
if ((error = CObject::Unflatten(sLoad, (CObject **)&m_pResourceMap)))
return error;
}
return NOERROR;
}
示例13: ReadFromStream
void CPlayerGameStats::ReadFromStream (SLoadCtx &Ctx)
// ReadFromStream
//
// Read from stream
//
// DWORD m_iScore
// DWORD m_iExtraSystemsVisited
// DWORD m_iExtraEnemyShipsDestroyed
// CTimeSpan m_PlayTime
// CTimeSpan m_GameTime
//
// DWORD Count of item types
// DWORD UNID
// DWORD iCountSold
// LONGLONG iValueSold
// DWORD iCountBought
// LONGLONG iValueBought
// DWORD iCountInstalled
// DWORD dwFirstInstalled
// DWORD dwLastInstalled
// DWORD dwLastUninstalled
// DWORD dwTotalInstalledTime
// DWORD iCountFired
//
// DWORD Count of ship classes
// DWORD UNID
// DWORD iEnemyDestroyed
// DWORD iFriendDestroyed
//
// DWORD Count of station types
// DWORD UNID
// DWORD iDestroyed
//
// DWORD Count of systems
// CString NodeID
// DWORD dwFirstEntered
// DWORD dwLastEntered
// DWORD dwLastLeft
// DWORD dwTotalTime
//
// DWORD Count of systems
// CString NodeID
// DWORD count of key events
// DWORD iType
// DWORD dwTime
// DWORD dwObjUNID
// DWORD dwCauseUNID
// DWORD dwObjNameFlags
// CString sObjName
{
int i, j;
DWORD dwLoad, dwCount;
// Prior to version 49 we only saved:
//
// DWORD m_iScore
// DWORD m_iSystemsVisited
// DWORD m_iEnemiesDestroyed
// DWORD m_pBestEnemyDestroyed (UNID)
// DWORD m_iBestEnemyDestroyedCount
if (Ctx.dwVersion < 49)
{
Ctx.pStream->Read((char *)&m_iScore, sizeof(DWORD));
Ctx.pStream->Read((char *)&m_iExtraSystemsVisited, sizeof(DWORD));
Ctx.pStream->Read((char *)&m_iExtraEnemyShipsDestroyed, sizeof(DWORD));
// Load the ship class and count of the best enemy
Ctx.pStream->Read((char *)&dwLoad, sizeof(DWORD));
Ctx.pStream->Read((char *)&dwCount, sizeof(DWORD));
if (dwLoad)
{
SShipClassStats *pShipStats = GetShipStats(dwLoad);
pShipStats->iEnemyDestroyed += dwCount;
// We subtract from extra ships (because these ships are already
// included there)
m_iExtraEnemyShipsDestroyed -= dwCount;
ASSERT(m_iExtraEnemyShipsDestroyed >= 0);
}
return;
}
// New version
Ctx.pStream->Read((char *)&m_iScore, sizeof(DWORD));
Ctx.pStream->Read((char *)&m_iExtraSystemsVisited, sizeof(DWORD));
Ctx.pStream->Read((char *)&m_iExtraEnemyShipsDestroyed, sizeof(DWORD));
if (Ctx.dwVersion >= 53)
{
Ctx.pStream->Read((char *)&m_PlayTime, sizeof(CTimeSpan));
Ctx.pStream->Read((char *)&m_GameTime, sizeof(CTimeSpan));
}
//.........这里部分代码省略.........
示例14: ReadFromStream
void COrderList::ReadFromStream (SLoadCtx &Ctx)
// ReadFromStream
//
// Read
{
int i;
DWORD dwLoad;
DWORD dwCount;
Ctx.pStream->Read((char *)&dwCount, sizeof(DWORD));
m_List.InsertEmpty(dwCount);
// Read new version
if (Ctx.dwVersion >= 87)
{
for (i = 0; i < (int)dwCount; i++)
{
SOrderEntry *pEntry = &m_List[i];
Ctx.pStream->Read((char *)&dwLoad, sizeof(DWORD));
pEntry->dwOrderType = LOWORD(dwLoad);
pEntry->dwDataType = HIWORD(dwLoad);
CSystem::ReadObjRefFromStream(Ctx, &pEntry->pTarget);
switch (pEntry->dwDataType)
{
case IShipController::dataInteger:
case IShipController::dataPair:
Ctx.pStream->Read((char *)&pEntry->dwData, sizeof(DWORD));
break;
case IShipController::dataString:
{
CString *pString = new CString;
pString->ReadFromStream(Ctx.pStream);
pEntry->dwData = (DWORD)pString;
break;
}
case IShipController::dataVector:
{
CVector *pVector = new CVector;
Ctx.pStream->Read((char *)pVector, sizeof(CVector));
pEntry->dwData = (DWORD)pVector;
break;
}
}
}
}
// Backwards compatible
else
{
for (i = 0; i < (int)dwCount; i++)
{
SOrderEntry *pEntry = &m_List[i];
Ctx.pStream->Read((char *)&dwLoad, sizeof(DWORD));
pEntry->dwOrderType = dwLoad;
pEntry->dwDataType = IShipController::dataInteger;
CSystem::ReadObjRefFromStream(Ctx, &pEntry->pTarget);
Ctx.pStream->Read((char *)&pEntry->dwData, sizeof(DWORD));
}
}
}