Fix for CompatTC Fail
[framework/osp/social.git] / src / FScl_AddressImpl.cpp
1 //
2 // Copyright (c) 2012 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  * @file                FScl_AddressImpl.cpp
18  * @brief               This is the implementation for _AddressImpl class.
19  *
20  * This file contains definitions of @e _AddressImpl class.
21  */
22
23 #include <FBaseString.h>
24 #include <FBaseSysLog.h>
25 #include <FSclAddress.h>
26 #include <FApp_AppInfo.h>
27 #include "FScl_AddressImpl.h"
28
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31
32 namespace Tizen { namespace Social
33 {
34
35 _AddressImpl::_AddressImpl(void)
36         : __type(ADDRESS_TYPE_HOME)
37 {
38         // empty body.
39 }
40
41 _AddressImpl::_AddressImpl(const _AddressImpl& rhs)
42 {
43         __type = rhs.__type;
44         __label = rhs.__label;
45         __extended = rhs.__extended;
46         __street = rhs.__street;
47         __city = rhs.__city;
48         __state = rhs.__state;
49         __postalCode = rhs.__postalCode;
50         __country = rhs.__country;
51         __postOfficeBoxNumber = rhs.__postOfficeBoxNumber;
52 }
53
54 _AddressImpl::~_AddressImpl(void)
55 {
56         // empty body.
57 }
58
59 _AddressImpl&
60 _AddressImpl::operator =(const _AddressImpl& rhs)
61 {
62         if (this == &rhs)
63         {
64                 return *this;
65         }
66
67         __type = rhs.__type;
68         __label = rhs.__label;
69         __extended = rhs.__extended;
70         __street = rhs.__street;
71         __city = rhs.__city;
72         __state = rhs.__state;
73         __postalCode = rhs.__postalCode;
74         __country = rhs.__country;
75         __postOfficeBoxNumber = rhs.__postOfficeBoxNumber;
76
77         return *this;
78 }
79
80 bool
81 _AddressImpl::operator ==(const _AddressImpl& rhs) const
82 {
83         if ((__type == rhs.__type) &&
84                 (__label == rhs.__label) &&
85                 (__extended == rhs.__extended) &&
86                 (__street == rhs.__street) &&
87                 (__city == rhs.__city) &&
88                 (__state == rhs.__state) &&
89                 (__postalCode == rhs.__postalCode) &&
90                 (__country == rhs.__country) &&
91                 (__postOfficeBoxNumber == rhs.__postOfficeBoxNumber))
92         {
93                 return true;
94         }
95
96         return false;
97 }
98
99 bool
100 _AddressImpl::operator !=(const _AddressImpl& rhs) const
101 {
102         return !(*this == rhs);
103 }
104
105 bool
106 _AddressImpl::Equals(const Object& rhs) const
107 {
108         const _AddressImpl* pAddressImpl = dynamic_cast<const _AddressImpl*>(&rhs);
109
110         if (pAddressImpl == null)
111         {
112                 return false;
113         }
114
115         return (*this == *pAddressImpl);
116 }
117
118 int
119 _AddressImpl::GetHashCode(void) const
120 {
121         int hashCode = 0;
122
123         hashCode = __type;
124         hashCode += __label.GetHashCode();
125         hashCode += __extended.GetHashCode();
126         hashCode += __street.GetHashCode();
127         hashCode += __city.GetHashCode();
128         hashCode += __state.GetHashCode();
129         hashCode += __postalCode.GetHashCode();
130         hashCode += __country.GetHashCode();
131         hashCode += __postOfficeBoxNumber.GetHashCode();
132
133         return hashCode;
134 }
135
136 AddressType
137 _AddressImpl::GetType(void) const
138 {
139         return __type;
140 }
141
142 String
143 _AddressImpl::GetExtended(void) const
144 {
145         return __extended;
146 }
147
148 String
149 _AddressImpl::GetStreet(void) const
150 {
151         return __street;
152 }
153
154 String
155 _AddressImpl::GetCity(void) const
156 {
157         return __city;
158 }
159
160 String
161 _AddressImpl::GetState(void) const
162 {
163         return __state;
164 }
165
166 String
167 _AddressImpl::GetPostalCode(void) const
168 {
169
170         return __postalCode;
171 }
172
173 String
174 _AddressImpl::GetCountry(void) const
175 {
176
177         return __country;
178 }
179
180 String
181 _AddressImpl::GetPostOfficeBoxNumber(void) const
182 {
183         return __postOfficeBoxNumber;
184 }
185
186 void
187 _AddressImpl::SetType(AddressType type)
188 {
189         __type = type;
190 }
191
192 void
193 _AddressImpl::SetExtended(const String& extended)
194 {
195         __extended = extended;
196 }
197
198 void
199 _AddressImpl::SetStreet(const String& street)
200 {
201         __street = street;
202 }
203
204 void
205 _AddressImpl::SetCity(const String& city)
206 {
207         __city = city;
208 }
209
210 void
211 _AddressImpl::SetState(const String& state)
212 {
213         __state = state;
214 }
215
216 void
217 _AddressImpl::SetPostalCode(const String& postalCode)
218 {
219         __postalCode = postalCode;
220 }
221
222 void
223 _AddressImpl::SetCountry(const String& country)
224 {
225         __country = country;
226 }
227
228 void
229 _AddressImpl::SetPostOfficeBoxNumber(const String& postOfficeBoxNumber)
230 {
231         __postOfficeBoxNumber = postOfficeBoxNumber;
232 }
233
234 String
235 _AddressImpl::GetLabel(void) const
236 {
237         return __label;
238 }
239
240 void
241 _AddressImpl::SetLabel(const String& label)
242 {
243         __label = label;
244 }
245
246 bool
247 _AddressImpl::IsEmpty(void) const
248 {
249         if (!__extended.IsEmpty() ||
250                 !__postalCode.IsEmpty() ||
251                 !__postOfficeBoxNumber.IsEmpty() ||
252                 !__state.IsEmpty() ||
253                 !__country.IsEmpty() ||
254                 !__city.IsEmpty() ||
255                 !__street.IsEmpty())
256         {
257                 return false;
258         }
259
260         return true;
261 }
262
263 const _AddressImpl*
264 _AddressImpl::GetInstance(const Address& address)
265 {
266         return address.__pAddressImpl;
267 }
268
269 _AddressImpl*
270 _AddressImpl::GetInstance(Address& address)
271 {
272         return address.__pAddressImpl;
273 }
274
275 }} //Tizen::Social