本文整理汇总了C++中SerializerElement::GetAllChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ SerializerElement::GetAllChildren方法的具体用法?C++ SerializerElement::GetAllChildren怎么用?C++ SerializerElement::GetAllChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerializerElement
的用法示例。
在下文中一共展示了SerializerElement::GetAllChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Split
std::vector<Splitter::SplitElement> Splitter::Split(
SerializerElement& element,
const std::set<gd::String>& tags,
gd::String path) {
std::vector<Splitter::SplitElement> elements;
for (auto& child : element.GetAllChildren()) {
auto& childElement = child.second;
gd::String ref = path + pathSeparator + child.first;
if (tags.find(ref) != tags.end()) {
gd::String refName = childElement->GetStringAttribute(nameAttribute);
SplitElement splitElement = {ref, refName, *childElement};
elements.push_back(splitElement);
SerializerElement refElement;
refElement.SetAttribute("referenceTo", ref);
refElement.SetAttribute("name", refName);
*childElement = refElement;
} else {
auto newElements = Split(*childElement, tags, ref);
elements.insert(elements.end(), newElements.begin(), newElements.end());
}
}
return elements;
}
示例2: Unsplit
void Splitter::Unsplit(SerializerElement & element,
std::function<SerializerElement(gd::String path, gd::String name)> cb)
{
for(auto & child : element.GetAllChildren())
{
auto & childElement = child.second;
if ((childElement->HasAttribute("referenceTo") && childElement->HasAttribute("name")) ||
(childElement->HasChild("referenceTo") && childElement->HasChild("name")))
{
SerializerElement newElement = cb(childElement->GetStringAttribute("referenceTo"),
childElement->GetStringAttribute("name"));
*childElement = newElement;
}
Unsplit(*childElement, cb);
}
}