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


C++ CPVRTString::substr方法代码示例

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


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

示例1: PVRTStringGetContainingDirectoryPath

/*!***********************************************************************
@Function			PVRTStringGetContainingDirectoryPath
@Input				strFilePath A string
@Returns			Directory
@Description		Extracts the directory portion from a file path.
************************************************************************/
CPVRTString PVRTStringGetContainingDirectoryPath(const CPVRTString& strFilePath)
{
	size_t i32sep = strFilePath.find_last_of('/');
	if(i32sep == strFilePath.npos)
	{
		i32sep = strFilePath.find_last_of('\\');
		if(i32sep == strFilePath.npos)
		{	// can't find an actual \ or / so leave it be
			return strFilePath;
		}
	}
	return strFilePath.substr(0,i32sep);
}
开发者ID:quocble,项目名称:LimbicGL,代码行数:19,代码来源:PVRTString.cpp

示例2: PVRTStringGetFileName

/*!***********************************************************************
@Function			PVRTStringGetFileName
@Input				strFilePath A string
@Returns			FileName
@Description		Extracts the name and extension portion from a file path.
************************************************************************/
CPVRTString PVRTStringGetFileName(const CPVRTString& strFilePath)
{
	size_t i32sep = strFilePath.find_last_of('/');
	if(i32sep == strFilePath.npos)
	{
		i32sep = strFilePath.find_last_of('\\');
		if(i32sep == strFilePath.npos)
		{	// can't find an actual \ or / so leave it be
			return strFilePath;
		}
	}
	return strFilePath.substr(i32sep+1,strFilePath.length());
}
开发者ID:quocble,项目名称:LimbicGL,代码行数:19,代码来源:PVRTString.cpp

示例3: Parse

PVRES PVRESParser::Parse()
{
	if(m_bScriptFileSpecified)
	{	// file has been specified
		// read script file; seriously unsubtle atm
		FILE *file = fopen(m_pcPVRES->getScriptFileName().c_str(),"rb");
		if(!file)
		{
			m_strError = CPVRTString("Couldn't open file.");
			return *m_pcPVRES;
		}
		// obtain file size:
		fseek (file , 0 , SEEK_END);
		long lSize = ftell(file);
		fclose(file);			// some OSs don't understand rewind
		file = fopen(m_pcPVRES->getScriptFileName().c_str(), "rb");
		if(!lSize)
		{
			m_strError = CPVRTString("File is empty.");
			return *m_pcPVRES;
		}
		// Allocate an array large enough
		char* allData = new char[lSize+1];

		if(!allData)
		{
			m_strError = CPVRTString("Couldn't allocate memory for reading script.");
			return *m_pcPVRES;
		}

		fread(allData,1,lSize,file);
		fclose(file);

		allData[lSize]='0';	// terminate the file properly

		m_strScript = CPVRTString(allData);
		PVRDELETEARRAY(allData);
	}
	else
	{
		return *m_pcPVRES;	//use default PVRES that should outlive the PVRESParser class
	}

	// parse the script file
	CPVRTString strLine;

	char cBool;
	int i32Int;


	// TODO: do this in a slightly less pre-school way
	while(getline(m_strScript, strLine, '\n'))
	{
		if (strLine.substr(0,strlen("fullscreen:")).compare("fullscreen:")==0)
		{
			sscanf(strLine.c_str(),"fullscreen:%c", &cBool);
			m_pcPVRES->setFullScreen(cBool=='Y' || cBool=='y');
		}
		else if (strLine.substr(0,strlen("title:")).compare("title:")==0)
		{
			m_pcPVRES->setTitle(strLine.substr(6));
		}
		else if (strLine.substr(0,strlen("pod:")).compare("pod:")==0)
		{
			m_pcPVRES->setPODFileName(strLine.substr(4));
		}
		else if (strLine.substr(0,strlen("startframe:")).compare("startframe:")==0)
		{
		CPVRTString strTemp = (strLine.substr(11));

			char* pszTemp = new char[strTemp.size()+1];
			sprintf(pszTemp,"%s",strTemp.c_str());

			m_pcPVRES->setStartFrame((float)atof(pszTemp));
			PVRDELETEARRAY(pszTemp);
		}
		else if (strLine.substr(0,strlen("showfps:")).compare("showfps:")==0)
		{
			sscanf(strLine.c_str(),"showfps:%c", &cBool);
			m_pcPVRES->setShowFPS(cBool=='Y' || cBool=='y');
		}
		else if (strLine.substr(0,strlen("animspeed:")).compare("animspeed:")==0)
		{
			float fAnimationSpeed;
			sscanf(strLine.c_str(),"animspeed:%f", &fAnimationSpeed);
			m_pcPVRES->setAnimationSpeed(fAnimationSpeed);
		}
		else if (strLine.substr(0,strlen("vertsync:")).compare("vertsync:")==0)
		{
			sscanf(strLine.c_str(),"vertsync:%c", &cBool);
			m_pcPVRES->setVertSync(cBool=='Y' || cBool=='y');
		}
		else if (strLine.substr(0,strlen("logtofile:")).compare("logtofile:")==0)
		{
			sscanf(strLine.c_str(),"logtofile:%c", &cBool);
			m_pcPVRES->setLogToFile(cBool=='Y' || cBool=='y');
		}
		else if (strLine.substr(0,strlen("powersaving:")).compare("powersaving:")==0)
		{
			sscanf(strLine.c_str(),"powersaving:%c", &cBool);
//.........这里部分代码省略.........
开发者ID:zhurb88,项目名称:PVR-OGLES2.0,代码行数:101,代码来源:PVRESParser.cpp


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