2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file FScl_PhoneNumberImpl.cpp
18 * @brief This is the implementation for _PhoneNumberImpl class.
20 * This file contains definitions of @e _PhoneNumberImpl class.
23 #include <unique_ptr.h>
24 #include <FSclPhoneNumber.h>
25 #include <FBaseSysLog.h>
26 #include <FBase_StringConverter.h>
27 #include "FScl_PhoneNumberImpl.h"
29 using namespace Tizen::Base;
31 namespace Tizen { namespace Social
34 _PhoneNumberImpl::_PhoneNumberImpl(void)
36 , __type(PHONENUMBER_TYPE_HOME)
41 _PhoneNumberImpl::_PhoneNumberImpl(PhoneNumberType type, const String& number)
49 _PhoneNumberImpl::_PhoneNumberImpl(const _PhoneNumberImpl& rhs)
51 __recordId = rhs.__recordId;
53 __label = rhs.__label;
54 __number = rhs.__number;
57 _PhoneNumberImpl::~_PhoneNumberImpl(void)
63 _PhoneNumberImpl::operator =(const _PhoneNumberImpl& rhs)
70 __recordId = rhs.__recordId;
72 __label = rhs.__label;
73 __number = rhs.__number;
79 _PhoneNumberImpl::operator ==(const _PhoneNumberImpl& rhs) const
81 if (__type != rhs.__type || __label != rhs.__label || __number != rhs.__number)
90 _PhoneNumberImpl::Equals(const Object& rhs) const
92 const _PhoneNumberImpl* pPhoneNumberImpl = dynamic_cast<const _PhoneNumberImpl*>(&rhs);
94 if (pPhoneNumberImpl == null)
99 return (*this == *pPhoneNumberImpl);
103 _PhoneNumberImpl::GetHashCode(void) const
105 int hashCode = __recordId;
107 hashCode += __number.GetHashCode();
108 hashCode += __label.GetHashCode();
114 _PhoneNumberImpl::operator !=(const _PhoneNumberImpl& rhs) const
116 return !(*this == rhs);
120 _PhoneNumberImpl::GetType(void) const
126 _PhoneNumberImpl::GetPhoneNumber(void) const
132 _PhoneNumberImpl::SetType(PhoneNumberType type)
138 _PhoneNumberImpl::SetPhoneNumber(const String& number)
140 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));
148 _PhoneNumberImpl::SetLabel(const String& label)
154 _PhoneNumberImpl::GetLabel(void) const
160 _PhoneNumberImpl::SetRecordId(int recordId)
162 __recordId = recordId;
166 _PhoneNumberImpl::GetRecordId(void) const
172 _PhoneNumberImpl::IsEmpty(void) const
174 return __number.IsEmpty();
178 _PhoneNumberImpl::GetInstance(PhoneNumber& phoneNumber)
180 return phoneNumber.__pPhoneNumberImpl;
183 const _PhoneNumberImpl*
184 _PhoneNumberImpl::GetInstance(const PhoneNumber& phoneNumber)
186 return phoneNumber.__pPhoneNumberImpl;