本文整理汇总了C++中XML_Node::parent方法的典型用法代码示例。如果您正苦于以下问题:C++ XML_Node::parent方法的具体用法?C++ XML_Node::parent怎么用?C++ XML_Node::parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XML_Node
的用法示例。
在下文中一共展示了XML_Node::parent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getByTitle
XML_Node* getByTitle(const Cantera::XML_Node& node, const std::string &title) {
XML_Node* s = node.findByAttr("title", title);
if (!s) return 0;
if (s->parent() == &node) {
return s;
}
return 0;
}
示例2: importKinetics
bool importKinetics(const XML_Node& phase, std::vector<ThermoPhase*> th,
Kinetics* k)
{
if (k == 0) {
return false;
}
// This phase will be the owning phase for the kinetics operator
// For interfaces, it is the surface phase between two volumes.
// For homogeneous kinetics, it's the current volumetric phase.
string owning_phase = phase["id"];
bool check_for_duplicates = false;
if (phase.parent() && phase.parent()->hasChild("validate")) {
const XML_Node& d = phase.parent()->child("validate");
if (d["reactions"] == "yes") {
check_for_duplicates = true;
}
}
// If other phases are involved in the reaction mechanism, they must be
// listed in a 'phaseArray' child element. Homogeneous mechanisms do not
// need to include a phaseArray element.
vector<string> phase_ids;
if (phase.hasChild("phaseArray")) {
const XML_Node& pa = phase.child("phaseArray");
getStringArray(pa, phase_ids);
}
phase_ids.push_back(owning_phase);
// for each referenced phase, attempt to find its id among those
// phases specified.
string msg = "";
for (size_t n = 0; n < phase_ids.size(); n++) {
string phase_id = phase_ids[n];
bool phase_ok = false;
// loop over the supplied 'ThermoPhase' objects representing
// phases, to find an object with the same id.
for (size_t m = 0; m < th.size(); m++) {
if (th[m]->id() == phase_id) {
phase_ok = true;
// if no phase with this id has been added to
//the kinetics manager yet, then add this one
if (k->phaseIndex(phase_id) == npos) {
k->addPhase(*th[m]);
}
}
msg += " "+th[m]->id();
}
if (!phase_ok) {
throw CanteraError("importKinetics",
"phase "+phase_id+" not found. Supplied phases are:"+msg);
}
}
// allocates arrays, etc. Must be called after the phases have been added to
// 'kin', so that the number of species in each phase is known.
k->init();
// Install the reactions.
return installReactionArrays(phase, *k, owning_phase, check_for_duplicates);
}