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.
19 * @brief This is the header file for the %UuId class.
21 * This header file contains the declarations of the %UuId class.
23 #ifndef _FBASE_UU_ID_H_
24 #define _FBASE_UU_ID_H_
26 #include <FBaseTypes.h>
27 #include <FBaseObject.h>
28 #include <FBaseString.h>
34 namespace Tizen { namespace Base
38 * @brief This class is the base class of the wrapped UUID types and provides methods for UUIDs.
42 * The %UuId class is the base class of the wrapped UUID types and provides useful operators. The UUID consists of 32 hexadecimal
43 * digits displayed in 5 groups separated by hyphens to form a total of 36 characters (32 digits and 4 hyphens '-').
45 * It also provides operators for assignment and equality, and methods for parsing, comparing, and generalization.
47 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/base_namespace.htm">Base Guide</a>.
49 * The following example demonstrates how to use the %UuId class.
55 * using namespace Tizen::Base;
58 * MyClass::UuIdSamples(void)
61 * String str(L"A02D0DA1-80A0-4E73-B61F-793263C029EE");
62 * String uuidStr_upper
63 * UuId::Parse(str, uuid); // UuId = A02D0DA1-80A0-4E73-B61F-793263C029EE
65 * String uuidStr = uuid.ToString();
66 * uuidStr.ToUpper(uuidStr_upper);
68 * if (str.Equals(uuidStr_upper))
76 class _OSP_EXPORT_ UuId
81 * This is the default constructor for this class. @n
82 * The %UuId is set to @c 0.
89 * Copying of objects using this copy constructor is allowed.
93 * @param[in] uuid An instance of %UuId
95 UuId(const UuId& uuid);
99 * Initializes an instance of %UuId with the value of the specified UUID.
101 * @brief <i> [Deprecated] </i>
102 * @deprecated This method is deprecated as a UUID type is deprecated.
103 * Instead of using this method, use the UuId(const byte uuid[16]) method.
106 * @param[in] uuid An instance of UUID
109 UuId(const UUID& uuid);
112 * Initializes an instance of %UuId with the specified uuid value.
116 * @param[in] uuid A byte array of uuid value
118 UuId(const byte uuid[16]);
121 * This destructor overrides Tizen::Base::Object::~Object().
129 * Checks whether the specified instance of %UuId is equal to the specified UUID.
131 * @brief <i> [Deprecated] </i>
132 * @deprecated This method is deprecated as a UUID type is deprecated.
135 * @return @c true if the UUID and the %UuId instance are equal, @n
137 * @param[in] uuid1 An instance of UUID
138 * @param[in] uuid2 An instance of %UuId
141 _OSP_EXPORT_ friend bool operator ==(const UUID& uuid1, const UuId& uuid2);
144 * Checks whether the current instance of %UuId is equal to the specified instance of %UuId.
148 * @return @c true if the two instances are equal, @n
150 * @param[in] uuid An instance of %UuId
152 bool operator ==(const UuId& uuid) const;
156 * Checks whether the specified instance of %UuId is not equal to the specified UUID.
158 * @brief <i> [Deprecated] </i>
159 * @deprecated This method is deprecated as a UUID type is deprecated.
162 * @return @c true if the two IDs are not equal, @n
164 * @param[in] uuid1 An instance of UUID
165 * @param[in] uuid2 An instance of %UuId
168 _OSP_EXPORT_ friend bool operator !=(const UUID& uuid1, const UuId& uuid2);
171 * Checks whether the current instance of %UuId is not equal to the specified instance of %UuId.
175 * @return @c true if the two IDs are not equal, @n
177 * @param[in] uuid An instance of %UuId
179 bool operator !=(const UuId& uuid) const;
182 * Assigns the value of the specified instance to the current instance of %UuId.
186 * @return A reference to the current instance
187 * @param[in] uuid An instance of %UuId
189 UuId& operator =(const UuId& uuid);
192 * Checks whether the specified instance of Object is equal to the current instance of %UuId.
196 * @return @c true if the specified instance of Object is equal to the current instance of %UuId, @n
198 * @param[in] obj An instance of Object to compare
199 * @remarks This method can be overridden to support value equality. @n
200 * Furthermore, the method must return the same result
201 * as the equality operator.
202 * @see Tizen::Base::Object::GetHashCode()
204 virtual bool Equals(const Object& obj) const;
207 * Gets the hash value of the current instance of %UuId.
211 * @return The integer value equivalent of the hash value of the current instance of %UuId
213 * - Two equal instances must return the same hash value. @n
214 * For better performance, the used hash function must
215 * generate a random distribution for all inputs.
216 * - The default implementation of this method returns the value of the current instance.
218 virtual int GetHashCode(void) const;
221 * Gets the string representing the value of the current instance.
225 * @return An instance of the String class with the unicode representation of the value of the current instance, @n
226 * else an empty string if an error such as @c E_OUT_OF_MEMORY occurs
228 String ToString(void) const;
232 * Gets the UUID of the %UuId instance.
234 * @brief <i> [Deprecated] </i>
235 * @deprecated This method is deprecated as a UUID type is deprecated.
241 UUID ToUUID(void) const;
244 * Parses the specified string representing a %UuId value.
248 * @return An error code
249 * @param[in] str A string representing the %UuId value
250 * @param[out] uuid An instance of %UuId
251 * @exception E_SUCCESS The method is successful.
252 * @exception E_INVALID_ARG The string does not contain an %UuId that can be parsed.
254 * - The format of a string representing a %UuId value is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (For example, 130DF2EC-8233-4975-B03D-F0AD99E3449D).
255 * - This method guarantees that the original value of out-parameter is not changed when the method returns an error.
257 static result Parse(const String& str, UuId& uuid);
260 * Generates a new %UuId instance with a random value.
264 * @return A new %UuId instance
266 static UuId* GenerateN(void);
269 * Gets a new invalid %UuId instance.
273 * @return A new invalid %UuId instance
275 static UuId GetInvalidUuId(void);
279 * This attribute is pre-defined. Its value is an invalid UUID.
281 * @brief <i> [Deprecated] </i>
282 * @deprecated This object is provided only for backward compatibility and will be deleted in the near future.
283 * Use GetInvalidUuId(void) instead of this object.
287 static const UuId INVALID_UUID;
290 * A byte array of the uuid value.
297 static void ConvertToUuId(byte uuid[16]);
299 friend class _UuIdImpl;
300 class _UuIdImpl * __pUuIdImpl;