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 header file for the %UuId class.
22 * This header file contains the declarations of the %UuId class.
24 #ifndef _FBASE_UU_ID_H_
25 #define _FBASE_UU_ID_H_
27 #include <FBaseTypes.h>
28 #include <FBaseObject.h>
29 #include <FBaseString.h>
35 namespace Tizen { namespace Base
39 * @brief This class is the base class of the wrapped UUID types and provides useful operators.
43 * The %UuId class is the base class of the wrapped UUID types and provides useful operators. The UUID consists of 32 hexadecimal 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 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 IDs 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. Furthermore, the method must return the same result as the equality operator.
200 * @see Tizen::Base::Object::GetHashCode()
202 virtual bool Equals(const Object& obj) const;
205 * Gets the hash value of the current instance of %UuId.
209 * @return The integer value equivalent of the hash value of the current instance of %UuId
210 * @remarks Two equal instances must return the same hash value. For better performance,
211 * the used hash function must generate a random distribution for all inputs. @n
212 * The default implementation of this method returns the value of the current instance.
214 virtual int GetHashCode(void) const;
217 * Gets the string representing the value of the current instance when implemented by a class.
221 * @return An instance of the String class with the unicode representation of the value of the current instance @n
222 * If an error such as E_OUT_OF_MEMORY occurs, an empty string is returned.
224 String ToString(void) const;
228 * Gets the UUID of the %UuId instance.
230 * @brief <i> [Deprecated] </i>
231 * @deprecated This method is deprecated as a UUID type is deprecated.
237 UUID ToUUID(void) const;
240 * Parses the specified string representing a %UuId value.
244 * @return An error code
245 * @param[in] str A string representing the %UuId value
246 * @param[out] uuid An instance of %UuId
247 * @exception E_SUCCESS The method is successful.
248 * @exception E_INVALID_ARG The string does not contain an %UuId that can be parsed.
250 * - The format of a string representing a %UuId value is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (For example, 130DF2EC-8233-4975-B03D-F0AD99E3449D).
251 * - This method guarantees that the original value of out-parameter is not changed when the method returns error.
253 static result Parse(const String& str, UuId& uuid);
256 * Generates a new %UuId instance with a random value.
260 * @return A new %UuId instance
262 static UuId* GenerateN(void);
265 * Get a new invalid %UuId instance.
269 * @return A new invalid %UuId instance
271 static UuId GetInvalidUuId(void);
275 * This attribute is pre-defined. Its value is an invalid UUID.
277 * @brief <i> [Deprecated] </i>
278 * @deprecated This object is provided only for backward compatibility and will be deleted in the near future.
279 * Use GetInvalidUuId(void) instead of this object.
283 static const UuId INVALID_UUID;
286 * A byte array of uuid value.
293 static void ConvertToUuId(byte uuid[16]);
295 friend class _UuIdImpl;
296 class _UuIdImpl * __pUuIdImpl;