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.
20 * @brief This is the implementation file for Boolean class.
23 #include <FBaseBoolean.h>
24 #include <FBaseResult.h>
27 namespace Tizen { namespace Base
30 Boolean::Boolean(bool value)
32 , __pBooleanImpl(null)
36 Boolean::Boolean(const Boolean& value)
38 , __pBooleanImpl(null)
42 Boolean::Boolean(const String& value)
44 const String trueString = L"true";
47 value.ToLower(lowString);
49 if (lowString.Equals(trueString))
58 __pBooleanImpl = null;
61 Boolean::~Boolean(void)
66 Boolean::operator ==(const Boolean& rhs) const
68 return(value == rhs.value);
72 Boolean::operator !=(const Boolean& rhs) const
74 return(value != rhs.value);
78 Boolean::operator =(const Boolean& rhs)
89 Boolean::Equals(const Object& obj) const
91 const Boolean* pOther = dynamic_cast <const Boolean*>(&obj);
97 return *this == *pOther;
101 Boolean::GetHashCode(void) const
103 return static_cast<int> (value);
107 Boolean::Equals(bool value) const
109 return this->value == value;
113 Boolean::ToBool(void) const
119 Boolean::Parse(const String& s)
121 const String trueString = L"true";
122 if (s.Equals(trueString))
131 Boolean::Parse(const String& s, bool caseSensitive)
133 const String trueString = L"true";
137 if (s.Equals(trueString))
144 int len = s.GetLength();
145 int trueLen = trueString.GetLength();
147 result r = E_SUCCESS;
156 r = s.ToLower(lowString);
157 if (!lowString.Equals(trueString))
169 Boolean::ToString(void) const
171 return(Boolean::ToString(value));
175 Boolean::ToString(bool value)
192 Boolean::GetTrue(void)
194 static const Boolean True(true);
199 Boolean::GetFalse(void)
201 static const Boolean False(false);