本文整理汇总了C++中XML_Node::lock方法的典型用法代码示例。如果您正苦于以下问题:C++ XML_Node::lock方法的具体用法?C++ XML_Node::lock怎么用?C++ XML_Node::lock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XML_Node
的用法示例。
在下文中一共展示了XML_Node::lock方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_XML_File
XML_Node* Application::get_XML_File(const std::string& file, int debug)
{
std::unique_lock<std::mutex> xmlLock(xml_mutex);
std::string path = "";
path = findInputFile(file);
int mtime = get_modified_time(path);
if (xmlfiles.find(path) != xmlfiles.end()) {
// Already have a parsed XML tree for this file cached. Check the
// last-modified time.
std::pair<XML_Node*, int> cache = xmlfiles[path];
if (cache.second == mtime) {
return cache.first;
}
}
/*
* Check whether or not the file is XML (based on the file extension). If
* not, it will be first processed with the preprocessor.
*/
string::size_type idot = path.rfind('.');
string ext;
if (idot != string::npos) {
ext = path.substr(idot, path.size());
} else {
ext = "";
}
XML_Node* x = new XML_Node("doc");
if (ext != ".xml" && ext != ".ctml") {
// Assume that we are trying to open a cti file. Do the conversion to XML.
std::stringstream phase_xml(ct2ctml_string(path));
x->build(phase_xml);
} else {
std::ifstream s(path.c_str());
if (s) {
x->build(s);
} else {
throw CanteraError("get_XML_File",
"cannot open "+file+" for reading.\n"
"Note, this error indicates a possible configuration problem.");
}
}
x->lock();
xmlfiles[path] = {x, mtime};
return x;
}