本文整理汇总了C++中property::Map::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ Map::Count方法的具体用法?C++ Map::Count怎么用?C++ Map::Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类property::Map
的用法示例。
在下文中一共展示了Map::Count方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NewActor
Actor NewActor( const Property::Map& map )
{
BaseHandle handle;
// First find type and create Actor
Property::Value* typeValue = map.Find( "type" );
if ( typeValue )
{
TypeInfo type = TypeRegistry::Get().GetTypeInfo( typeValue->Get< std::string >() );
if ( type )
{
handle = type.CreateInstance();
}
}
if ( !handle )
{
DALI_LOG_ERROR( "Actor type not provided\n" );
return Actor();
}
Actor actor( Actor::DownCast( handle ) );
if ( actor )
{
// Now set the properties, or create children
for ( unsigned int i = 0, mapCount = map.Count(); i < mapCount; ++i )
{
const StringValuePair& pair( map.GetPair( i ) );
const std::string& key( pair.first );
if ( key == "type" )
{
continue;
}
const Property::Value& value( pair.second );
if ( key == "actors" )
{
// Create children
Property::Array actorArray = value.Get< Property::Array >();
for ( Property::Array::SizeType i = 0; i < actorArray.Size(); ++i)
{
actor.Add( NewActor( actorArray[i].Get< Property::Map >() ) );
}
}
else
{
Property::Index index( actor.GetPropertyIndex( key ) );
if ( index != Property::INVALID_INDEX )
{
actor.SetProperty( index, value );
}
}
}
}
return actor;
}
示例2: UtcDaliPropertyMapInsertP
int UtcDaliPropertyMapInsertP(void)
{
Property::Map map;
DALI_TEST_EQUALS( 0, map.Count(), TEST_LOCATION );
map.Insert( "foo", "bar");
DALI_TEST_EQUALS( 1, map.Count(), TEST_LOCATION );
Property::Value* value = map.Find( "foo" );
DALI_TEST_CHECK( value );
DALI_TEST_EQUALS( "bar", value->Get<std::string>(), TEST_LOCATION );
map.Insert( std::string("foo2"), "testing" );
DALI_TEST_EQUALS( 2, map.Count(), TEST_LOCATION );
value = map.Find( "foo2" );
DALI_TEST_CHECK( value );
DALI_TEST_EQUALS( "testing", value->Get<std::string>(), TEST_LOCATION );
END_TEST;
}
示例3: UtcDaliPropertyMapCopyAndAssignment
int UtcDaliPropertyMapCopyAndAssignment(void)
{
Property::Map map;
map[ "hello" ] = 1;
map[ "world" ] = 2;
Property::Map assignedMap;
assignedMap[ "foo" ] = 3;
DALI_TEST_CHECK( assignedMap.Count() == 1 );
assignedMap = map;
DALI_TEST_CHECK( assignedMap.Count() == 2 );
Property::Map copiedMap( map );
DALI_TEST_CHECK( copiedMap.Count() == 2 );
// Self assignment
DALI_TEST_CHECK( map.Count() == 2 );
map = map;
DALI_TEST_CHECK( map.Count() == 2 );
END_TEST;
}
示例4: UtcDaliPropertyMapPopulate
int UtcDaliPropertyMapPopulate(void)
{
Property::Map map;
DALI_TEST_CHECK( map.Empty() );
map[ "hello" ] = 1;
map[ "world" ] = "world";
map[ "world" ] = 3; // same item as line above
DALI_TEST_CHECK( !map.Empty() ); // Should no longer be empty
DALI_TEST_CHECK( map.Count() == 2 ); // Should only have two items, not three!!
DALI_TEST_CHECK( map["hello"].Get<int>() == 1 );
DALI_TEST_CHECK( map["world"].Get<int>() == 3 );
map.Clear();
DALI_TEST_CHECK( map.Empty() );
END_TEST;
}
示例5: UtcDaliPropertyMapConstOperator
int UtcDaliPropertyMapConstOperator(void)
{
Property::Map map;
map[ "hello" ] = 1;
map[ "world" ] = 2;
DALI_TEST_CHECK( map.Count() == 2 );
const Property::Map& constMap( map );
DALI_TEST_CHECK( constMap[ "world" ].Get<int>() == 2 );
DALI_TEST_CHECK( constMap.Count() == 2 ); // Ensure count hasn't gone up
// Invalid Key
try
{
constMap[ "invalid-key" ];
tet_result( TET_FAIL );
}
catch ( DaliException& e )
{
DALI_TEST_ASSERT( e, "! \"Invalid Key\"", TEST_LOCATION );
}
END_TEST;
}
示例6: SetPropertyFromNode
//.........这里部分代码省略.........
{
value = Quaternion(Radian(Degree((*v).x)),
Radian(Degree((*v).y)),
Radian(Degree((*v).z)));
done = true;
}
}
break;
}
case Property::STRING:
{
if( OptionalString v = replacer.IsString(node) )
{
value = *v;
done = true;
}
break;
}
case Property::ARRAY:
{
if( replacer.IsArray( node, value ) )
{
done = true;
}
else if(node.Size())
{
value = Property::Value(Property::ARRAY);
Property::Array* array = value.GetArray();
unsigned int i = 0;
TreeNode::ConstIterator iter(node.CBegin());
if( array )
{
for( ; i < node.Size(); ++i, ++iter)
{
Property::Value childValue;
if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
{
array->PushBack( childValue );
}
}
if( array->Count() == node.Size() )
{
done = true;
}
else
{
done = false;
}
}
}
break;
}
case Property::MAP:
{
if( replacer.IsMap( node, value ) )
{
done = true;
}
else if(node.Size())
{
value = Property::Value(Property::MAP);
Property::Map* map = value.GetMap();
unsigned int i = 0;
TreeNode::ConstIterator iter(node.CBegin());
if( map )
{
for( ; i < node.Size(); ++i, ++iter)
{
Property::Value childValue;
if( SetPropertyFromNode( (*iter).second, childValue, replacer ) )
{
map->Insert( (*iter).first, childValue );
}
}
if( map->Count() == node.Size() )
{
done = true;
}
else
{
done = false;
}
}
}
break;
}
case Property::NONE:
{
break;
}
} // switch type
return done;
}
示例7: NewAnimation
void NewAnimation( const Property::Map& map, Dali::AnimationData& outputAnimationData )
{
// Note: Builder cannot currently pass generic Property::Maps "{" that are nested, so currently we can only have one AnimateTo per animation.
Dali::AnimationData::AnimationDataElement* element = new Dali::AnimationData::AnimationDataElement();
element->alphaFunction = AlphaFunction::LINEAR;
element->timePeriodDelay = 0.0f;
element->timePeriodDuration = 1.0f;
// Now set the properties, or create children
for( unsigned int i = 0, animationMapCount = map.Count(); i < animationMapCount; ++i )
{
const StringValuePair& pair( map.GetPair( i ) );
const std::string& key( pair.first );
const Property::Value& value( pair.second );
if( key == "actor" )
{
element->actor = value.Get< std::string >();
}
else if( key == "property" )
{
element->property = value.Get< std::string >();
}
else if( key == "value" )
{
element->value = value;
}
else if( key == "alphaFunction" )
{
std::string alphaFunctionValue = value.Get< std::string >();
if( alphaFunctionValue == "LINEAR" )
{
element->alphaFunction = AlphaFunction::LINEAR;
}
else if( alphaFunctionValue == "REVERSE" )
{
element->alphaFunction = AlphaFunction::REVERSE;
}
else if( alphaFunctionValue == "EASE_IN_SQUARE" )
{
element->alphaFunction = AlphaFunction::EASE_IN_SQUARE;
}
else if( alphaFunctionValue == "EASE_OUT_SQUARE" )
{
element->alphaFunction = AlphaFunction::EASE_OUT_SQUARE;
}
else if( alphaFunctionValue == "EASE_IN" )
{
element->alphaFunction = AlphaFunction::EASE_IN;
}
else if( alphaFunctionValue == "EASE_OUT" )
{
element->alphaFunction = AlphaFunction::EASE_OUT;
}
else if( alphaFunctionValue == "EASE_IN_OUT" )
{
element->alphaFunction = AlphaFunction::EASE_IN_OUT;
}
else if( alphaFunctionValue == "EASE_IN_SINE" )
{
element->alphaFunction = AlphaFunction::EASE_IN_SINE;
}
else if( alphaFunctionValue == "EASE_OUT_SINE" )
{
element->alphaFunction = AlphaFunction::EASE_OUT_SINE;
}
else if( alphaFunctionValue == "EASE_IN_OUT_SINE" )
{
element->alphaFunction = AlphaFunction::EASE_IN_OUT_SINE;
}
else if( alphaFunctionValue == "BOUNCE" )
{
element->alphaFunction = AlphaFunction::BOUNCE;
}
else if( alphaFunctionValue == "SIN" )
{
element->alphaFunction = AlphaFunction::SIN;
}
else if( alphaFunctionValue == "EASE_OUT_BACK" )
{
element->alphaFunction = AlphaFunction::EASE_OUT_BACK;
}
}
else if( key == "timePeriod" )
{
Property::Map timeMap = value.Get< Property::Map >();
for( unsigned int i = 0; i < timeMap.Count(); ++i )
{
const StringValuePair& pair( timeMap.GetPair( i ) );
if( pair.first == "delay" )
{
element->timePeriodDelay = pair.second.Get< float >();
}
else if( pair.first == "duration" )
{
element->timePeriodDuration = pair.second.Get< float >();
}
}
}
//.........这里部分代码省略.........
示例8: UtcDaliPropertyMapMerge
int UtcDaliPropertyMapMerge(void)
{
Property::Map map;
map[ "hello" ] = 1;
map[ "world" ] = 2;
DALI_TEST_CHECK( map.Count() == 2 );
// Create another map with the same keys but different values
Property::Map map2;
map[ "hello" ] = 3;
map[ "world" ] = 4;
// Merge map2 into map1, count should still be 2, map values should be from map2
map.Merge( map2 );
DALI_TEST_CHECK( map.Count() == 2 );
DALI_TEST_CHECK( map[ "hello" ].Get< int >() == 3 );
DALI_TEST_CHECK( map[ "world"].Get< int >() == 4 );
// Create another map with different keys
Property::Map map3;
map3[ "foo" ] = 5;
map3[ "bar" ] = 6;
// Merge map3 into map1, count should increase, existing values should match previous and new values should match map3
map.Merge( map3 );
DALI_TEST_CHECK( map.Count() == 4 );
DALI_TEST_CHECK( map[ "hello" ].Get< int >() == 3 );
DALI_TEST_CHECK( map[ "world"].Get< int >() == 4 );
DALI_TEST_CHECK( map[ "foo"].Get< int >() == 5 );
DALI_TEST_CHECK( map[ "bar"].Get< int >() == 6 );
// Create an empty map and attempt to merge, should be successful, nothing should change
Property::Map map4;
DALI_TEST_CHECK( map4.Empty() );
map.Merge( map4 );
DALI_TEST_CHECK( map4.Empty() );
DALI_TEST_CHECK( map.Count() == 4 );
DALI_TEST_CHECK( map[ "hello" ].Get< int >() == 3 );
DALI_TEST_CHECK( map[ "world"].Get< int >() == 4 );
DALI_TEST_CHECK( map[ "foo"].Get< int >() == 5 );
DALI_TEST_CHECK( map[ "bar"].Get< int >() == 6 );
// Merge map into map4, map4 should be the same as map now.
map4.Merge( map );
DALI_TEST_CHECK( map4.Count() == 4 );
DALI_TEST_CHECK( map4[ "hello" ].Get< int >() == 3 );
DALI_TEST_CHECK( map4[ "world"].Get< int >() == 4 );
DALI_TEST_CHECK( map4[ "foo"].Get< int >() == 5 );
DALI_TEST_CHECK( map4[ "bar"].Get< int >() == 6 );
// Attempt to merge into itself, should be successful, nothing should change
map.Merge( map );
DALI_TEST_CHECK( map.Count() == 4 );
DALI_TEST_CHECK( map[ "hello" ].Get< int >() == 3 );
DALI_TEST_CHECK( map[ "world"].Get< int >() == 4 );
DALI_TEST_CHECK( map[ "foo"].Get< int >() == 5 );
DALI_TEST_CHECK( map[ "bar"].Get< int >() == 6 );
END_TEST;
}