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 useful operators.
42 * 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 '-').
44 * It also provides operators for assignment and equality, and methods for parsing, comparing, and generalization.
46 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/base/base_namespace.htm">Base Guide</a>.
48 * The following example demonstrates how to use the %UuId class.
54 * using namespace Tizen::Base;
57 * MyClass::UuIdSamples(void)
60 * String str(L"A02D0DA1-80A0-4E73-B61F-793263C029EE");
61 * String uuidStr_upper
62 * UuId::Parse(str, uuid); // UuId = A02D0DA1-80A0-4E73-B61F-793263C029EE
64 * String uuidStr = uuid.ToString();
65 * uuidStr.ToUpper(uuidStr_upper);
67 * if (str.Equals(uuidStr_upper))
75 class _OSP_EXPORT_ UuId
80 * This is the default constructor for this class. @n
81 * The %UuId is set to @c 0.
88 * Copying of objects using this copy constructor is allowed.
92 * @param[in] uuid An instance of %UuId
94 UuId(const UuId& uuid);
98 * Initializes an instance of %UuId with the value of the specified UUID.
100 * @brief <i> [Deprecated] </i>
101 * @deprecated This method is deprecated as a UUID type is deprecated.
102 * Instead of using this method, use the UuId(const byte uuid[16]) method.
105 * @param[in] uuid An instance of UUID
108 UuId(const UUID& uuid);
111 * Initializes an instance of %UuId with the uuid value.
115 * @param[in] uuid A byte array of uuid value
117 UuId(const byte uuid[16]);
120 * This destructor overrides Tizen::Base::Object::~Object().
128 * Checks whether the specified instance of %UuId is equal to the specified UUID.
130 * @brief <i> [Deprecated] </i>
131 * @deprecated This method is deprecated as a UUID type is deprecated.
134 * @return @c true if the UUID and the %UuId instance are equal, @n
136 * @param[in] uuid1 An instance of UUID
137 * @param[in] uuid2 An instance of %UuId
140 _OSP_EXPORT_ friend bool operator ==(const UUID& uuid1, const UuId& uuid2);
143 * Checks whether the current instance of %UuId is equal to the specified instance of %UuId.
147 * @return @c true if the two IDs are equal, @n
149 * @param[in] uuid An instance of %UuId
151 bool operator ==(const UuId& uuid) const;
155 * Checks whether the specified instance of %UuId is not equal to the specified UUID.
157 * @brief <i> [Deprecated] </i>
158 * @deprecated This method is deprecated as a UUID type is deprecated.
161 * @return @c true if the two IDs are not equal, @n
163 * @param[in] uuid1 An instance of UUID
164 * @param[in] uuid2 An instance of %UuId
167 _OSP_EXPORT_ friend bool operator !=(const UUID& uuid1, const UuId& uuid2);
170 * Checks whether the current instance of %UuId is not equal to the specified instance of %UuId.
174 * @return @c true if the two IDs are not equal, @n
176 * @param[in] uuid An instance of %UuId
178 bool operator !=(const UuId& uuid) const;
181 * Assigns the value of the specified instance to the current instance of %UuId.
185 * @return A reference to the current instance
186 * @param[in] uuid An instance of %UuId
188 UuId& operator =(const UuId& uuid);
191 * Checks whether the specified instance of Object is equal to the current instance of %UuId.
195 * @return @c true if the specified instance of Object is equal to the current instance of %UuId, @n
197 * @param[in] obj An instance of Object to compare
198 * @remarks This method can be overridden to support value equality. Furthermore, the method must return the same result as the equality operator.
199 * @see Tizen::Base::Object::GetHashCode()
201 virtual bool Equals(const Object& obj) const;
204 * Gets the hash value of the current instance of %UuId.
208 * @return The integer value equivalent of the hash value of the current instance of %UuId
209 * @remarks Two equal instances must return the same hash value. For better performance,
210 * the used hash function must generate a random distribution for all inputs. @n
211 * The default implementation of this method returns the value of the current instance.
213 virtual int GetHashCode(void) const;
216 * Gets the string representing the value of the current instance when implemented by a class.
220 * @return An instance of the String class with the unicode representation of the value of the current instance @n
221 * If an error such as E_OUT_OF_MEMORY occurs, an empty string is returned.
223 String ToString(void) const;
227 * Gets the UUID of the %UuId instance.
229 * @brief <i> [Deprecated] </i>
230 * @deprecated This method is deprecated as a UUID type is deprecated.
236 UUID ToUUID(void) const;
239 * Parses the specified string representing a %UuId value.
243 * @return An error code
244 * @param[in] str A string representing the %UuId value
245 * @param[out] uuid An instance of %UuId
246 * @exception E_SUCCESS The method is successful.
247 * @exception E_INVALID_ARG The string does not contain an %UuId that can be parsed.
249 * - The format of a string representing a %UuId value is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (For example, 130DF2EC-8233-4975-B03D-F0AD99E3449D).
250 * - This method guarantees that the original value of out-parameter is not changed when the method returns error.
252 static result Parse(const String& str, UuId& uuid);
255 * Generates a new %UuId instance with a random value.
259 * @return A new %UuId instance
261 static UuId* GenerateN(void);
264 * Get a new invalid %UuId instance.
268 * @return A new invalid %UuId instance
270 static UuId GetInvalidUuId(void);
274 * This attribute is pre-defined. Its value is an invalid UUID.
276 * @brief <i> [Deprecated] </i>
277 * @deprecated This object is provided only for backward compatibility and will be deleted in the near future.
278 * Use GetInvalidUuId(void) instead of this object.
282 static const UuId INVALID_UUID;
285 * A byte array of uuid value.
292 static void ConvertToUuId(byte uuid[16]);
294 friend class _UuIdImpl;
295 class _UuIdImpl * __pUuIdImpl;