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