DALI_TEST_CHECK( "MAP" == std::string(PropertyTypes::GetName( type ) ) );
break;
}
- case Property::TYPE_COUNT:
- {
- DALI_TEST_CHECK( "NONE" == std::string(PropertyTypes::GetName( type ) ) );
- break;
- }
} // switch(type)
} // CheckTypeName
}
};
-template <>
-struct CheckCopyCtorP<AngleAxis>
-{
- CheckCopyCtorP(Property::Value value)
- {
- Property::Value copy( value );
- AngleAxis a = value.Get<AngleAxis>();
- AngleAxis b = copy.Get<AngleAxis>();
- DALI_TEST_CHECK( a.angle == b.angle );
- DALI_TEST_CHECK( a.axis == b.axis );
- }
-};
-
-template <>
-struct CheckCopyCtorP<Property::Array>
-{
- CheckCopyCtorP(Property::Value value)
- {
- Property::Value copy( value );
- Property::Array a = value.Get<Property::Array>();
- Property::Array b = copy.Get<Property::Array>();
- DALI_TEST_CHECK( a.Size() == b.Size() );
- }
-};
-
-template <>
-struct CheckCopyCtorP<Property::Map>
-{
- CheckCopyCtorP(Property::Value value)
- {
- Property::Value copy( value );
- Property::Map a = value.Get<Property::Map>();
- Property::Map b = copy.Get<Property::Map>();
- DALI_TEST_CHECK( a.Count() == b.Count() );
- }
-};
-
} // unnamed namespace
void utc_dali_property_value_startup(void)
DALI_TEST_CHECK( value.GetType() == Property::NONE );
- Property::Value value2( Property::TYPE_COUNT );
-
- DALI_TEST_CHECK( value2.GetType() == Property::NONE );
-
END_TEST;
}
Property::Value value;
Property::Value value2( value );
DALI_TEST_EQUALS( value.GetType(), value2.GetType(), TEST_LOCATION );
- DALI_TEST_EQUALS( value.IsMap(), value2.IsMap(), TEST_LOCATION );
- DALI_TEST_EQUALS( value.IsArray(), value2.IsArray(), TEST_LOCATION );
+ DALI_TEST_EQUALS( value.GetMap(), value2.GetMap(), TEST_LOCATION );
+ DALI_TEST_EQUALS( value.GetArray(), value2.GetArray(), TEST_LOCATION );
END_TEST;
}
Property::Value* self = &value;
value = *self;
DALI_TEST_EQUALS( value.GetType(), Property::NONE, TEST_LOCATION );
- DALI_TEST_EQUALS( value.IsMap(), false, TEST_LOCATION );
- DALI_TEST_EQUALS( value.IsArray(), false, TEST_LOCATION );
+ DALI_TEST_CHECK( value.GetMap() == NULL );
+ DALI_TEST_CHECK( value.GetArray() == NULL );
END_TEST;
}
int UtcDaliPropertyValueGetBoolP(void)
{
Property::Value value(true);
+ bool boolean( false );
+ DALI_TEST_CHECK( value.Get( boolean ) == true );
DALI_TEST_CHECK( value.Get<bool>() == true );
+ std::string string;
+ DALI_TEST_CHECK( value.Get( string ) == false );
value = Property::Value(1.f);
DALI_TEST_CHECK( value.Get<float>() == 1.f );
END_TEST;
{
Property::Value value;
DALI_TEST_CHECK( value.Get<bool>() == false );
+ bool boolean( false );
+ DALI_TEST_CHECK( value.Get( boolean ) == false );
END_TEST;
}
int UtcDaliPropertyValueGetFloatP(void)
{
Property::Value value(1.1f);
+ float flow( 0.0f );
DALI_TEST_EQUALS( 1.1f, value.Get<float>(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( flow ), TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetFloatN(void)
{
Property::Value value;
- DALI_TEST_EQUALS( 0.0f, value.Get<float>(), TEST_LOCATION );
+ float result( 1.0f );
+ DALI_TEST_EQUALS( false, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( 1.0f, result, TEST_LOCATION ); // result is not modified
+ Property::Value value2( "" );
+ DALI_TEST_EQUALS( false, value2.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( 1.0f, result, TEST_LOCATION ); // result is not modified
END_TEST;
}
int UtcDaliPropertyValueGetIntP(void)
{
Property::Value value(123);
+ int result( 10 );
DALI_TEST_EQUALS( 123, value.Get<int>(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( 123, result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetIntN(void)
{
Property::Value value;
+ int result( 10 );
DALI_TEST_EQUALS( 0, value.Get<int>(), TEST_LOCATION );
+ DALI_TEST_EQUALS( false, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( 10, result, TEST_LOCATION ); // result is not modified
+ Property::Value value2("");
+ DALI_TEST_EQUALS( false, value2.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( 10, result, TEST_LOCATION ); // result is not modified
END_TEST;
}
int UtcDaliPropertyValueGetUnsignedIntP(void)
{
Property::Value value(123u);
+ unsigned int result( 10u );
DALI_TEST_EQUALS( 123u, value.Get<unsigned int>(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( 123u, result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetUnsignedIntN(void)
{
Property::Value value;
+ unsigned int result( 10u );
DALI_TEST_EQUALS( 0u, value.Get<unsigned int>(), TEST_LOCATION );
+ DALI_TEST_EQUALS( false, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( 10u, result, TEST_LOCATION );
+ Property::Value value2("");
+ DALI_TEST_EQUALS( false, value2.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( 10u, result, TEST_LOCATION ); // result is not modified
END_TEST;
}
int UtcDaliPropertyValueGetRectP(void)
{
Property::Value value( Rect<int>(1,2,3,4) );
+ Rect<int> result(4,3,2,1);
DALI_TEST_EQUALS( Rect<int>(1,2,3,4), value.Get< Rect<int> >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Rect<int>(1,2,3,4), result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetRectN(void)
{
Property::Value value;
+ Rect<int> result(4,3,2,1);
DALI_TEST_EQUALS( Rect<int>(0,0,0,0), value.Get< Rect<int> >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( false, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Rect<int>(4,3,2,1), result, TEST_LOCATION );
+ Property::Value value2("");
+ DALI_TEST_EQUALS( false, value2.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Rect<int>(4,3,2,1), result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetVector2P(void)
{
Property::Value value( Vector2(1.0f,2.0f) );
+ Vector2 result;
DALI_TEST_EQUALS( Vector2(1.0f,2.0f), value.Get< Vector2 >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(1.0f,2.0f), result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetVector2N(void)
{
Property::Value value;
+ Vector2 result;
DALI_TEST_EQUALS( Vector2(0.f,0.f), value.Get< Vector2 >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( false, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(), result, TEST_LOCATION );
+ Property::Value value2("");
+ DALI_TEST_EQUALS( false, value2.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(), result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetVector3P(void)
{
Property::Value value( Vector3(1.0f,2.0f,-1.f) );
+ Vector3 result;
DALI_TEST_EQUALS( Vector3(1.0f,2.0f,-1.f), value.Get< Vector3 >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector3(1.0f,2.0f,-1.f), result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetVector3N(void)
{
Property::Value value;
+ Vector3 result;
DALI_TEST_EQUALS( Vector3(0.f,0.f,0.f), value.Get< Vector3 >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( false, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector3(), result, TEST_LOCATION );
+ Property::Value value2("");
+ DALI_TEST_EQUALS( false, value2.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector3(), result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetVector4P(void)
{
Property::Value value( Vector4(1.f,2.f,-1.f,-3.f) );
+ Vector4 result;
DALI_TEST_EQUALS( Vector4(1.f,2.f,-1.f,-3.f), value.Get< Vector4 >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector4(1.f,2.f,-1.f,-3.f), result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetVector4N(void)
{
Property::Value value;
+ Vector4 result;
DALI_TEST_EQUALS( Vector4(0.f,0.f,0.f,0.f), value.Get< Vector4 >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( false, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector4(), result, TEST_LOCATION );
+ Property::Value value2("");
+ DALI_TEST_EQUALS( false, value2.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector4(), result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetMatrix3P(void)
{
Property::Value value( Matrix3(1.f,2.f,3.f,4.f,5.f,6.f,7.f,8.f,9.f) );
+ Matrix3 result;
DALI_TEST_EQUALS( Matrix3(1.f,2.f,3.f,4.f,5.f,6.f,7.f,8.f,9.f), value.Get< Matrix3 >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Matrix3(1.f,2.f,3.f,4.f,5.f,6.f,7.f,8.f,9.f), result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetMatrix3N(void)
{
Property::Value value;
- DALI_TEST_EQUALS( Matrix3::IDENTITY, value.Get< Matrix3 >(), TEST_LOCATION );
+ Matrix3 result(1.f,2.f,3.f,4.f,5.f,6.f,7.f,8.f,9.f);
+ DALI_TEST_EQUALS( Matrix3(), value.Get< Matrix3 >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( false, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Matrix3(1.f,2.f,3.f,4.f,5.f,6.f,7.f,8.f,9.f), result, TEST_LOCATION );
+ Property::Value value2("");
+ DALI_TEST_EQUALS( false, value2.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Matrix3(1.f,2.f,3.f,4.f,5.f,6.f,7.f,8.f,9.f), result, TEST_LOCATION );
END_TEST;
}
float matrixValues[16] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 };
Matrix input( matrixValues );
Property::Value value( input );
+ Matrix result;
DALI_TEST_EQUALS( input, value.Get< Matrix >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( input, result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetMatrixN(void)
{
Property::Value value;
- DALI_TEST_EQUALS( Matrix::IDENTITY, value.Get< Matrix >(), TEST_LOCATION );
+ Matrix result( Matrix::IDENTITY );
+ DALI_TEST_EQUALS( Matrix(), value.Get< Matrix >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( false, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Matrix::IDENTITY, result, TEST_LOCATION );
+
+ Property::Value value2("");
+ DALI_TEST_EQUALS( false, value2.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Matrix::IDENTITY, result, TEST_LOCATION );
END_TEST;
}
AngleAxis result = value.Get<AngleAxis>();
DALI_TEST_EQUALS( input.angle, result.angle, TEST_LOCATION );
DALI_TEST_EQUALS( input.axis, result.axis, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( input, result, TEST_LOCATION );
END_TEST;
}
{
Property::Value value;
AngleAxis b = value.Get<AngleAxis>();
+ AngleAxis result;
DALI_TEST_EQUALS( 0.f, b.angle, TEST_LOCATION );
DALI_TEST_EQUALS( Vector3::ZERO, b.axis, TEST_LOCATION );
+ DALI_TEST_EQUALS( false, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( AngleAxis(), result, TEST_LOCATION );
+
+ Property::Value value2("");
+ DALI_TEST_EQUALS( false, value2.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( AngleAxis(), result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetQuaternionP(void)
{
Property::Value value( Quaternion(1.f,2.f,3.f,4.f) );
+ Quaternion result;
DALI_TEST_EQUALS( Quaternion(1.f,2.f,3.f,4.f), value.Get< Quaternion >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Quaternion(1.f,2.f,3.f,4.f), result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetQuaternionN(void)
{
Property::Value value;
- DALI_TEST_EQUALS( Quaternion::IDENTITY, value.Get< Quaternion >(), TEST_LOCATION );
+ Quaternion result(1.f,2.f,3.f,4.f);
+ DALI_TEST_EQUALS( Quaternion(), value.Get< Quaternion >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( false, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Quaternion(1.f,2.f,3.f,4.f), result, TEST_LOCATION );
+
+ Property::Value value2("");
+ DALI_TEST_EQUALS( false, value2.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( Quaternion(1.f,2.f,3.f,4.f), result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetStringP(void)
{
Property::Value value( std::string("hello") );
+ std::string result;
DALI_TEST_EQUALS( std::string("hello"), value.Get< std::string >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( std::string("hello"), result, TEST_LOCATION );
+
+ Property::Value value2( "C hi!" );
+ DALI_TEST_EQUALS( "C hi!", value2.Get< std::string >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( true, value2.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( "C hi!", result, TEST_LOCATION );
END_TEST;
}
int UtcDaliPropertyValueGetStringN(void)
{
Property::Value value;
- DALI_TEST_EQUALS( std::string(""), value.Get< std::string >(), TEST_LOCATION );
+ std::string result("doesn't change");
+ DALI_TEST_EQUALS( std::string(), value.Get< std::string >(), TEST_LOCATION );
+ DALI_TEST_EQUALS( false, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( "doesn't change", result, TEST_LOCATION );
+
+ Property::Value value2(10);
+ DALI_TEST_EQUALS( false, value2.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( "doesn't change", result, TEST_LOCATION );
+
+ Property::Value value3((char*)NULL);
+ DALI_TEST_EQUALS( true, value3.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( std::string(), result, TEST_LOCATION );
END_TEST;
}
value.GetArray()->PushBack( Property::Value(1) );
Property::Array got = value.Get<Property::Array>();
DALI_TEST_CHECK( got[0].Get<int>() == 1);
+ Property::Array result;
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_CHECK( result[0].Get<int>() == 1);
END_TEST;
}
{
Property::Value value;
DALI_TEST_CHECK( NULL == value.GetArray() );
- Property::Array array;
- array.PushBack( Property::Value( 10 ) );
- value.Get( array );
- DALI_TEST_CHECK( 0 == array.Count() );
+ Property::Array result;
+ result.PushBack( Property::Value( 10 ) );
+ DALI_TEST_EQUALS( false, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( 1, result.Count(), TEST_LOCATION ); // array is not modified
+
+ Property::Value value2("");
+ DALI_TEST_EQUALS( false, value2.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( 1, result.Count(), TEST_LOCATION ); // array is not modified
END_TEST;
}
DALI_TEST_CHECK( NULL == value.GetArray() );
DALI_TEST_CHECK( NULL != value.GetMap() );
value.GetMap()->Insert("key", Property::Value(1));
- Property::Map got = value.Get<Property::Map>();
- DALI_TEST_CHECK(got.Find("key")->Get<int>() == 1);
+ Property::Map result = value.Get<Property::Map>();
+ DALI_TEST_CHECK(result.Find("key")->Get<int>() == 1);
+ DALI_TEST_EQUALS( true, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_CHECK(result.Find("key")->Get<int>() == 1);
END_TEST;
}
{
Property::Value value;
DALI_TEST_CHECK( NULL == value.GetMap() );
- Property::Map map = value.Get<Property::Map>();
- DALI_TEST_CHECK( 0 == map.Count() );
+ DALI_TEST_EQUALS( 0, value.Get<Property::Map>().Count(), TEST_LOCATION );
+ Property::Map result;
+ result.Insert("key", "value" );
+ DALI_TEST_EQUALS( false, value.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( 1, result.Count(), TEST_LOCATION );
+
+ Property::Value value2("");
+ DALI_TEST_EQUALS( false, value2.Get( result ), TEST_LOCATION );
+ DALI_TEST_EQUALS( 1, result.Count(), TEST_LOCATION ); // array is not modified
END_TEST;
}
}
{
- Property::Value empty( Property::TYPE_COUNT );
- std::ostringstream stream;
- stream << empty;
- DALI_TEST_CHECK( stream.str() == "undefined type" )
- }
-
- {
value = Property::Value(20.2f);
std::ostringstream stream;
stream << value;
switch( type )
{
case Property::NONE : // FALLTHROUGH
- case Property::TYPE_COUNT : // FALLTHROUGH
case Property::BOOLEAN : // FALLTHROUGH
case Property::FLOAT : // FALLTHROUGH
case Property::INTEGER : // FALLTHROUGH
}
Property::Value::Value( const char* stringValue )
-: mImpl( new Impl( std::string(stringValue) ) )
+: mImpl( NULL )
{
+ if( stringValue ) // string constructor is undefined with NULL pointer
+ {
+ mImpl = new Impl( std::string(stringValue) );
+ }
+ else
+ {
+ mImpl = new Impl( std::string() );
+ }
}
Property::Value::Value( Property::Array& arrayValue )
{
}
-
-Property::Value::~Value()
-{
- delete mImpl;
-}
-
-Property::Value::Value( const Property::Value& value )
-: mImpl( NULL )
-{
- // reuse assignment operator
- operator=( value );
-}
-
Property::Value::Value( Type type )
{
switch (type)
break;
}
case Property::NONE:
- case Property::TYPE_COUNT:
{
mImpl = new Impl();
break;
}
}
}
+Property::Value::Value( const Property::Value& value )
+: mImpl( NULL )
+{
+ // reuse assignment operator
+ operator=( value );
+}
Property::Value& Property::Value::operator=( const Property::Value& value )
{
}
case Property::VECTOR2:
{
- *mImpl->vector2Value = *value.mImpl->vector2Value;
+ *mImpl->vector2Value = *value.mImpl->vector2Value; // type cannot change in mImpl so vector is allocated
break;
}
case Property::VECTOR3:
{
- *mImpl->vector3Value = *value.mImpl->vector3Value;
+ *mImpl->vector3Value = *value.mImpl->vector3Value; // type cannot change in mImpl so vector is allocated
break;
}
case Property::VECTOR4:
{
- *mImpl->vector4Value = *value.mImpl->vector4Value;
+ *mImpl->vector4Value = *value.mImpl->vector4Value; // type cannot change in mImpl so vector is allocated
break;
}
case Property::RECTANGLE:
{
- *mImpl->rectValue = *value.mImpl->rectValue;
+ *mImpl->rectValue = *value.mImpl->rectValue; // type cannot change in mImpl so rect is allocated
break;
}
case Property::ROTATION:
{
- *mImpl->quaternionValue = *value.mImpl->quaternionValue;
+ *mImpl->quaternionValue = *value.mImpl->quaternionValue; // type cannot change in mImpl so quaternion is allocated
break;
}
case Property::STRING:
{
- *mImpl->stringValue = *value.mImpl->stringValue;
+ *mImpl->stringValue = *value.mImpl->stringValue; // type cannot change in mImpl so string is allocated
break;
}
case Property::MATRIX:
{
- *mImpl->matrixValue = *value.mImpl->matrixValue;
+ *mImpl->matrixValue = *value.mImpl->matrixValue; // type cannot change in mImpl so matrix is allocated
break;
}
case Property::MATRIX3:
{
- *mImpl->matrix3Value = *value.mImpl->matrix3Value;
+ *mImpl->matrix3Value = *value.mImpl->matrix3Value; // type cannot change in mImpl so matrix is allocated
break;
}
case Property::ARRAY:
{
- *mImpl->arrayValue = *value.mImpl->arrayValue;
+ *mImpl->arrayValue = *value.mImpl->arrayValue; // type cannot change in mImpl so array is allocated
break;
}
case Property::MAP:
{
- *mImpl->mapValue = *value.mImpl->mapValue;
+ *mImpl->mapValue = *value.mImpl->mapValue; // type cannot change in mImpl so map is allocated
break;
}
case Property::NONE:
- case Property::TYPE_COUNT:
{ // mImpl will be NULL, there's no way to get to this case
}
}
}
case Property::VECTOR2:
{
- newImpl = new Impl( *value.mImpl->vector2Value );
+ newImpl = new Impl( *value.mImpl->vector2Value ); // type cannot change in mImpl so vector is allocated
break;
}
case Property::VECTOR3:
{
- newImpl = new Impl( *value.mImpl->vector3Value );
+ newImpl = new Impl( *value.mImpl->vector3Value ); // type cannot change in mImpl so vector is allocated
break;
}
case Property::VECTOR4:
{
- newImpl = new Impl( *value.mImpl->vector4Value );
+ newImpl = new Impl( *value.mImpl->vector4Value ); // type cannot change in mImpl so vector is allocated
break;
}
case Property::RECTANGLE:
{
- newImpl = new Impl( *value.mImpl->rectValue );
+ newImpl = new Impl( *value.mImpl->rectValue ); // type cannot change in mImpl so rect is allocated
break;
}
case Property::ROTATION:
{
- newImpl = new Impl( *value.mImpl->quaternionValue );
+ newImpl = new Impl( *value.mImpl->quaternionValue ); // type cannot change in mImpl so quaternion is allocated
break;
}
case Property::MATRIX3:
{
- newImpl = new Impl( *value.mImpl->matrix3Value );
+ newImpl = new Impl( *value.mImpl->matrix3Value ); // type cannot change in mImpl so matrix is allocated
break;
}
case Property::MATRIX:
{
- newImpl = new Impl( *value.mImpl->matrixValue );
+ newImpl = new Impl( *value.mImpl->matrixValue ); // type cannot change in mImpl so matrix is allocated
break;
}
case Property::STRING:
{
- newImpl = new Impl( *value.mImpl->stringValue );
+ newImpl = new Impl( *value.mImpl->stringValue ); // type cannot change in mImpl so string is allocated
break;
}
case Property::ARRAY:
{
- newImpl = new Impl( *value.mImpl->arrayValue );
+ newImpl = new Impl( *value.mImpl->arrayValue ); // type cannot change in mImpl so array is allocated
break;
}
case Property::MAP:
{
- newImpl = new Impl( *value.mImpl->mapValue );
+ newImpl = new Impl( *value.mImpl->mapValue ); // type cannot change in mImpl so map is allocated
break;
}
case Property::NONE:
- case Property::TYPE_COUNT:
{ // NULL value will be used for "empty" value
}
}
return *this;
}
+Property::Value::~Value()
+{
+ delete mImpl;
+}
+
Property::Type Property::Value::GetType() const
{
Property::Type type( Property::NONE );
return type;
}
-void Property::Value::Get( bool& booleanValue ) const
+bool Property::Value::Get( bool& booleanValue ) const
{
+ bool converted = false;
if( mImpl && IsIntegerType( mImpl->type ) )
{
booleanValue = mImpl->integerValue;
+ converted = true;
}
- else
- {
- booleanValue = false;
- }
+ return converted;
}
-void Property::Value::Get( float& floatValue ) const
+bool Property::Value::Get( float& floatValue ) const
{
+ bool converted = false;
if( mImpl && mImpl->type == FLOAT )
{
floatValue = mImpl->floatValue;
+ converted = true;
}
- else
- {
- floatValue = 0.f;
- }
+ return converted;
}
-void Property::Value::Get( int& integerValue ) const
+bool Property::Value::Get( int& integerValue ) const
{
+ bool converted = false;
if( mImpl && IsIntegerType( mImpl->type ) )
{
integerValue = mImpl->integerValue;
+ converted = true;
}
- else
- {
- integerValue = 0;
- }
+ return converted;
}
-void Property::Value::Get( unsigned int& unsignedIntegerValue ) const
+bool Property::Value::Get( unsigned int& unsignedIntegerValue ) const
{
+ bool converted = false;
if( mImpl && IsIntegerType( mImpl->type ) )
{
unsignedIntegerValue = mImpl->unsignedIntegerValue;
+ converted = true;
}
- else
- {
- unsignedIntegerValue = 0u;
- }
+ return converted;
}
-void Property::Value::Get( Vector2& vectorValue ) const
+bool Property::Value::Get( Vector2& vectorValue ) const
{
- if( mImpl && mImpl->type == VECTOR2 && mImpl->vector2Value )
+ bool converted = false;
+ if( mImpl && (mImpl->type == VECTOR2) ) // type cannot change in mImpl so vector is allocated
{
vectorValue = *(mImpl->vector2Value);
+ converted = true;
}
- else
- {
- vectorValue.x = vectorValue.y = 0.f;
- }
+ return converted;
}
-void Property::Value::Get( Vector3& vectorValue ) const
+bool Property::Value::Get( Vector3& vectorValue ) const
{
- if( mImpl && mImpl->type == VECTOR3 && mImpl->vector3Value )
+ bool converted = false;
+ if( mImpl && (mImpl->type == VECTOR3) ) // type cannot change in mImpl so vector is allocated
{
vectorValue = *(mImpl->vector3Value);
+ converted = true;
}
- else
- {
- vectorValue.x = vectorValue.y = vectorValue.z = 0.f;
- }
+ return converted;
}
-void Property::Value::Get( Vector4& vectorValue ) const
+bool Property::Value::Get( Vector4& vectorValue ) const
{
- if( mImpl && mImpl->type == VECTOR4 && mImpl->vector4Value )
+ bool converted = false;
+ if( mImpl && (mImpl->type == VECTOR4) ) // type cannot change in mImpl so vector is allocated
{
vectorValue = *(mImpl->vector4Value);
+ converted = true;
}
- else
- {
- vectorValue.x = vectorValue.y = vectorValue.z = vectorValue.w = 0.f;
- }
+ return converted;
}
-void Property::Value::Get( Matrix3& matrixValue ) const
+bool Property::Value::Get( Matrix3& matrixValue ) const
{
- if( mImpl && mImpl->type == MATRIX3 && mImpl->matrix3Value )
+ bool converted = false;
+ if( mImpl && (mImpl->type == MATRIX3) ) // type cannot change in mImpl so matrix is allocated
{
matrixValue = *(mImpl->matrix3Value);
+ converted = true;
}
- else
- {
- matrixValue.SetIdentity();
- }
+ return converted;
}
-void Property::Value::Get( Matrix& matrixValue ) const
+bool Property::Value::Get( Matrix& matrixValue ) const
{
- if( mImpl && mImpl->type == MATRIX && mImpl->matrixValue )
+ bool converted = false;
+ if( mImpl && (mImpl->type == MATRIX) ) // type cannot change in mImpl so matrix is allocated
{
matrixValue = *(mImpl->matrixValue);
+ converted = true;
}
- else
- {
- matrixValue.SetIdentity();
- }
+ return converted;
}
-void Property::Value::Get( Rect<int>& rectValue ) const
+bool Property::Value::Get( Rect<int>& rectValue ) const
{
- if( mImpl && mImpl->type == RECTANGLE && mImpl->rectValue )
+ bool converted = false;
+ if( mImpl && (mImpl->type == RECTANGLE) ) // type cannot change in mImpl so rect is allocated
{
rectValue = *(mImpl->rectValue);
+ converted = true;
}
- else
- {
- rectValue.x = rectValue.y = rectValue.width = rectValue.height = 0.f;
- }
+ return converted;
}
-void Property::Value::Get( AngleAxis& angleAxisValue ) const
+bool Property::Value::Get( AngleAxis& angleAxisValue ) const
{
- if( mImpl && mImpl->type == ROTATION && mImpl->quaternionValue )
+ bool converted = false;
+ if( mImpl && (mImpl->type == ROTATION) ) // type cannot change in mImpl so quaternion is allocated
{
mImpl->quaternionValue->ToAxisAngle( angleAxisValue.axis, angleAxisValue.angle );
+ converted = true;
}
- else
- {
- angleAxisValue.angle = 0.f;
- angleAxisValue.axis = Vector3::ZERO; // identity quaternion
- }
+ return converted;
}
-void Property::Value::Get( Quaternion& quaternionValue ) const
+bool Property::Value::Get( Quaternion& quaternionValue ) const
{
- if( mImpl && mImpl->type == ROTATION && mImpl->quaternionValue )
+ bool converted = false;
+ if( mImpl && (mImpl->type == ROTATION) ) // type cannot change in mImpl so quaternion is allocated
{
quaternionValue = *(mImpl->quaternionValue);
+ converted = true;
}
- else
- {
- quaternionValue = Quaternion::IDENTITY;
- }
+ return converted;
}
-void Property::Value::Get( std::string& stringValue ) const
+bool Property::Value::Get( std::string& stringValue ) const
{
- if( mImpl && mImpl->type == STRING && mImpl->stringValue )
+ bool converted = false;
+ if( mImpl && (mImpl->type == STRING) ) // type cannot change in mImpl so string is allocated
{
stringValue.assign( *(mImpl->stringValue) );
+ converted = true;
}
- else
- {
- stringValue.clear();
- }
+ return converted;
}
-void Property::Value::Get( Property::Array& arrayValue ) const
+bool Property::Value::Get( Property::Array& arrayValue ) const
{
- if( mImpl && mImpl->type == ARRAY && mImpl->arrayValue )
+ bool converted = false;
+ if( mImpl && (mImpl->type == ARRAY) ) // type cannot change in mImpl so array is allocated
{
arrayValue = *(mImpl->arrayValue);
+ converted = true;
}
- else
- {
- arrayValue.Clear();
- }
+ return converted;
}
-void Property::Value::Get( Property::Map& mapValue ) const
+bool Property::Value::Get( Property::Map& mapValue ) const
{
- if( mImpl && mImpl->type == MAP && mImpl->mapValue )
+ bool converted = false;
+ if( mImpl && (mImpl->type == MAP) ) // type cannot change in mImpl so map is allocated
{
mapValue = *(mImpl->mapValue);
+ converted = true;
}
- else
+ return converted;
+}
+
+Property::Array* Property::Value::GetArray() const
+{
+ Property::Array* array = NULL;
+ if( mImpl && (mImpl->type == ARRAY) ) // type cannot change in mImpl so array is allocated
{
- mapValue.Clear();
+ array = mImpl->arrayValue;
}
+ return array;
}
Property::Map* Property::Value::GetMap() const
{
Property::Map* map = NULL;
- if( mImpl && mImpl->type == MAP && mImpl->mapValue )
+ if( mImpl && (mImpl->type == MAP) ) // type cannot change in mImpl so map is allocated
{
map = mImpl->mapValue;
}
return map;
}
-Property::Array* Property::Value::GetArray() const
-{
- Property::Array* array = NULL;
- if( mImpl && mImpl->type == ARRAY && mImpl->arrayValue )
- {
- array = mImpl->arrayValue;
- }
- return array;
-}
-
std::ostream& operator<<( std::ostream& stream, const Property::Value& value )
{
if( value.mImpl )
break;
}
case Dali::Property::NONE:
- case Dali::Property::TYPE_COUNT:
{
stream << "undefined type";
break;
Value( const char* stringValue );
/**
- * @brief Copy a property value.
- *
- * @param [in] value The property value to copy.
- */
- Value( const Value& value );
-
- /**
* @brief Create an array property value.
*
* @param [in] arrayValue An array
explicit Value( Type type );
/**
+ * @brief Copy constructor
+ *
+ * @param [in] value The property value to copy.
+ */
+ Value( const Value& value );
+
+ /**
* @brief Assign a property value.
*
* @param [in] value The property value to assign from.
/**
* @brief Non-virtual destructor.
+ *
+ * This class is not a base class.
*/
~Value();
/**
* @brief Retrieve a specific value.
*
- * @pre GetType() returns the Property::Type for type T.
+ * Works on a best-effort approach; if value type is not convertible returns a default value of the type
+ *
* @return A value of type T.
*/
template <typename T>
T DALI_INTERNAL Get() const
{
- T temp;
- Get(temp);
+ T temp = T(); // value (zero) initialize
+ Get( temp );
return temp;
}
*
* @pre GetType() returns Property::BOOLEAN.
* @param [out] boolValue On return, a boolean value.
+ * @return true if the value is successfully retrieved, false if the type is not convertible
*/
- void Get( bool& boolValue ) const;
+ bool Get( bool& boolValue ) const;
/**
* @brief Retrieve a floating-point value.
*
* @pre GetType() returns Property::FLOAT.
* @param [out] floatValue On return, a floating-point value.
+ * @return true if the value is successfully retrieved, false if the type is not convertible
*/
- void Get( float& floatValue ) const;
+ bool Get( float& floatValue ) const;
/**
* @brief Retrieve an integer value.
*
* @pre GetType() returns Property::INTEGER.
* @param [out] integerValue On return, an integer value.
+ * @return true if the value is successfully retrieved, false if the type is not convertible
*/
- void Get( int& integerValue ) const;
+ bool Get( int& integerValue ) const;
/**
* @brief Retrieve an unsigned integer value.
*
* @pre GetType() returns Property::UNSIGNED_INTEGER.
* @param [out] unsignedIntegerValue On return, an unsigned integer value.
+ * @return true if the value is successfully retrieved, false if the type is not convertible
*/
- void Get( unsigned int& unsignedIntegerValue ) const;
+ bool Get( unsigned int& unsignedIntegerValue ) const;
/**
* @brief Retrieve an integer rectangle.
*
* @pre GetType() returns Property::RECTANGLE.
* @param [out] rect On return, an integer rectangle.
+ * @return true if the value is successfully retrieved, false if the type is not convertible
*/
- void Get( Rect<int>& rect ) const;
+ bool Get( Rect<int>& rect ) const;
/**
* @brief Retrieve a vector value.
*
* @pre GetType() returns Property::VECTOR2.
* @param [out] vectorValue On return, a vector value.
+ * @return true if the value is successfully retrieved, false if the type is not convertible
*/
- void Get( Vector2& vectorValue ) const;
+ bool Get( Vector2& vectorValue ) const;
/**
* @brief Retrieve a vector value.
*
* @pre GetType() returns Property::VECTOR3.
* @param [out] vectorValue On return, a vector value.
+ * @return true if the value is successfully retrieved, false if the type is not convertible
*/
- void Get( Vector3& vectorValue ) const;
+ bool Get( Vector3& vectorValue ) const;
/**
* @brief Retrieve a vector value.
*
* @pre GetType() returns Property::VECTOR4.
* @param [out] vectorValue On return, a vector value.
+ * @return true if the value is successfully retrieved, false if the type is not convertible
*/
- void Get( Vector4& vectorValue ) const;
+ bool Get( Vector4& vectorValue ) const;
/**
* @brief Retrieve a matrix3 value.
*
* @pre GetType() returns Property::MATRIX3.
* @param [out] matrixValue On return, a matrix3 value.
+ * @return true if the value is successfully retrieved, false if the type is not convertible
*/
- void Get( Matrix3& matrixValue ) const;
+ bool Get( Matrix3& matrixValue ) const;
/**
* @brief Retrieve a matrix value.
*
* @pre GetType() returns Property::MATRIX.
* @param [out] matrixValue On return, a matrix value.
+ * @return true if the value is successfully retrieved, false if the type is not convertible
*/
- void Get( Matrix& matrixValue ) const;
+ bool Get( Matrix& matrixValue ) const;
/**
* @brief Retrieve an angle-axis value.
*
* @pre GetType() returns Property::ROTATION.
* @param [out] angleAxisValue On return, a angle-axis value.
+ * @return true if the value is successfully retrieved, false if the type is not convertible
*/
- void Get( AngleAxis& angleAxisValue ) const;
+ bool Get( AngleAxis& angleAxisValue ) const;
/**
* @brief Retrieve a quaternion value.
*
* @pre GetType() returns Property::ROTATION.
* @param [out] quaternionValue On return, a quaternion value.
+ * @return true if the value is successfully retrieved, false if the type is not convertible
*/
- void Get( Quaternion& quaternionValue ) const;
+ bool Get( Quaternion& quaternionValue ) const;
/**
* @brief Retrieve an string property value.
*
* @pre GetType() returns Property::STRING.
* @param [out] stringValue A string.
+ * @return true if the value is successfully retrieved, false if the type is not convertible
*/
- void Get( std::string& stringValue ) const;
+ bool Get( std::string& stringValue ) const;
/**
* @brief Retrieve an array property value.
*
* @pre GetType() returns Property::ARRAY.
* @param [out] arrayValue The array as a vector Property Values
+ * @return true if the value is successfully retrieved, false if the type is not convertible
*/
- void Get( Property::Array& arrayValue ) const;
+ bool Get( Property::Array& arrayValue ) const;
/**
* @brief Retrieve an map property value.
*
* @pre GetType() returns Property::MAP.
* @param [out] mapValue The map as vector of string and Property Value pairs
+ * @return true if the value is successfully retrieved, false if the type is not convertible
*/
- void Get( Property::Map& mapValue ) const;
+ bool Get( Property::Map& mapValue ) const;
/**
- * @brief return true if this property is a Property::MAP.
+ * @brief Retrieve the Array API of the Property::Value without copying the contents of the map
*
- * @return return true if this property is a Property::MAP
+ * @return the Array API of the Property::Value or NULL if not a Property::Array
*/
- bool IsMap() const
- {
- return GetMap() != NULL;
- }
+ Property::Array* GetArray() const;
/**
* @brief Retrieve the Map API of the Property::Value without copying the contents of the map
Property::Map* GetMap() const;
/**
- * @brief return true if this property is a Property::ARRAY.
- *
- * @return return true if this property is a Property::ARRAY
- */
- bool IsArray() const
- {
- return GetArray() != NULL;
- }
-
- /**
- * @brief Retrieve the Array API of the Property::Value without copying the contents of the map
- *
- * @return the Array API of the Property::Value or NULL if not a Property::Array
- */
- Property::Array* GetArray() const;
-
- /**
* output to stream
*/
friend std::ostream& operator<<( std::ostream& ouputStream, const Property::Value& value );