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


C++ FilePtr::readLine方法代码示例

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


在下文中一共展示了FilePtr::readLine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadMessageInfo

//------------------------------------------------------------------------------------------
long Radio::loadMessageInfo(void)
{
FullPathFileName	messageInfoPath;
FilePtr				messageInfoFile;
long				result;
char				dataLine[512];
char*				field;

	messageInfoPath.init(soundPath,"radio",".csv");
	messageInfoFile = new File;
	if (!messageInfoFile)
		return -1; //quasit

	result = messageInfoFile->open(messageInfoPath);
	if (result != NO_ERR)
	{
		delete messageInfoFile;
		return result;
	}

	messageInfoFile->readLine((MemoryPtr)dataLine, 511);	// skip title line

	for (long i=0; i<RADIO_MESSAGE_COUNT; i++)
	{
		result = messageInfoFile->readLine((MemoryPtr)dataLine, 511);
		if (!result)
			Fatal(0, "Bad Message Info File");

		field = strtok(dataLine, ",");	// get past command name
		field = strtok(NULL, ",");
		if (field)
			messageInfo[i].priority = atoi(field);
		else
			messageInfo[i].priority = 4;

		field = strtok(NULL, ",");
		if (field)
			messageInfo[i].shelfLife = atoi(field);
		else
			messageInfo[i].shelfLife = 0;

		field = strtok(NULL, ",");
		if (field && *field != 'x')
			messageInfo[i].movieCode = *field;
		else
			messageInfo[i].movieCode = '\0';

		field = strtok(NULL, ",");
		if (field)
			messageInfo[i].styleCount = atoi(field);
		else
			messageInfo[i].styleCount = 1;

		field = strtok(NULL, ",");
		if (field)
			messageInfo[i].styleChance[0] = atoi(field);
		else
			messageInfo[i].styleChance[0] = 0;
		field = strtok(NULL, ",");
		if (field)
			messageInfo[i].styleChance[1] = atoi(field);
		else
			messageInfo[i].styleChance[1] = 0;
		field = strtok(NULL, ",");
		if (field)
			messageInfo[i].styleChance[2] = atoi(field);
		else
			messageInfo[i].styleChance[2] = 0;

		field = strtok(NULL, ",");
		if (field)
			messageInfo[i].pilotIdentifiesSelf = (*field == 'y');
		else
			messageInfo[i].pilotIdentifiesSelf = FALSE;

		field = strtok(NULL, ",");
		if (field)
			messageInfo[i].messageMapping = atoi(field);
		else
			messageInfo[i].messageMapping = 0;
		
		field = strtok(NULL, ",");
		if (field)
		{
			field = strtok(NULL, ",");
			if (field)
			{
				messageInfo[i].kludgeStyle = (*field == 'x');
			}
		}
		if (!field)
			messageInfo[i].kludgeStyle = FALSE;
	}
	messageInfoFile->close();
	delete messageInfoFile;
	return NO_ERR;
}
开发者ID:Echelon9,项目名称:mechcommander2-open,代码行数:98,代码来源:radio.cpp


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