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_
27 #include <FBaseTypes.h>
28 #include <FBaseColIComparerT.h>
31 namespace Tizen { namespace Base
36 * @brief This class checks for equivalence between 2 values of the same primitive type.
39 * The %ComparerT class checks for equivalence between 2 values of the same primitive type.
41 * The following example demonstrates how to use the %ComparerT class.
47 * using namespace Tizen::Base;
50 * MyClass::ComparerTSample(void)
54 * ComparerT<double> comparer;
56 * // Compares 2 instances of Double
58 * comparer.Compare(d1, d2, cmp);
68 : public virtual Tizen::Base::Collection::IComparerT <Type>
73 * This constructor initializes a new instance of the %ComparerT class.
81 * This destructor overrides Tizen::Base::Object::~Object().
85 virtual ~ComparerT(void) { }
88 * Compares two given instances of the same type.
92 * @return An error code
93 * @param[in] obj1 The first object to compare
94 * @param[in] obj2 The second object to compare
95 * @param[out] cmp The result of comparison
96 * @exception E_SUCCESS The method is successful.
97 * @exception E_INVALID_ARG The specified objects are not of the expected type.
98 * @remarks @c cmp can take one of the following values:
100 * < 0 if the value of @c obj1 is less than the value of @c obj2
101 * == 0 if the value of @c obj1 is equal to the value of @c obj2
102 * > 0 if the value of @c obj1 is greater than the value of @c obj2
105 virtual result Compare(const Type& obj1, const Type& obj2, int& cmp) const
111 else if (obj1 < obj2)
125 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
127 ComparerT(const ComparerT& obj);
130 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
132 ComparerT& operator =(const ComparerT& rhs);
137 class ComparerT <Tizen::Base::String>
138 : public virtual Tizen::Base::Collection::IComparerT <Tizen::Base::String>
143 * This constructor initializes a new instance of the %ComparerT class.
150 * This destructor overrides Tizen::Base::Object::~Object().
154 virtual ~ComparerT(void) { }
157 * Compare two String instances.
161 * @return Always returns E_SUCCESS
162 * @param[in] str1 The String instance to compare
163 * @param[in] str2 The String instance to compare
164 * @param[in] cmp An integer value for result
166 virtual result Compare(const Tizen::Base::String& str1, const Tizen::Base::String& str2, int& cmp) const
168 cmp = String::Compare(str1, str2);
173 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
175 ComparerT(const ComparerT& obj);
178 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
180 ComparerT& operator =(const ComparerT& rhs);
182 }; // ComparerT <Tizen::Base::String>
186 #endif // _FBASE_COMPARER_T_H_