本文整理汇总了C++中tree::getValue方法的典型用法代码示例。如果您正苦于以下问题:C++ tree::getValue方法的具体用法?C++ tree::getValue怎么用?C++ tree::getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::getValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeSiblingsXML
void writeSiblingsXML(const tree<AstNode>& t, const tree<AstNode>::iterator iRoot, ostream& stream)
{
if(t.empty())
return;
if (iRoot->getType() == "root") {
tree<AstNode>::sibling_iterator iChildren = t.begin(iRoot);
stream << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" << endl;
writeSiblingsXML(t,iChildren,stream);
}
else if (t.number_of_children(iRoot) == 0) {
string type = iRoot->getType();
stream << "<php:" << type << '>';
if (iRoot->getValue().length() > 0)
stream << htmlentities(iRoot->getValue());
stream << "</php:" << type << '>' << endl;
}
else {
string type = iRoot->getType();
string xmlns="";
if (type == "start")
xmlns = " xmlns:php=\"http://php.net/csl\"";
stream << "<php:" << type << xmlns << '>' << endl;
int siblingNum;
tree<AstNode>::sibling_iterator iChildren;
for (iChildren = t.begin(iRoot), siblingNum = 0; iChildren != t.end(iRoot); ++iChildren)
{
writeSiblingsXML(t,iChildren,stream);
}
stream << "</php:" << type << '>' << endl;
}
}
示例2: insert_statement
/**
Insert a new statement.
- Create a new inner_statement_list
- Add the statement under it
*/
bool insert_statement(const tree<AstNode>::iterator& where, const tree<AstNode>::iterator& what, tree<AstNode>& tr)
{
if (where->getType() == "text" && where->getValue() == "$enter_the_new_statement") {
// rewind to the inner_statement_list
tree<AstNode>::iterator top = where;
do {
top = tr.parent(top);
} while (top->getType() != "inner_statement" && tr.child(top,0)->getType() != "statement");
top = tr.parent(top);
if (top->getType() != "inner_statement_list")
return false;
else {
top = tr.append_child(top, AstNode("inner_statement_list"));
top = tr.append_child(top, AstNode("inner_statement"));
if (what->getType() == "statement") {
top = tr.append_child(top, AstNode("statement"));
//cout << "Seems to be okay..." << endl;
move_branch(top, what, tr);
}
}
return true;
}
return false;
}