当前位置: 首页>>代码示例>>C++>>正文


C++ IStream::seek方法代码示例

本文整理汇总了C++中nlmisc::IStream::seek方法的典型用法代码示例。如果您正苦于以下问题:C++ IStream::seek方法的具体用法?C++ IStream::seek怎么用?C++ IStream::seek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nlmisc::IStream的用法示例。


在下文中一共展示了IStream::seek方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
			}
		}
	}
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:60,代码来源:interface_config.cpp

示例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;
	}
}
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:25,代码来源:interface_config.cpp

示例3: serial

//--------------------------------------------------------------
//						CAISurvivalInstinctEvent::serial()  
//--------------------------------------------------------------
void CAISurvivalInstinctEvent::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	if (f.isReading() )
	{
	//	CAIEventType type;
		uint16 size;
	//	f.serial(type);
		f.serial(size);

		if (/*type != CAIEventType("SURVIE") ||*/ size != sizeof(CAISurvivalInstinctEvent))
		{
			CreatureId = NLMISC::CEntityId();
			EntityId = NLMISC::CEntityId();
			Modifier = 0;
			try
			{
				// seek takes a param in bytes (8 bits)
				f.seek( size, NLMISC::IStream::current);
			}
			catch(ESeekNotSupported &)
			{
				uint8 tmp;
				for (uint i = 0 ; i < size ; ++i)
					f.serial(tmp);
			}
		}
		else
		{
			f.serial(CreatureId);
			f.serial(EntityId);
			f.serial(Modifier);
		}
	}
	else
	{
		CAIEventType type("SURVIE");
		uint16 size = sizeof(CAISurvivalInstinctEvent);

		f.serial(type);
		f.serial(size);
		f.serial(CreatureId);
		f.serial(EntityId);
		f.serial(Modifier);
		
	}
} // CAISurvivalInstinctEvent::serial //
开发者ID:Darkhunter,项目名称:Tranquillien-HCRP-Project-using-NeL,代码行数:49,代码来源:ai_event.cpp


注:本文中的nlmisc::IStream::seek方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。