本文整理汇总了C++中ConfigReader::SetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigReader::SetAttribute方法的具体用法?C++ ConfigReader::SetAttribute怎么用?C++ ConfigReader::SetAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigReader
的用法示例。
在下文中一共展示了ConfigReader::SetAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateEditorFiles
/**
* @brief Export current configuration to xml: this is used to create the XML and JSON files to describe each module
*/
void Manager::CreateEditorFiles(const string& x_fileName)
{
try
{
map<string,vector<string>> categories;
Json::Value modules_json;
SYSTEM("mkdir -p modules");
vector<string> moduleTypes;
mr_moduleFactory.List(moduleTypes);
int id = 0;
for(const auto& moduleType : moduleTypes)
{
createEmptyConfigFile("/tmp/config_empty.xml");
ConfigFile config("/tmp/config_empty.xml");
ConfigReader moduleConfig = config.FindRef("application>module[name=\"" + moduleType + "\"]", true);
moduleConfig.SetAttribute("id", id);
moduleConfig.FindRef("parameters>param[name=\"class\"]", true).SetValue(moduleType);
ParameterStructure* parameters = mr_parametersFactory.Create(moduleType, moduleConfig);
Module* module = mr_moduleFactory.Create(moduleType, *parameters);
modules_json.append(moduleType);
// Append to the category
categories[module->GetCategory()].push_back(moduleType);
categories["all"].push_back(moduleType);
// Create the specific XML
string file("editor/modules/" + moduleType + ".xml");
ofstream os(file.c_str());
os<<"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<endl;
module->Export(os, 0);
delete module;
delete parameters;
os.close();
id++;
}
// Generate the js file containing the categories
Json::Value categories_json;
for(const auto& categ : categories)
{
for(const auto& mod : categ.second)
{
categories_json[categ.first].append(mod);
}
}
ofstream of(x_fileName);
of << "// This file contain the list of modules and modules categories. Generated automatically and used by the editor" << endl;
of << "var availableCategories = " << categories_json << ";" << endl << endl;
of << "var availableModules = " << modules_json << ";" << endl << endl;
of.close();
}
catch(MkException& e)
{
LOG_ERROR(m_logger, "Exception in Manager::Export: "<<e.what());
throw;
}
}