本文整理汇总了C++中Platform::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ Platform::setName方法的具体用法?C++ Platform::setName怎么用?C++ Platform::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Platform
的用法示例。
在下文中一共展示了Platform::setName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parsXml
Module* XmlModLoader::parsXml(const char* szFile)
{
module.clear();
ErrorLogger* logger = ErrorLogger::Instance();
TiXmlDocument doc(szFile);
if(!doc.LoadFile())
{
OSTRINGSTREAM err;
err<<"Syntax error while loading "<<szFile<<" at line "\
<<doc.ErrorRow()<<": ";
err<<doc.ErrorDesc();
logger->addError(err);
return nullptr;
}
/* retrieving root module */
TiXmlElement *root = doc.RootElement();
if(!root)
{
OSTRINGSTREAM err;
err<<"Syntax error while loading "<<szFile<<" . ";
err<<"No root element.";
logger->addError(err);
return nullptr;
}
if(!compareString(root->Value(), "module"))
{
/*
OSTRINGSTREAM msg;
msg<<szFile<<" is not a module descriptor file.";
logger->addWarning(msg);
*/
return nullptr;
}
/* retrieving name */
auto* name = (TiXmlElement*) root->FirstChild("name");
if(!name || !name->GetText())
{
OSTRINGSTREAM err;
err<<"Module from "<<szFile<<" has no name.";
logger->addError(err);
//return NULL;
}
for(TiXmlElement* var = root->FirstChildElement("var"); var; var = var->NextSiblingElement())
{
if(var->Attribute("name") && var->GetText())
{
parser->addVariable(var->Attribute("name"), var->GetText());
}
}
module.setXmlFile(szFile);
if(name)
module.setName(parser->parseText(name->GetText()).c_str());
/* retrieving description */
TiXmlElement* desc;
if((desc = (TiXmlElement*) root->FirstChild("description")))
module.setDescription(parser->parseText(desc->GetText()).c_str());
/* retrieving version */
TiXmlElement* ver;
if((ver = (TiXmlElement*) root->FirstChild("version")))
module.setVersion(parser->parseText(ver->GetText()).c_str());
/* retrieving parameter */
TiXmlElement* arguments;
if((arguments = (TiXmlElement*) root->FirstChild("arguments")))
for(TiXmlElement* param = arguments->FirstChildElement(); param;
param = param->NextSiblingElement())
{
if(compareString(param->Value(), "param"))
{
if(param->GetText())
{
bool brequired = false;
if(compareString(param->Attribute("required"), "yes"))
brequired = true;
Argument arg(parser->parseText(param->GetText()).c_str(),
brequired,
param->Attribute("desc"));
arg.setDefault(param->Attribute("default"));
module.addArgument(arg);
}
}
else
if(compareString(param->Value(), "switch"))
{
if(param->GetText())
{
bool brequired = false;
if(compareString(param->Attribute("required"), "yes"))
brequired = true;
Argument arg(parser->parseText(param->GetText()).c_str(),
//.........这里部分代码省略.........
示例2: parsXml
bool XmlResLoader::parsXml(const char* szFile)
{
computers.clear();
ErrorLogger* logger = ErrorLogger::Instance();
TiXmlDocument doc(szFile);
if(!doc.LoadFile())
{
OSTRINGSTREAM err;
err<<"Syntax error while loading "<<szFile<<" at line "\
<<doc.ErrorRow()<<": ";
err<<doc.ErrorDesc();
logger->addError(err);
return false;
}
/* retrieving root module */
TiXmlElement *root = doc.RootElement();
if(!root)
{
OSTRINGSTREAM err;
err<<"Syntax error while loading "<<szFile<<" . ";
err<<"No root element.";
logger->addError(err);
return false;
}
if(!compareString(root->Value(), "resources"))
{
/*
OSTRINGSTREAM msg;
msg<<szFile<<" is not a resource descriptor file.";
logger->addWarning(msg);
*/
return false;
}
/* retrieving all computers descriptions */
for(TiXmlElement* restag = root->FirstChildElement();
restag; restag = restag->NextSiblingElement())
{
/* retrieving a computer resource */
if(compareString(restag->Value(), "computer"))
{
Computer computer;
computer.setXmlFile(szFile);
for(TiXmlElement* comptag = restag->FirstChildElement();
comptag; comptag = comptag->NextSiblingElement())
{
/* retrieving name */
if(compareString(comptag->Value(), "name"))
computer.setName(comptag->GetText());
/* retrieving description */
if(compareString(comptag->Value(), "description"))
computer.setDescription(comptag->GetText());
/* retrieving disablility */
if(compareString(comptag->Value(), "disable"))
{
if(compareString(comptag->GetText(), "yes"))
computer.setDisable(true);
}
// platform
if(compareString(comptag->Value(), "platform"))
{
Platform os;
TiXmlElement* element;
if((element = (TiXmlElement*) comptag->FirstChild("name")))
os.setName(element->GetText());
else
{
OSTRINGSTREAM war;
war<<"Platform from "<<szFile<<" at line "\
<<comptag->Row()<<" has no name.";
logger->addWarning(war);
}
if((element = (TiXmlElement*) comptag->FirstChild("distribution")))
os.setDistribution(element->GetText());
if((element = (TiXmlElement*) comptag->FirstChild("release")))
os.setRelease(element->GetText());
computer.setPlatform(os);
} // end of platform tag
// memory
if(compareString(comptag->Value(), "memory"))
{
Memory mem;
TiXmlElement* element;
if((element = (TiXmlElement*) comptag->FirstChild("total_space")))
mem.setTotalSpace((Capacity)atol(element->GetText()));
computer.setMemory(mem);
} // end of memory tag
// storage
//.........这里部分代码省略.........