本文整理汇总了C++中nlmisc::IStream::getPos方法的典型用法代码示例。如果您正苦于以下问题:C++ IStream::getPos方法的具体用法?C++ IStream::getPos怎么用?C++ IStream::getPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nlmisc::IStream
的用法示例。
在下文中一共展示了IStream::getPos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: streamToDataBase
// ***************************************************************************
void CInterfaceConfig::streamToDataBase (NLMISC::IStream &f, uint32 uiDbSaveVersion)
{
if (!f.isReading())
{
nlwarning("stream is not in reading mode");
return;
}
sint32 begPos = f.getPos();
f.seek (0, NLMISC::IStream::end);
sint32 endPos = f.getPos();
if ((begPos - endPos) == 0) return;
f.seek (begPos, NLMISC::IStream::begin);
CInterfaceManager *pIM = CInterfaceManager::getInstance();
// Load branch of the database
SDBLeaf leafTmp;
CCDBNodeBranch *pDB = pIM->getDbBranch ("UI:SAVE");
if (pDB != NULL)
{
// Number of leaf to save
uint32 nbLeaves = 0;
f.serial(nbLeaves);
for (uint32 i = 0; i < nbLeaves; ++i)
{
f.serial(leafTmp);
// If there is a define RESET_VER_dbName that exist for this DB, check if version is OK
bool wantRead= true;
// Format dbName for version check
string defVerId= "RESET_VER_";
defVerId+= leafTmp.Name;
for(uint i=0;i<defVerId.size();i++)
{
if(defVerId[i]==':')
defVerId[i]='_';
}
// check if exist
if(pIM->isDefineExist(defVerId))
{
uint32 dbVer;
fromString(pIM->getDefine(defVerId), dbVer);
// if the version in the file is older than the version this db want, abort read
if(uiDbSaveVersion<dbVer)
wantRead= false;
}
// if want read the value from file, read it, else keep the default one
if(wantRead)
{
CCDBNodeLeaf *pNL = pIM->getDbProp(leafTmp.Name,false);
if (pNL != NULL)
leafTmp.setTo(pNL);
}
}
}
}
示例2:
// ***************************************************************************
void CInterfaceConfig::CDesktopImage::read(NLMISC::IStream &f)
{
nlassert(f.isReading());
f.serialVersion(Version);
f.serialCont(GCImages);
// extra datas go until the end of stream
sint32 begPos = f.getPos();
f.seek (0, NLMISC::IStream::end);
sint32 endPos = f.getPos();
f.seek (begPos, NLMISC::IStream::begin);
NLMISC::contReset(ExtraDatas);
if (ExtraDatas.isReading())
{
ExtraDatas.invert();
}
sint32 length = endPos - begPos;
if (length > 0)
{
uint8 *pBuffer = new uint8[length];
f.serialBuffer(pBuffer, length); // read buffer from file
ExtraDatas.serialBuffer(pBuffer, length); // copy buffer to memstream
delete [] pBuffer;
}
}