本文整理汇总了C++中TreeNode::Size方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeNode::Size方法的具体用法?C++ TreeNode::Size怎么用?C++ TreeNode::Size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode::Size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetPropertyFromNode
bool SetPropertyFromNode( const TreeNode& node, Property::Value& value,
const Replacement& replacer )
{
bool done = false;
// some values are ambiguous as we have no Property::Type but can be disambiguated in the json
// Currently Rotations and Rectangle must always be disambiguated when a type isnt available
if( Disambiguated( node, value, replacer ) )
{
done = true;
}
else
{
if( node.Size() )
{
// our current heuristic for deciding an array is actually a vector and not say a map
// is to check if the values are all floats
bool allNumbers = true;
for(TreeConstIter iter = node.CBegin(); iter != node.CEnd(); ++iter)
{
OptionalFloat f = IsFloat((*iter).second);
if(!f)
{
allNumbers = false;
break;
}
}
if( allNumbers )
{
// prefer finding vectors over presuming composite Property::Array...
if( OptionalMatrix v = IsMatrix(node) )
{
value = *v;
done = true;
}
else if( OptionalMatrix3 v = IsMatrix3(node) )
{
value = *v;
done = true;
}
else if( OptionalVector4 v = IsVector4(node) )
{
value = *v;
done = true;
}
else if( OptionalVector3 v = IsVector3(node) )
{
value = *v;
done = true;
}
else if( OptionalVector2 v = IsVector2(node) )
{
value = *v;
done = true;
}
else if( 4 == node.Size() )
{
if( OptionalVector4 v = IsVector4(node) )
{
value = *v;
done = true;
}
}
else
{
value = Property::Value(Property::ARRAY);
Property::Array* array = value.GetArray();
if( array )
{
for(TreeConstIter iter = node.CBegin(); iter != node.CEnd(); ++iter)
{
Property::Value childValue;
if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
{
array->PushBack( childValue );
done = true;
}
}
}
}
}
if(!done)
{
// presume an array or map
// container of size 1
TreeNode::ConstIterator iter = node.CBegin();
// its seems legal with current json parser for a map to have an empty key
// but here we take that to mean the structure is a list
if( ((*iter).first) == 0 )
{
value = Property::Value(Property::ARRAY);
Property::Array* array = value.GetArray();
if( array )
{
//.........这里部分代码省略.........