2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 %Variant class.
22 * This header file contains the declarations of the %Variant class.
24 #ifndef _FUI_VARIANT_H_
25 #define _FUI_VARIANT_H_
27 #include <FBaseDataType.h>
28 #include <FBaseObject.h>
30 namespace Tizen { namespace Base
35 namespace Tizen { namespace Graphics
47 namespace Tizen { namespace Ui
55 * Defines the types which %Variant can hold.
61 VARIANT_TYPE_NONE = 0, /**< The type for invalid variant */
62 VARIANT_TYPE_INT, /**< The @c int type */
63 VARIANT_TYPE_UINT, /**< The unsigned @c int type */
64 VARIANT_TYPE_BOOL, /**< The @c bool type */
65 VARIANT_TYPE_FLOAT, /**< The @c float type */
66 VARIANT_TYPE_DOUBLE, /**< The @c double type */
67 VARIANT_TYPE_LONG, /**< The @c long type */
68 VARIANT_TYPE_ULONG, /**< The unsigned @c long type */
69 VARIANT_TYPE_LONGLONG, /**< The @c long @c long type */
70 VARIANT_TYPE_ULONGLONG, /**< The unsigned @c long @c long type */
71 VARIANT_TYPE_STRING, /**< The String type */
72 VARIANT_TYPE_DATETIME, /**< The DateTime type */
73 VARIANT_TYPE_COLOR, /**< The Color type */
74 VARIANT_TYPE_POINT, /**< The Point type */
75 VARIANT_TYPE_FLOAT_POINT, /**< The FloatPoint type */
76 VARIANT_TYPE_RECTANGLE, /**< The Rectangle type */
77 VARIANT_TYPE_FLOAT_RECTANGLE, /**< The FloatRectangle type */
78 VARIANT_TYPE_DIMENSION, /**< The Dimension type */
79 VARIANT_TYPE_FLOAT_DIMENSION, /**< The FloatDimension type */
80 VARIANT_TYPE_FLOAT_MATRIX4 /**< The FloatMatrix4 type */
85 * @brief This class abstracts a %Variant value.
89 * The %Variant class represents a %Variant type which can hold any of the basic type values.
92 class _OSP_EXPORT_ Variant
93 : public Tizen::Base::Object
97 * This is the default constructor for this class.
104 * This is the copy constructor for the %Variant class.
108 * @param[in] value A reference to the %Variant instance to copy
110 Variant(const Variant& value);
113 * Initializes this instance of %Variant with the specified @c int value.
117 * @param[in] value An @c int value
122 * Initializes this instance of %Variant with the specified unsigned @c int value.
126 * @param[in] value An unsigned @c int value
128 Variant(unsigned int value);
131 * Initializes this instance of %Variant with the specified bool value.
135 * @param[in] value A bool value
140 * Initializes this instance of %Variant with the specified @c float value.
144 * @param[in] value A @c float value
146 Variant(float value);
149 * Initializes this instance of %Variant with the specified @c double value.
153 * @param[in] value A @c double value
155 Variant(double value);
158 * Initializes this instance of %Variant with the specified @c long value.
162 * @param[in] value A @c long value
167 * Initializes this instance of %Variant with the specified unsigned @c long value.
171 * @param[in] value An unsigned @c long value
173 Variant(unsigned long value);
176 * Initializes this instance of %Variant with the specified @c long @c long value.
180 * @param[in] value A @c long @c long value
182 Variant(long long value);
185 * Initializes this instance of %Variant with the specified unsigned @c long @c long value.
189 * @param[in] value An unsigned @c long @c long value
191 Variant(unsigned long long value);
194 * Initializes this instance of %Variant with the specified array of characters.
198 * @param[in] pValue An array of characters value
200 Variant(const char* pValue);
203 * Initializes this instance of %Variant with the specified array of Unicode characters.
207 * @param[in] pValue An array of Unicode characters value
209 Variant(const wchar_t* pValue);
212 * Initializes this instance of %Variant with the specified unsigned string value.
216 * @param[in] value An unsigned string value
218 Variant(const Tizen::Base::String& value);
221 * Initializes this instance of %Variant with the specified unsigned datetime value.
225 * @param[in] value An unsigned datetime value
227 Variant(const Tizen::Base::DateTime& value);
230 * Initializes this instance of %Variant with the specified unsigned color value.
234 * @param[in] value An unsigned color value
236 Variant(const Tizen::Graphics::Color& value);
239 * Initializes this instance of %Variant with the specified unsigned point value.
243 * @param[in] value An unsigned point value
245 Variant(const Tizen::Graphics::Point& value);
248 * Initializes this instance of %Variant with the specified floatpoint value.
252 * @param[in] value A floatpoint value
254 Variant(const Tizen::Graphics::FloatPoint& value);
257 * Initializes this instance of %Variant with the specified rectangle value.
261 * @param[in] value A rectangle value
263 Variant(const Tizen::Graphics::Rectangle& value);
266 * Initializes this instance of %Variant with the specified float-rectangle value.
270 * @param[in] value A float-rectangle value
272 Variant(const Tizen::Graphics::FloatRectangle& value);
275 * Initializes this instance of %Variant with the specified dimension value.
279 * @param[in] value A dimension value
281 Variant(const Tizen::Graphics::Dimension& value);
284 * Initializes this instance of %Variant with the specified float-dimension value.
288 * @param[in] value A float-dimension value
290 Variant(const Tizen::Graphics::FloatDimension& value);
293 * Initializes this instance of %Variant with the specified float-matrix4 value.
297 * @param[in] value A float-matrix4 value
299 Variant(const Tizen::Graphics::FloatMatrix4& value);
302 * This is the destructor for this class.
306 virtual ~Variant(void);
309 * Assigns the value of the specified instance to the current instance of %Variant.
313 * @return A reference to the %Variant instance
314 * @param[in] rhs An instance of %Variant to copy
316 Variant& operator =(const Variant& rhs);
319 * Assigns the value of the specified instance to the current instance of %Variant.
323 * @return A reference to the %Variant instance
324 * @param[in] rhs An @c int value
326 Variant& operator =(int rhs);
329 * Assigns the value of the specified instance to the current instance of %Variant.
333 * @return A reference to the %Variant instance
334 * @param[in] rhs An unsigned @c int value
337 Variant& operator =(unsigned int rhs);
340 * Assigns the value of the specified instance to the current instance of %Variant.
343 * @return A reference to the %Variant instance
344 * @param[in] rhs A @c bool value
347 Variant& operator =(bool rhs);
350 * Assigns the value of the specified instance to the current instance of %Variant.
354 * @return A reference to the %Variant instance
355 * @param[in] rhs A @c float value
358 Variant& operator =(float rhs);
361 * Assigns the value of the specified instance to the current instance of %Variant.
365 * @return A reference to the %Variant instance
366 * @param[in] rhs A @c double value
369 Variant& operator =(double rhs);
372 * Assigns the value of the specified instance to the current instance of %Variant.
376 * @return A reference to the %Variant instance
377 * @param[in] rhs A @c long value
380 Variant& operator =(long rhs);
383 * Assigns the value of the specified instance to the current instance of %Variant.
387 * @return A reference to the %Variant instance
388 * @param[in] rhs An unsigned @c long value
391 Variant& operator =(unsigned long rhs);
394 * Assigns the value of the specified instance to the current instance of %Variant.
398 * @return A reference to the %Variant instance
399 * @param[in] rhs A @c long @c long value
402 Variant& operator =(long long rhs);
405 * Assigns the value of the specified instance to the current instance of %Variant.
408 * @return A reference to the %Variant instance
409 * @param[in] rhs An unsigned @c long @c long value
412 Variant& operator =(unsigned long long rhs);
415 * Assigns the value of the pointer to the current instance of %Variant.
419 * @return A reference to the %Variant instance
420 * @param[in] pRhs A pointer to an array of characters
423 Variant& operator =(const char* pRhs);
426 * Assigns the value of the pointer to the current instance of %Variant.
430 * @return A reference to the %Variant instance
431 * @param[in] pRhs A pointer to an array of Unicode characters
434 Variant& operator =(const wchar_t* pRhs);
437 * Assigns the value of the specified instance of Tizen::Base::String to the current instance of %Variant.
441 * @return A reference to the %Variant instance
442 * @param[in] rhs An instance of Tizen::Base::String
444 Variant& operator =(const Tizen::Base::String& rhs);
447 * Assigns the value of the specified instance of Tizen::Base::DateTime to the current instance of %Variant.
451 * @return A reference to the %Variant instance
452 * @param[in] rhs An instance of Tizen::Base::DateTime
454 Variant& operator =(const Tizen::Base::DateTime& rhs);
457 * Assigns the value of the specified instance of Tizen::Graphics::Color to the current instance of %Variant.
460 * @return A reference to the %Variant instance
461 * @param[in] rhs An instance of Tizen::Graphics::Color
463 Variant& operator =(const Tizen::Graphics::Color& rhs);
466 * Assigns the value of the specified instance of Tizen::Graphics::Point to the current instance of %Variant.
469 * @return A reference to the %Variant instance
470 * @param[in] rhs An instance of Tizen::Graphics::Point
472 Variant& operator =(const Tizen::Graphics::Point& rhs);
475 * Assigns the value of the specified instance of Tizen::Graphics::FloatPoint to the current instance of %Variant.
478 * @return A reference to the %Variant instance
479 * @param[in] rhs An instance of Tizen::Graphics::FloatPoint
481 Variant& operator =(const Tizen::Graphics::FloatPoint& rhs);
484 * Assigns the value of the specified instance of Tizen::Graphics::Rectangle to the current instance of %Variant.
487 * @return A reference to the %Variant instance
488 * @param[in] rhs An instance of Tizen::Graphics::Rectangle
490 Variant& operator =(const Tizen::Graphics::Rectangle& rhs);
493 * Assigns the value of the specified instance of Tizen::Graphics::FloatRectangle to the current instance of %Variant.
496 * @return A reference to the %Variant instance
497 * @param[in] rhs An instance of Tizen::Graphics::FloatRectangle
499 Variant& operator =(const Tizen::Graphics::FloatRectangle& rhs);
502 * Assigns the value of the specified instance of Tizen::Graphics::Dimension to the current instance of %Variant.
505 * @return A reference to the %Variant instance
506 * @param[in] rhs An instance of Tizen::Graphics::Dimension
508 Variant& operator =(const Tizen::Graphics::Dimension& rhs);
511 * Assigns the value of the specified instance of Tizen::Graphics::FloatDimension to the current instance of %Variant.
514 * @return A reference to the %Variant instance
515 * @param[in] rhs An instance of Tizen::Graphics::FloatDimension
517 Variant& operator =(const Tizen::Graphics::FloatDimension& rhs);
520 * Assigns the value of the specified instance of Tizen::Graphics::FloatMatrix4 to the current instance of %Variant.
523 * @return A reference to the %Variant instance
524 * @param[in] rhs An instance of Tizen::Graphics::FloatMatrix4
526 Variant& operator =(const Tizen::Graphics::FloatMatrix4& rhs);
529 * Checks whether the specified instance and current instance of %Variant have equal values.
532 * @return @c true if the two instances of %Variant are equal, @n
534 * @param[in] lhs An instance of %Variant
535 * @param[in] rhs An instance of %Variant
537 _OSP_EXPORT_ friend bool operator ==(const Variant& lhs, const Variant& rhs);
540 * Checks whether the specified instance and current instance of %Variant have different values.
543 * @return @c true if the values of the two instances of %Variant are not equal, @n
545 * @param[in] lhs An instance of %Variant
546 * @param[in] rhs An instance of %Variant
549 _OSP_EXPORT_ friend bool operator !=(const Variant& lhs, const Variant& rhs);
552 * Gets the signed @c int equivalent of the current instance.
556 * @return Signed @c int equivalent of the current instance
557 * @exception E_SUCCESS The method is successful.
558 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_INT.
559 * @remarks The specific error code can be accessed using the GetLastResult() method.
560 * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_INT.
563 int ToInt(void) const;
566 * Gets the unsigned @c int equivalent of the current instance.
570 * @return Unsigned @c int equivalent of the current instance
571 * @exception E_SUCCESS The method is successful.
572 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_UINT.
573 * @remarks The specific error code can be accessed using the GetLastResult() method.
574 * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_UINT.
577 unsigned int ToUInt(void) const;
580 * Gets the @c bool equivalent of the current instance.
584 * @return @c bool equivalent of the current instance
585 * @exception E_SUCCESS The method is successful.
586 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_BOOL.
587 * @remarks The specific error code can be accessed using the GetLastResult() method.
588 * The method returns @c false and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_BOOL.
591 bool ToBool(void) const;
594 * Gets the @c float equivalent of the current instance.
598 * @return @c float equivalent of the current instance
599 * @exception E_SUCCESS The method is successful.
600 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_FLOAT.
601 * @remarks The specific error code can be accessed using the GetLastResult() method.
602 * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_FLOAT.
605 float ToFloat(void) const;
608 * Gets the @c double equivalent of the current instance.
612 * @return @c double equivalent of the current instance
613 * @exception E_SUCCESS The method is successful.
614 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_DOUBLE.
615 * @remarks The specific error code can be accessed using the GetLastResult() method.
616 * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_DOUBLE.
619 double ToDouble(void) const;
622 * Gets the signed @c long equivalent of the current instance.
626 * @return Signed @c long equivalent of the current instance
627 * @exception E_SUCCESS The method is successful.
628 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_LONG.
629 * @remarks The specific error code can be accessed using the GetLastResult() method.
630 * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_LONG.
633 long ToLong(void) const;
636 * Gets the unsigned @c int equivalent of the current instance.
640 * @return Unsigned @c long equivalent of the current instance
641 * @exception E_SUCCESS The method is successful.
642 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_ULONG.
643 * @remarks The specific error code can be accessed using the GetLastResult() method.
644 * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_ULONG.
647 unsigned long ToULong(void) const;
650 * Gets the signed @c long @c long equivalent of the current instance.
654 * @exception E_SUCCESS The method is successful.
655 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_LONGLONG.
657 * @remarks The specific error code can be accessed using the GetLastResult() method.
658 * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_LONGLONG.
661 long long ToLongLong(void) const;
664 * Gets the unsigned @c long @c long equivalent of the current instance.
668 * @return Unsigned @c long @c long equivalent of the current instance
669 * @exception E_SUCCESS The method is successful.
670 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_ULONGLONG.
671 * @remarks The specific error code can be accessed using the GetLastResult() method.
672 * The method returns @c 0 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_ULONGLONG.
675 unsigned long long ToULongLong(void) const;
678 * Gets the Tizen::Base::String representation of the value of the current instance.
682 * @return A Tizen::Base::String representing the value of the current instance
683 * @exception E_SUCCESS The method is successful.
684 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_STRING.
685 * @remarks The specific error code can be accessed using the GetLastResult() method.
686 * The method returns String("") and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_STRING.
689 Tizen::Base::String ToString(void) const;
692 * Gets the Tizen::Base::DateTime representation of the value of the current instance.
696 * @return A Tizen::Base::DateTime representing the value of the current instance
697 * @exception E_SUCCESS The method is successful.
698 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_DATETIME.
699 * @remarks The specific error code can be accessed using the GetLastResult() method.
700 * The method returns DateTime and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_DATETIME.
703 Tizen::Base::DateTime ToDateTime(void) const;
706 * Gets the Tizen::Graphics::Color representation of the value of the current instance.
710 * @return A Tizen::Graphics::Color representing the value of the current instance
711 * @exception E_SUCCESS The method is successful.
712 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_COLOR.
713 * @remarks The specific error code can be accessed using the GetLastResult() method.
714 * The method returns Color and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_COLOR.
717 Tizen::Graphics::Color ToColor(void) const;
720 * Gets the Tizen::Graphics::Point representation of the value of the current instance.
724 * @return A Tizen::Graphics::Point representing the value of the current instance
725 * @exception E_SUCCESS The method is successful.
726 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_POINT.
727 * @remarks The specific error code can be accessed using the GetLastResult() method.
728 * The method returns Point and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_POINT.
731 Tizen::Graphics::Point ToPoint(void) const;
734 * Gets the Tizen::Graphics::FloatPoint representation of the value of the current instance.
738 * @return A Tizen::Graphics::FloatPoint representing the value of the current instance
739 * @exception E_SUCCESS The method is successful.
740 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_FLOATPOINT.
741 * @remarks The specific error code can be accessed using the GetLastResult() method.
742 * The method returns FloatPoint and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_FLOATPOINT.
745 Tizen::Graphics::FloatPoint ToFloatPoint(void) const;
748 * Gets the Tizen::Graphics::Rectangle representation of the value of the current instance.
752 * @return A Tizen::Graphics::Rectangle representing the value of the current instance
753 * @exception E_SUCCESS The method is successful.
754 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_RECTANGLE.
755 * @remarks The specific error code can be accessed using the GetLastResult() method.
756 * The method returns Rectangle and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_RECTANGLE.
759 Tizen::Graphics::Rectangle ToRectangle(void) const;
762 * Gets the Tizen::Graphics::FloatRectangle representation of the value of the current instance.
766 * @return A Tizen::Graphics::FloatRectangle representing the value of the current instance
767 * @exception E_SUCCESS The method is successful.
768 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_FLOATRECTANGLE.
769 * @remarks The specific error code can be accessed using the GetLastResult() method.
770 * The method returns FloatRectangle and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_FLOATRECTANGLE.
773 Tizen::Graphics::FloatRectangle ToFloatRectangle(void) const;
776 * Gets the Tizen::Graphics::Dimension representation of the value of the current instance.
780 * @return A Tizen::Graphics::Dimension representing the value of the current instance
781 * @exception E_SUCCESS The method is successful.
782 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_DIMENSION.
783 * @remarks The specific error code can be accessed using the GetLastResult() method.
784 * The method returns Dimension and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_DIMENSION.
787 Tizen::Graphics::Dimension ToDimension(void) const;
790 * Gets the Tizen::Graphics::FloatDimension representation of the value of the current instance.
794 * @return A Tizen::Graphics::FloatDimension representing the value of the current instance
795 * @exception E_SUCCESS The method is successful.
796 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_FLOATDIMENSION.
797 * @remarks The specific error code can be accessed using the GetLastResult() method.
798 * The method returns FloatDimension and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_FLOATDIMENSION.
801 Tizen::Graphics::FloatDimension ToFloatDimension(void) const;
804 * Gets the Tizen::Graphics::FloatMatrix4 representation of the value of the current instance.
808 * @return A Tizen::Graphics::FloatMatrix4 representing the value of the current instance
809 * @exception E_SUCCESS The method is successful.
810 * @exception E_INVALID_OPERATION The current variant type is not @c VARIANT_TYPE_FLOATMATRIX4.
811 * @remarks The specific error code can be accessed using the GetLastResult() method.
812 * The method returns FloatMatrix4 and generates @c E_INVALID_OPERATION exception if the current variant type is not @c VARIANT_TYPE_FLOATMATRIX4.
815 Tizen::Graphics::FloatMatrix4 ToFloatMatrix4(void) const;
818 * Checks whether the variant is empty.
822 * @return @c true if the current instance is @c NULL_VARIANT, @n
825 bool IsEmpty(void) const;
828 * Gets the type of the variant.
832 * @return The variant type
834 VariantType GetType(void) const;
837 * Checks whether the current instance of %Variant equals the specified instance of %Variant.
841 * @return @c true if the values of the current instance is equal to the value of the specified instance, @n
843 * @param[in] obj An instance of %Variant
844 * @remarks This method overrides Tizen::Base::Object::Equals(). This method uses the values of the %Variant to compare the two instances.
846 virtual bool Equals(const Object& obj) const;
849 * Gets the hash value of the current instance.
853 * @return The hash value of the current instance
854 * @remarks Two equal instances must return the same hash value. For better performance, the used hash function must generate a random distribution for all inputs.
856 virtual int GetHashCode(void) const;
860 * A constant represents a @c null value.
864 static const Variant NULL_VARIANT;
867 // This method is for internal use only.
868 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
870 // This method is prohibited. If this method is used in an application, the application can get rejected during
871 // the certification process.
875 const _VariantImpl* GetVariantImpl(void) const;
878 // This method is for internal use only.
879 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
881 // This method is prohibited. If this method is used in an application, the application can get rejected during
882 // the certification process.
886 _VariantImpl* GetVariantImpl(void);
889 _VariantImpl* __pVariantImpl;
894 #endif // _FUI_VARIANT_H_