本文整理汇总了C++中StringParser::ReadValue方法的典型用法代码示例。如果您正苦于以下问题:C++ StringParser::ReadValue方法的具体用法?C++ StringParser::ReadValue怎么用?C++ StringParser::ReadValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringParser
的用法示例。
在下文中一共展示了StringParser::ReadValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ResourceConfig_AddToMap
static bool ResourceConfig_AddToMap(const char *theName, StringParser &theVal, Map &theMap, int theParseCount, Type* &theType)
{
std::string aKey;
theVal.ReadValue(aKey,true);
if(aKey.empty())
throw ConfigObjectException("Invalid resource key.");
std::pair<Map::iterator,bool> aRet;
aRet = theMap.insert(Map::value_type(aKey,Map::referent_type(Type(),theParseCount)));
int &aParseCount = aRet.first->second.second;
if(aRet.second)
{
theType = &aRet.first->second.first;
return true;
}
else if(aParseCount==theParseCount)
{
char aBuf[512];
sprintf(aBuf,"%s resource already exists: %s",theName,aKey.c_str());
throw ConfigObjectException(aBuf);
}
return false;
}
示例2: 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));
}
示例3: HandleInt
bool ResourceConfig::HandleInt(StringParser &theVal)
{
int *anInt;
std::string aRefName;
if(ResourceConfig_AddToMap("Int",theVal,mIntMap,mParseCount,anInt))
{
ResourceConfig *aRef = CheckResourceReference(theVal,aRefName);
if(aRef!=NULL)
*anInt = aRef->SafeGetInt(aRefName);
else
{
if(!theVal.ReadValue(*anInt))
throw ConfigObjectException("Invalid integer value.");
}
}
return true;
}
示例4: HandleString
bool ResourceConfig::HandleString(StringParser &theVal)
{
GUIString *aString;
std::string aRefName;
if(ResourceConfig_AddToMap("String",theVal,mStringMap,mParseCount,aString))
{
ResourceConfig *aRef = CheckResourceReference(theVal,aRefName);
if(aRef!=NULL)
*aString = aRef->SafeGetString(aRefName);
else
{
std::wstring aVal;
theVal.ReadValue(aVal,false);
*aString = aVal;
}
}
return true;
}
示例5: 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;
}