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.
18 * @file FBaseComparerT.h
19 * @brief This is the header file for the %ComparerT class.
21 * This file contains declarations of the %ComparerT class.
23 #ifndef _FBASE_COMPARER_T_H_
24 #define _FBASE_COMPARER_T_H_
26 #include <FBaseTypes.h>
27 #include <FBaseColIComparerT.h>
29 namespace Tizen { namespace Base
34 * @brief This class checks for equivalence between two values of the same primitive type.
37 * The %ComparerT class checks for equivalence between two values of the same primitive type.
39 * The following example demonstrates how to use the %ComparerT class.
45 * using namespace Tizen::Base;
48 * MyClass::ComparerTSample(void)
52 * ComparerT<double> comparer;
54 * // Compares 2 instances of Double
56 * comparer.Compare(d1, d2, cmp);
64 template< class Type >
66 : public virtual Tizen::Base::Collection::IComparerT< Type >
71 * This constructor initializes a new instance of the %ComparerT class.
79 * This destructor overrides Tizen::Base::Object::~Object().
83 virtual ~ComparerT(void) { }
86 * Compares two given instances of the same type.
90 * @return An error code
91 * @param[in] obj1 The first object to compare
92 * @param[in] obj2 The second object to compare
93 * @param[out] cmp The result of the comparison
94 * @exception E_SUCCESS The method is successful.
95 * @exception E_INVALID_ARG The specified objects are not of the expected type.
96 * @remarks @c cmp can take one of the following values:
98 * < 0 if the value of obj1 is less than the value of obj2
99 * == 0 if the value of obj1 is equal to the value of obj2
100 * > 0 if the value of obj1 is greater than the value of obj2
103 virtual result Compare(const Type& obj1, const Type& obj2, int& cmp) const
109 else if (obj1 < obj2)
123 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
125 ComparerT(const ComparerT& obj);
128 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
130 ComparerT& operator =(const ComparerT& rhs);
135 class ComparerT< Tizen::Base::String >
136 : public virtual Tizen::Base::Collection::IComparerT< Tizen::Base::String >
141 * This constructor initializes a new instance of the %ComparerT class.
148 * This destructor overrides Tizen::Base::Object::~Object().
152 virtual ~ComparerT(void) { }
155 * Compares two String instances.
159 * @return Always returns @c E_SUCCESS
160 * @param[in] str1 The String instance to compare
161 * @param[in] str2 The String instance to compare
162 * @param[in] cmp The integer value for the result
164 virtual result Compare(const Tizen::Base::String& str1, const Tizen::Base::String& str2, int& cmp) const
166 cmp = String::Compare(str1, str2);
171 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
173 ComparerT(const ComparerT& obj);
176 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
178 ComparerT& operator =(const ComparerT& rhs);
180 }; // ComparerT <Tizen::Base::String>
184 #endif // _FBASE_COMPARER_T_H_