本文整理汇总了C++中StringParser::ReadString方法的典型用法代码示例。如果您正苦于以下问题:C++ StringParser::ReadString方法的具体用法?C++ StringParser::ReadString怎么用?C++ StringParser::ReadString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringParser
的用法示例。
在下文中一共展示了StringParser::ReadString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleKeyVal
bool LobbyConfig::HandleKeyVal(ConfigParser &theParser, const std::string &theKey, StringParser &theVal)
{
if(theKey=="LOBBYDEFINE")
{
std::string aKey, aVal;
theVal.ReadString(aKey,true);
theVal.ReadString(aVal);
if(!aKey.empty())
mDefineMap[aKey] = aVal;
}
else
return ConfigObject::HandleKeyVal(theParser,theKey,theVal);
return true;
}
示例2: 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;
}
示例3: SafeReadImage
ImagePtr ResourceConfig::SafeReadImage(StringParser &theVal)
{
std::string aPath;
theVal.ReadString(aPath);
ImagePtr anImage = WindowManager::GetDefaultWindowManager()->DecodeDelayImage(ComponentConfig::GetResourceFile(aPath).c_str());
if(anImage.get()==NULL)
throw ConfigObjectException("Failed to decode image: " + aPath);
return anImage;
}
示例4: SafeReadFont
FontPtr ResourceConfig::SafeReadFont(StringParser &theVal)
{
std::string aFace;
theVal.ReadString(aFace); EnsureComma(theVal);
int aStyle = SafeReadFontStyle(theVal); EnsureComma(theVal);
int aSize;
if(!theVal.ReadValue(aSize) || aSize<=0)
throw ConfigObjectException("Invalid font size.");
return Window::GetDefaultWindow()->GetFont(FontDescriptor(aFace,aStyle,aSize));
}
示例5: SafeReadBackground
Background ResourceConfig::SafeReadBackground(StringParser &theVal)
{
std::string aType;
theVal.ReadString(aType);
if(stricmp(aType.c_str(),"COLOR")==0)
{
EnsureComma(theVal);
return SafeReadColor(theVal);
}
else if(stricmp(aType.c_str(),"IMAGE")==0)
{
EnsureComma(theVal);
return SafeReadImage(theVal).get();
}
else if(stricmp(aType.c_str(),"STRETCHIMAGE")==0)
{
EnsureComma(theVal);
Background aBackground(SafeReadImage(theVal));
aBackground.SetStretchImage(true);
return aBackground;
}
else if(stricmp(aType.c_str(),"WATERMARK")==0)
{
EnsureComma(theVal);
Background aBackground(SafeReadImage(theVal));
aBackground.SetUseOffsets(false);
return aBackground;
}
else if(stricmp(aType.c_str(),"NONE")==0)
return -1;
else if(stricmp(aType.c_str(),"TRANSPARENT")==0)
{
Background aBackground(-1);
aBackground.SetWantGrabBG(true);
return aBackground;
}
else
throw ConfigObjectException("Invalid background specification");
}
示例6: SafeReadFontStyle
int ResourceConfig::SafeReadFontStyle(StringParser &theVal)
{
std::string aStyleStr;
int aStyle = 0;
while(true)
{
theVal.ReadString(aStyleStr,true);
if(aStyleStr.empty())
break;
if(stricmp(aStyleStr.c_str(),"Bold")==0)
aStyle |= FontStyle_Bold;
else if(stricmp(aStyleStr.c_str(),"Italic")==0)
aStyle |= FontStyle_Italic;
else if(stricmp(aStyleStr.c_str(),"Plain")==0)
aStyle |= FontStyle_Plain;
else if(stricmp(aStyleStr.c_str(),"Underline")==0)
aStyle |= FontStyle_Underline;
else
throw ConfigObjectException("Unknown font style: " + aStyleStr);
}
return aStyle;
}
示例7: 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;
}