本文整理汇总了C++中DataNode::SetName方法的典型用法代码示例。如果您正苦于以下问题:C++ DataNode::SetName方法的具体用法?C++ DataNode::SetName怎么用?C++ DataNode::SetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataNode
的用法示例。
在下文中一共展示了DataNode::SetName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddNode
DataNode* DataNode::AddNode(const WString& name)
{
int delPos = name.Find("/");
if (delPos >= 0)
{
WString namePart = name.SubStr(0, delPos);
DataNode* node = GetNode(namePart);
if (!node)
{
node = mnew DataNode();
node->SetName(namePart);
node->mParent = this;
mChildNodes.Add(node);
}
return node->AddNode(name.SubStr(delPos + 1));
}
DataNode* newNode = mnew DataNode();
newNode->SetName(name);
newNode->mParent = this;
mChildNodes.Add(newNode);
return newNode;
}
示例2: WriteObject
static void WriteObject(void* object, void* source, const ObjectType& type, DataNode& node)
{
for (auto baseType : type.GetBaseTypes())
{
const ObjectType* baseObjectType = dynamic_cast<const ObjectType*>(baseType.type);
if (!baseObjectType)
continue;
void* baseObject = (*baseType.dynamicCastUpFunc)(object);
void* baseSourceObject = (*baseType.dynamicCastUpFunc)(source);
WriteObject(baseObject, baseSourceObject, *baseObjectType, node);
}
for (auto field : type.GetFields())
{
if (!field->GetAttribute<SerializableAttribute>())
continue;
if (field->GetType()->IsBasedOn(TypeOf(IObject)))
{
bool usedConverter = false;
for (auto conv : mDataConverters)
{
if (conv->IsConvertsType(&type))
{
if (!field->IsValueEquals(object, source))
conv->ToData(&object, *node.AddNode(field->GetName()));
usedConverter = true;
break;
}
}
if (usedConverter)
continue;
DataNode* newFieldNode = mnew DataNode();
newFieldNode->SetName(field->GetName());
newFieldNode->SetValueDelta(*(IObject*)field->GetValuePtr(object),
*(IObject*)field->GetValuePtr(source));
if (!newFieldNode->IsEmpty())
node.AddNode(newFieldNode);
else
delete newFieldNode;
continue;
}
if (!field->IsValueEquals(object, source))
{
DataNode* newFieldNode = mnew DataNode();
newFieldNode->SetName(field->GetName());
field->SerializeFromObject(object, *newFieldNode);
if (!newFieldNode->IsEmpty())
node.AddNode(newFieldNode);
else
delete newFieldNode;
}
}
}