本文整理汇总了C++中TreeIterator::moveToParent方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeIterator::moveToParent方法的具体用法?C++ TreeIterator::moveToParent怎么用?C++ TreeIterator::moveToParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeIterator
的用法示例。
在下文中一共展示了TreeIterator::moveToParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveTree
void XmlTreeSerializer::saveTree(const TreeIterator& treeIterator, const OutputStream& outputStream, int indent, const NumberFormat* numberFormat)
{
TreeIterator iterator = treeIterator;
if (iterator.hasMetaTag(NON_SERIALIZEABLE) == false)
{
if (iterator.isAttribute() == true)
{
iterator.moveToParent();
}
indentLine(outputStream, indent);
String nodeName = iterator.getName();
if (nodeName.findFirst("::") != String::END)
{
nodeName.searchAndReplace("::", ":");
}
outputStream << '<' << nodeName;
bool hasData = false;
const int attributeCount = iterator.getAttributeCount();
for (int i = 0; i < attributeCount; ++i)
{
iterator.moveToAttribute(i);
if (iterator.hasMetaTag(NON_SERIALIZEABLE) == false && iterator.isDefaultValue() == false)
{
if (iterator.getName() == "data")
{
hasData = true;
}
else
{
const String value = iterator.getValue();
const char8 quote = value.findFirst('\'') == String::END ? '\'' : '"';
outputStream << ' ' << iterator.getName() << '=' << quote << value << quote;
}
}
iterator.moveToParent();
}
const int childCount = iterator.getChildNodeCount();
if (childCount == 0 && hasData == false)
{
outputStream << " />" << newLine;
}
else
{
outputStream << '>' << newLine;
if (hasData == true)
{
outputStream << iterator.getValueOfAttribute("data");
}
for (int i = 0; i < childCount; ++i)
{
iterator.moveToChildNode(i);
saveTree(iterator, outputStream, indent+1, numberFormat);
iterator.moveToParent();
}
indentLine(outputStream, indent);
outputStream << "</" << nodeName << '>' << newLine;
}
}
}