[Tizen] Add codes for Dali Windows Backend
[platform/core/uifw/dali-core.git] / dali / public-api / object / property-key.cpp
1 /*
2  * Copyright (c) 2016 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 // CLASS HEADER
19 #include <dali/public-api/object/property-key.h>
20
21
22 namespace Dali
23 {
24
25 Property::Key::Key( const std::string& key )
26 : type(Key::STRING),
27   indexKey( Property::INVALID_INDEX ),
28   stringKey( key )
29 {
30 }
31
32 Property::Key::Key( Property::Index key )
33 : type(Key::INDEX),
34   indexKey( key )
35 {
36 }
37
38 bool Property::Key::operator== (const std::string& rhs)
39 {
40   bool result=false;
41   if(type == Key::STRING)
42   {
43     result = (stringKey == rhs);
44   }
45   return result;
46 }
47
48 bool Property::Key::operator== (Property::Index rhs)
49 {
50   bool result=false;
51   if(type == Key::INDEX)
52   {
53     result = (indexKey == rhs);
54   }
55   return result;
56 }
57
58 bool Property::Key::operator== (const Key& rhs)
59 {
60   bool result=false;
61   if(type == Key::STRING && rhs.type == Key::STRING )
62   {
63     result = (stringKey == rhs.stringKey);
64   }
65   else if( type == Key::INDEX && rhs.type == Key::INDEX )
66   {
67     result = (indexKey == rhs.indexKey);
68   }
69   return result;
70 }
71
72 bool Property::Key::operator!= (const std::string& rhs)
73 {
74   return !operator==(rhs);
75 }
76
77 bool Property::Key::operator!= (Property::Index rhs)
78 {
79   return !operator==(rhs);
80 }
81
82 bool Property::Key::operator!= (const Key& rhs)
83 {
84   return !operator==(rhs);
85 }
86
87 std::ostream& operator<<( std::ostream& stream, const Property::Key& key )
88 {
89   if( key.type == Property::Key::INDEX )
90   {
91     stream << key.indexKey;
92   }
93   else
94   {
95     stream << key.stringKey;
96   }
97   return stream;
98 }
99
100 } // namespace Dali