1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
//
// Copyright (c) 2012 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/**
* @file FSclAddress.cpp
* @brief This is the implementation for Address class.
*
* This file contains definitions of @e Address class.
*/
#include <FBaseString.h>
#include <FSclAddress.h>
#include <FApp_AppInfo.h>
#include <FBaseSysLog.h>
#include "FScl_AddressImpl.h"
using namespace Tizen::App;
using namespace Tizen::Base;
namespace Tizen { namespace Social
{
static const int _MAX_ADDR_COUNTRY_LENGTH_2_0 = 100;
Address::Address(void)
{
__pAddressImpl = new (std::nothrow) _AddressImpl();
SysTryReturnVoidResult(NID_SCL, __pAddressImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
}
Address::Address(const Address& rhs)
{
__pAddressImpl = new (std::nothrow) _AddressImpl(*rhs.__pAddressImpl);
SysTryReturnVoidResult(NID_SCL, __pAddressImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
}
Address::~Address(void)
{
delete __pAddressImpl;
}
Address&
Address::operator =(const Address& rhs)
{
if (this == &rhs)
{
return *this;
}
*__pAddressImpl = *rhs.__pAddressImpl;
return *this;
}
bool
Address::operator ==(const Address& rhs) const
{
return *__pAddressImpl == *rhs.__pAddressImpl;
}
bool
Address::operator !=(const Address& rhs) const
{
return !(*this == rhs);
}
bool
Address::Equals(const Object& rhs) const
{
const Address* pAddress = dynamic_cast<const Address*>(&rhs);
if (pAddress == null)
{
return false;
}
return __pAddressImpl->Equals(*pAddress->__pAddressImpl);
}
int
Address::GetHashCode(void) const
{
return __pAddressImpl->GetHashCode();
}
AddressType
Address::GetType(void) const
{
AddressType type = __pAddressImpl->GetType();
if (type == ADDRESS_TYPE_CUSTOM && (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
{
type = ADDRESS_TYPE_OTHER;
}
return type;
}
String
Address::GetExtended(void) const
{
String extended = __pAddressImpl->GetExtended();
if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
{
if (extended.GetLength() > MAX_ADDR_EXTENDED_LENGTH)
{
extended.SetLength(MAX_ADDR_EXTENDED_LENGTH);
}
}
return extended;
}
String
Address::GetStreet(void) const
{
String street = __pAddressImpl->GetStreet();
if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
{
if (street.GetLength() > MAX_ADDR_STREET_LENGTH)
{
street.SetLength(MAX_ADDR_STREET_LENGTH);
}
}
return street;
}
String
Address::GetCity(void) const
{
String city = __pAddressImpl->GetCity();
if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
{
if (city.GetLength() > MAX_ADDR_CITY_LENGTH)
{
city.SetLength(MAX_ADDR_CITY_LENGTH);
}
}
return city;
}
String
Address::GetState(void) const
{
String state = __pAddressImpl->GetState();
if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
{
if (state.GetLength() > MAX_ADDR_STATE_LENGTH)
{
state.SetLength(MAX_ADDR_STATE_LENGTH);
}
}
return state;
}
String
Address::GetPostalCode(void) const
{
String postalCode = __pAddressImpl->GetPostalCode();
if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
{
if (postalCode.GetLength() > MAX_ADDR_POSTAL_CODE_LENGTH)
{
postalCode.SetLength(MAX_ADDR_POSTAL_CODE_LENGTH);
}
}
return postalCode;
}
String
Address::GetCountry(void) const
{
String country = __pAddressImpl->GetCountry();
if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
{
if (country.GetLength() > _MAX_ADDR_COUNTRY_LENGTH_2_0)
{
country.SetLength(_MAX_ADDR_COUNTRY_LENGTH_2_0);
}
}
return country;
}
String
Address::GetPostOfficeBoxNumber(void) const
{
String postOfficeBoxNumber = __pAddressImpl->GetPostOfficeBoxNumber();
if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
{
if (postOfficeBoxNumber.GetLength() > MAX_ADDR_POBOXNUM_LENGTH)
{
postOfficeBoxNumber.SetLength(MAX_ADDR_POBOXNUM_LENGTH);
}
}
return postOfficeBoxNumber;
}
void
Address::SetType(AddressType type)
{
return __pAddressImpl->SetType(type);
}
result
Address::SetExtended(const String& extended)
{
if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
{
SysTryReturn(NID_SCL, extended.GetLength() <= MAX_ADDR_EXTENDED_LENGTH,
E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the value exceeds MAX_ADDR_EXTENDED_LENGTH.", GetErrorMessage(E_INVALID_ARG));
}
__pAddressImpl->SetExtended(extended);
return E_SUCCESS;
}
result
Address::SetStreet(const String& street)
{
if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
{
SysTryReturn(NID_SCL, street.GetLength() <= MAX_ADDR_STREET_LENGTH,
E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the value exceeds MAX_ADDR_STREET_LENGTH.", GetErrorMessage(E_INVALID_ARG));
}
__pAddressImpl->SetStreet(street);
return E_SUCCESS;
}
result
Address::SetCity(const String& city)
{
if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
{
SysTryReturn(NID_SCL, city.GetLength() <= MAX_ADDR_CITY_LENGTH,
E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the value exceeds MAX_ADDR_CITY_LENGTH.", GetErrorMessage(E_INVALID_ARG));
}
__pAddressImpl->SetCity(city);
return E_SUCCESS;
}
result
Address::SetState(const String& state)
{
if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
{
SysTryReturn(NID_SCL, state.GetLength() <= MAX_ADDR_STATE_LENGTH,
E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the value exceeds MAX_ADDR_STATE_LENGTH.", GetErrorMessage(E_INVALID_ARG));
}
__pAddressImpl->SetState(state);
return E_SUCCESS;
}
result
Address::SetPostalCode(const String& postalCode)
{
if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
{
SysTryReturn(NID_SCL, postalCode.GetLength() <= MAX_ADDR_POSTAL_CODE_LENGTH,
E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the value exceeds MAX_ADDR_POSTAL_CODE_LENGTH.", GetErrorMessage(E_INVALID_ARG));
}
__pAddressImpl->SetPostalCode(postalCode);
return E_SUCCESS;
}
result
Address::SetCountry(const String& country)
{
if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
{
SysTryReturn(NID_SCL, country.GetLength() <= _MAX_ADDR_COUNTRY_LENGTH_2_0,
E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of country exceeds the maximum length.", GetErrorMessage(E_INVALID_ARG));
}
__pAddressImpl->SetCountry(country);
return E_SUCCESS;
}
result
Address::SetPostOfficeBoxNumber(const String& postOfficeBoxNumber)
{
if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
{
SysTryReturn(NID_SCL, postOfficeBoxNumber.GetLength() <= MAX_ADDR_POBOXNUM_LENGTH,
E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The length of the value exceeds MAX_ADDR_POBOXNUM_LENGTH.", GetErrorMessage(E_INVALID_ARG));
}
__pAddressImpl->SetPostOfficeBoxNumber(postOfficeBoxNumber);
return E_SUCCESS;
}
String
Address::GetLabel(void) const
{
return __pAddressImpl->GetLabel();
}
void
Address::SetLabel(const String& label)
{
__pAddressImpl->SetLabel(label);
}
}} //Tizen::Social
|