2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FScl_PhoneNumberImpl.cpp
19 * @brief This is the implementation for _PhoneNumberImpl class.
21 * This file contains definitions of @e _PhoneNumberImpl class.
24 #include <unique_ptr.h>
25 #include <FSclPhoneNumber.h>
26 #include <FBaseSysLog.h>
27 #include <FBase_StringConverter.h>
28 #include "FScl_PhoneNumberImpl.h"
30 using namespace Tizen::Base;
32 namespace Tizen { namespace Social
35 _PhoneNumberImpl::_PhoneNumberImpl(void)
37 , __type(PHONENUMBER_TYPE_HOME)
42 _PhoneNumberImpl::_PhoneNumberImpl(PhoneNumberType type, const String& number)
50 _PhoneNumberImpl::_PhoneNumberImpl(const _PhoneNumberImpl& rhs)
52 __recordId = rhs.__recordId;
54 __label = rhs.__label;
55 __number = rhs.__number;
58 _PhoneNumberImpl::~_PhoneNumberImpl(void)
64 _PhoneNumberImpl::operator =(const _PhoneNumberImpl& rhs)
71 __recordId = rhs.__recordId;
73 __label = rhs.__label;
74 __number = rhs.__number;
80 _PhoneNumberImpl::operator ==(const _PhoneNumberImpl& rhs) const
82 if (__type != rhs.__type || __label != rhs.__label || __number != rhs.__number)
91 _PhoneNumberImpl::Equals(const Object& rhs) const
93 const _PhoneNumberImpl* pPhoneNumberImpl = dynamic_cast<const _PhoneNumberImpl*>(&rhs);
95 if (pPhoneNumberImpl == null)
100 return (*this == *pPhoneNumberImpl);
104 _PhoneNumberImpl::GetHashCode(void) const
106 int hashCode = __recordId;
108 hashCode += __number.GetHashCode();
109 hashCode += __label.GetHashCode();
115 _PhoneNumberImpl::operator !=(const _PhoneNumberImpl& rhs) const
117 return !(*this == rhs);
121 _PhoneNumberImpl::GetType(void) const
127 _PhoneNumberImpl::GetPhoneNumber(void) const
133 _PhoneNumberImpl::SetType(PhoneNumberType type)
139 _PhoneNumberImpl::SetPhoneNumber(const String& number)
141 SysTryReturn(NID_SCL, !number.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The phone number is empty.", GetErrorMessage(E_INVALID_ARG));
149 _PhoneNumberImpl::SetLabel(const String& label)
155 _PhoneNumberImpl::GetLabel(void) const
161 _PhoneNumberImpl::SetRecordId(int recordId)
163 __recordId = recordId;
167 _PhoneNumberImpl::GetRecordId(void) const
173 _PhoneNumberImpl::IsEmpty(void) const
175 return __number.IsEmpty();
179 _PhoneNumberImpl::GetInstance(PhoneNumber& phoneNumber)
181 return phoneNumber.__pPhoneNumberImpl;
184 const _PhoneNumberImpl*
185 _PhoneNumberImpl::GetInstance(const PhoneNumber& phoneNumber)
187 return phoneNumber.__pPhoneNumberImpl;