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


C++ StringParser::GetChar方法代码示例

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


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

示例1: SafeReadSound

SoundPtr ResourceConfig::SafeReadSound(StringParser &theVal)
{
	theVal.SkipWhitespace();
	
	SoundDescriptor aDesc;
	std::string aName;
	if(theVal.GetChar()=='(')
	{
		theVal.IncrementPos();
		theVal.ReadString(aName); EnsureComma(theVal);
		int aFlags = 0;
		while(true)
		{
			std::string aFlagStr;
			theVal.ReadString(aFlagStr,true);
			if(aFlagStr.empty())
				break;

			if(stricmp(aFlagStr.c_str(),"Preload")==0)
				aFlags |= SoundFlag_Preload;
			else if(stricmp(aFlagStr.c_str(),"Music")==0)
				aFlags |= SoundFlag_Music;
			else if(stricmp(aFlagStr.c_str(),"Muted")==0)
				aFlags |= SoundFlag_Muted;
			else 
				throw ConfigObjectException("Unknown sound flag: " + aFlagStr);
		}

		aDesc.SetSoundFlags(aFlags,true);
		EnsureCloseParen(theVal);
	}
	else
		theVal.ReadString(aName);

	aDesc.mFilePath = ComponentConfig::GetResourceFile(aName);

	SoundPtr aSound = WindowManager::GetDefaultWindowManager()->DecodeSound(aDesc);
	if(aSound.get()==NULL)
		throw ConfigObjectException("Failed to decode sound: " + aDesc.mFilePath);

	return aSound;
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:42,代码来源:ResourceConfig.cpp

示例2: SafeReadColor

int ResourceConfig::SafeReadColor(StringParser &theVal)
{
	theVal.SkipWhitespace();
	if(theVal.GetChar()=='(')
	{
		// special color (std or dec)
		std::string aType;
		theVal.IncrementPos();
		theVal.ReadString(aType);
		int aColor = 0;
		if(stricmp(aType.c_str(),"STD")==0) // standard color
		{
			EnsureComma(theVal);
			std::string aName;
			theVal.ReadString(aName); 
			const char *aPtr = aName.c_str();

			if(stricmp(aPtr,"3DDarkShadow")==0) aColor = ColorScheme::GetColorRef(StandardColor_3DDarkShadow); 
			else if(stricmp(aPtr,"3DFace")==0) aColor = ColorScheme::GetColorRef(StandardColor_3DFace); 
			else if(stricmp(aPtr,"3DHilight")==0) aColor = ColorScheme::GetColorRef(StandardColor_3DHilight); 
			else if(stricmp(aPtr,"3DShadow")==0) aColor = ColorScheme::GetColorRef(StandardColor_3DShadow); 
			else if(stricmp(aPtr,"Scrollbar")==0) aColor = ColorScheme::GetColorRef(StandardColor_Scrollbar); 
			else if(stricmp(aPtr,"ButtonText")==0) aColor = ColorScheme::GetColorRef(StandardColor_ButtonText); 
			else if(stricmp(aPtr,"GrayText")==0) aColor = ColorScheme::GetColorRef(StandardColor_GrayText); 
			else if(stricmp(aPtr,"Hilight")==0) aColor = ColorScheme::GetColorRef(StandardColor_Hilight); 
			else if(stricmp(aPtr,"HilightText")==0) aColor = ColorScheme::GetColorRef(StandardColor_HilightText); 
			else if(stricmp(aPtr,"ToolTipBack")==0) aColor = ColorScheme::GetColorRef(StandardColor_ToolTipBack); 
			else if(stricmp(aPtr,"ToolTipText")==0) aColor = ColorScheme::GetColorRef(StandardColor_ToolTipText); 
			else if(stricmp(aPtr,"MenuBack")==0) aColor = ColorScheme::GetColorRef(StandardColor_MenuBack); 
			else if(stricmp(aPtr,"MenuText")==0) aColor = ColorScheme::GetColorRef(StandardColor_MenuText); 
			else if(stricmp(aPtr,"Back")==0) aColor = ColorScheme::GetColorRef(StandardColor_Back); 
			else if(stricmp(aPtr,"Text")==0) aColor = ColorScheme::GetColorRef(StandardColor_Text); 
			else if(stricmp(aPtr,"Link")==0) aColor = ColorScheme::GetColorRef(StandardColor_Link); 
			else if(stricmp(aPtr,"LinkDown")==0) aColor = ColorScheme::GetColorRef(StandardColor_LinkDown); 
			else
				throw ConfigObjectException("Invalid standard color: " + aType);
		}
		else if(stricmp(aType.c_str(),"DEC")==0)
		{
			EnsureComma(theVal); 
			int r,g,b;
			theVal.ReadValue(r); EnsureComma(theVal);
			theVal.ReadValue(g); EnsureComma(theVal);
			theVal.ReadValue(b); 
			aColor = ((r&0xff)<<16) | ((g&0xff)<<8) | (b&0xff);
		}

		EnsureCloseParen(theVal);
		return aColor;
	}

	int aColor = 0;
	for(int i=0; i<6; i++)
	{
		aColor<<=4;
		int aDigit = ResourceConfig_GetHexDigit(theVal.GetChar());
		if(aDigit<0)
			throw ConfigObjectException("Invalid color specification.");

		aColor |= aDigit;
		theVal.IncrementPos();
	}
	
	return aColor;
}
开发者ID:SOLARIC,项目名称:world-opponent-network,代码行数:65,代码来源:ResourceConfig.cpp


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