Merge "Added Scaling and cropping properties to the image visual mask" into devel...
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / helpers / property-helper.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // HEADER
19 #include <dali-toolkit/internal/helpers/property-helper.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/property-array.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 namespace Internal
31 {
32
33 bool GetStringFromProperty( const Property::Value& value, std::string& output )
34 {
35   bool extracted = false;
36   if( value.Get( output ) )
37   {
38     extracted = true;
39   }
40   else
41   {
42     Property::Array* array = value.GetArray();
43     if( array )
44     {
45       const unsigned int arraySize = array->Size();
46       for( unsigned int i = 0; i < arraySize; ++i )
47       {
48         std::string element;
49         if( array->GetElementAt( i ).Get( element ) )
50         {
51           extracted = true;
52           output += element + '\n';
53         }
54         else
55         {
56           // If property in array is anything other than a string, then it is invalid so break and clear output.
57           output.clear();
58           extracted = false;
59           break;
60         }
61       }
62     }
63   }
64
65   return extracted;
66 }
67
68 } // namespace Internal
69
70 } // namespace Toolkit
71
72 } // namespace Dali