Remove dali-any from Property::Value - reimplement multivalue using more efficient...
[platform/core/uifw/dali-core.git] / dali / public-api / object / property-value.h
index 378fba2..f096d7b 100644 (file)
@@ -43,8 +43,6 @@ class DALI_IMPORT_API Property::Value
 {
 public:
 
-  friend std::ostream& operator<< (std::ostream& ouputStream, const Property::Value& value);
-
   /**
    * @brief Default constructor.
    *
@@ -57,126 +55,126 @@ public:
    *
    * @param [in] boolValue A boolean value.
    */
-  Value(bool boolValue);
+  Value( bool boolValue );
 
   /**
    * @brief Create an integer property value.
    *
    * @param [in] integerValue An integer value.
    */
-  Value(int integerValue);
+  Value( int integerValue );
 
   /**
    * @brief Create an unsigned integer property value.
    *
    * @param [in] unsignedIntegerValue An unsigned integer value.
    */
-  Value(unsigned int unsignedIntegerValue);
+  Value( unsigned int unsignedIntegerValue );
 
   /**
    * @brief Create a float property value.
    *
    * @param [in] floatValue A floating-point value.
    */
-  Value(float floatValue);
+  Value( float floatValue );
 
   /**
    * @brief Create a Vector2 property value.
    *
    * @param [in] vectorValue A vector of 2 floating-point values.
    */
-  Value(const Vector2& vectorValue);
+  Value( const Vector2& vectorValue );
 
   /**
    * @brief Create a Vector3 property value.
    *
    * @param [in] vectorValue A vector of 3 floating-point values.
    */
-  Value(const Vector3& vectorValue);
+  Value( const Vector3& vectorValue );
 
   /**
    * @brief Create a Vector4 property value.
    *
    * @param [in] vectorValue A vector of 4 floating-point values.
    */
-  Value(const Vector4& vectorValue);
+  Value( const Vector4& vectorValue );
 
   /**
    * @brief Create a Matrix3 property value.
    *
    * @param [in] matrixValue A matrix of 3x3 floating-point values.
    */
-  Value(const Matrix3& matrixValue);
+  Value( const Matrix3& matrixValue );
 
   /**
    * @brief Create a Matrix property value.
    *
    * @param [in] matrixValue A matrix of 4x4 floating-point values.
    */
-  Value(const Matrix& matrixValue);
+  Value( const Matrix& matrixValue );
 
   /**
    * @brief Create a Vector4 property value.
    *
    * @param [in] vectorValue A vector of 4 integer values.
    */
-  Value(const Rect<int>& vectorValue);
+  Value( const Rect<int>& vectorValue );
 
   /**
    * @brief Create an orientation property value.
    *
    * @param [in] angleAxis An angle-axis representing the rotation.
    */
-  Value(const AngleAxis& angleAxis);
+  Value( const AngleAxis& angleAxis );
 
   /**
    * @brief Create an orientation property value.
    *
    * @param [in] quaternion A quaternion representing the rotation.
    */
-  Value(const Quaternion& quaternion);
+  Value( const Quaternion& quaternion );
 
   /**
    * @brief Create an string property value.
    *
    * @param [in] stringValue A string.
    */
-  Value(const std::string& stringValue);
+  Value( const std::string& stringValue );
 
   /**
    * @brief Create an string property value.
    *
    * @param [in] stringValue A string.
    */
-  Value(const char* stringValue);
+  Value( const char* stringValue );
 
   /**
    * @brief Copy a property value.
    *
    * @param [in] value The property value to copy.
    */
-  Value(const Value& value);
+  Value( const Value& value );
 
   /**
    * @brief Create an array property value.
    *
    * @param [in] arrayValue An array
    */
-  Value(Property::Array& arrayValue);
+  Value( Property::Array& arrayValue );
 
   /**
    * @brief Create a map property value.
    *
    * @param [in] mapValue An array
    */
-  Value(Property::Map& mapValue);
+  Value( Property::Map& mapValue );
 
   /**
    * @brief Explicitly set a type and initialize it.
    *
    * @param [in] type The property value type.
    */
-  explicit Value(Type type);
+  explicit Value( Type type );
 
   /**
    * @brief Assign a property value.
@@ -184,7 +182,7 @@ public:
    * @param [in] value The property value to assign from.
    * @return a reference to this
    */
-  Value& operator=(const Value& value);
+  Value& operator=( const Value& value );
 
   /**
    * @brief Non-virtual destructor.
@@ -218,7 +216,7 @@ public:
    * @pre GetType() returns Property::BOOLEAN.
    * @param [out] boolValue On return, a boolean value.
    */
-  void Get(bool& boolValue) const;
+  void Get( bool& boolValue ) const;
 
   /**
    * @brief Retrieve a floating-point value.
@@ -226,7 +224,7 @@ public:
    * @pre GetType() returns Property::FLOAT.
    * @param [out] floatValue On return, a floating-point value.
    */
-  void Get(float& floatValue) const;
+  void Get( float& floatValue ) const;
 
   /**
    * @brief Retrieve an integer value.
@@ -234,7 +232,7 @@ public:
    * @pre GetType() returns Property::INTEGER.
    * @param [out] integerValue On return, an integer value.
    */
-  void Get(int& integerValue) const;
+  void Get( int& integerValue ) const;
 
   /**
    * @brief Retrieve an unsigned integer value.
@@ -242,7 +240,7 @@ public:
    * @pre GetType() returns Property::UNSIGNED_INTEGER.
    * @param [out] unsignedIntegerValue On return, an unsigned integer value.
    */
-  void Get(unsigned int& unsignedIntegerValue) const;
+  void Get( unsigned int& unsignedIntegerValue ) const;
 
   /**
    * @brief Retrieve an integer rectangle.
@@ -250,7 +248,7 @@ public:
    * @pre GetType() returns Property::RECTANGLE.
    * @param [out] rect On return, an integer rectangle.
    */
-  void Get(Rect<int>& rect) const;
+  void Get( Rect<int>& rect ) const;
 
   /**
    * @brief Retrieve a vector value.
@@ -258,7 +256,7 @@ public:
    * @pre GetType() returns Property::VECTOR2.
    * @param [out] vectorValue On return, a vector value.
    */
-  void Get(Vector2& vectorValue) const;
+  void Get( Vector2& vectorValue ) const;
 
   /**
    * @brief Retrieve a vector value.
@@ -266,7 +264,7 @@ public:
    * @pre GetType() returns Property::VECTOR3.
    * @param [out] vectorValue On return, a vector value.
    */
-  void Get(Vector3& vectorValue) const;
+  void Get( Vector3& vectorValue ) const;
 
   /**
    * @brief Retrieve a vector value.
@@ -274,7 +272,7 @@ public:
    * @pre GetType() returns Property::VECTOR4.
    * @param [out] vectorValue On return, a vector value.
    */
-  void Get(Vector4& vectorValue) const;
+  void Get( Vector4& vectorValue ) const;
 
   /**
    * @brief Retrieve a matrix3 value.
@@ -282,7 +280,7 @@ public:
    * @pre GetType() returns Property::MATRIX3.
    * @param [out] matrixValue On return, a matrix3 value.
    */
-  void Get(Matrix3& matrixValue) const;
+  void Get( Matrix3& matrixValue ) const;
 
   /**
    * @brief Retrieve a matrix value.
@@ -290,7 +288,7 @@ public:
    * @pre GetType() returns Property::MATRIX.
    * @param [out] matrixValue On return, a matrix value.
    */
-  void Get(Matrix& matrixValue) const;
+  void Get( Matrix& matrixValue ) const;
 
   /**
    * @brief Retrieve an angle-axis value.
@@ -298,7 +296,7 @@ public:
    * @pre GetType() returns Property::ROTATION.
    * @param [out] angleAxisValue On return, a angle-axis value.
    */
-  void Get(AngleAxis& angleAxisValue) const;
+  void Get( AngleAxis& angleAxisValue ) const;
 
   /**
    * @brief Retrieve a quaternion value.
@@ -306,7 +304,7 @@ public:
    * @pre GetType() returns Property::ROTATION.
    * @param [out] quaternionValue On return, a quaternion value.
    */
-  void Get(Quaternion& quaternionValue) const;
+  void Get( Quaternion& quaternionValue ) const;
 
   /**
    * @brief Retrieve an string property value.
@@ -314,7 +312,7 @@ public:
    * @pre GetType() returns Property::STRING.
    * @param [out] stringValue A string.
    */
-  void Get(std::string& stringValue) const;
+  void Get( std::string& stringValue ) const;
 
   /**
    * @brief Retrieve an array property value.
@@ -322,7 +320,7 @@ public:
    * @pre GetType() returns Property::ARRAY.
    * @param [out] arrayValue The array as a vector Property Values
    */
-  void Get(Property::Array& arrayValue) const;
+  void Get( Property::Array& arrayValue ) const;
 
   /**
    * @brief Retrieve an map property value.
@@ -330,96 +328,52 @@ public:
    * @pre GetType() returns Property::MAP.
    * @param [out] mapValue The map as vector of string and Property Value pairs
    */
-  void Get(Property::Map& mapValue) const;
-
-  /**
-   * @brief Retrieve a property value from the internal map.
-   *
-   * @pre GetType() returns Property::MAP.
-   * @param [in] key A string.
-   * @return Property value if available at key or Invalid
-   */
-  Property::Value& GetValue(const std::string& key) const;
-
-  /**
-   * @brief Retrieve a property value from the internal map.
-   *
-   * @param [in] key A string.
-   * @return true if the key exists, false if not a map or key does not exist
-   */
-  bool HasKey(const std::string& key) const;
+  void Get( Property::Map& mapValue ) const;
 
   /**
-   * @brief Retrieve a property value from the internal array or map.
+   * @brief return true if this property is a Property::MAP.
    *
-   * @pre GetType() returns Property::ARRAY or Property::MAP.
-   * @param [in] index The item index.
-   * @return Key at the index or empty if index is out of range
+   * @return return true if this property is a Property::MAP
    */
-  const std::string& GetKey(const int index) const;
-
-  /**
-   * @brief Set a property value in the map.
-   *
-   * @pre GetType() returns Property::MAP.
-   * @param [in] key A string key.
-   * @param [in] value The value to set.
-   * @return Property value if available at key
-   */
-  void SetValue(const std::string& key, const Property::Value &value);
-
-  /**
-   * @brief Retrieve a property value from the internal array or map.
-   *
-   * @pre GetType() returns Property::ARRAY or Property::MAP.
-   * @param [in] index The item index.
-   * @return Property value if available at index or Invalid
-   */
-  Property::Value& GetItem(const int index) const;
+  bool IsMap() const
+  {
+    return GetMap() != NULL;
+  }
 
   /**
-   * @brief Retrieve a property value from the internal array or map.
+   * @brief Retrieve the Map API of the Property::Value without copying the contents of the map
    *
-   * @pre GetType() returns Property::ARRAY or Property::MAP.
-   * @param [in] index The item index.
-   * @param [out] key The key of the index (Applicable only for Property::MAP).
-   * @return Property value if available at index or Invalid
+   * @return  the Map API of the Property::Value or NULL if not a Property::Map
    */
-  Property::Value& GetItem(const int index, std::string& key) const;
+  Property::Map* GetMap() const;
 
   /**
-   * @brief Set a property value in the array or map.
+   * @brief return true if this property is a Property::ARRAY.
    *
-   * @pre GetType() returns Property::ARRAY or Property::MAP.
-   * @pre index < GetSize()
-   * @param [in] index The property value index
-   * @param [in] value The value to set.
-   * @return Property value if index < GetSize()
+   * @return return true if this property is a Property::ARRAY
    */
-  void SetItem(const int index, const Property::Value &value);
+  bool IsArray() const
+  {
+    return GetArray() != NULL;
+  }
 
   /**
-   * @brief Set a property value in the array.
+   * @brief Retrieve the Array API of the Property::Value without copying the contents of the map
    *
-   * @pre GetType() returns Property::ARRAY.
-   * @param [in] value The value to set.
-   * @return THe index of the item just added
+   * @return the Array API of the Property::Value or NULL if not a Property::Array
    */
-  int AppendItem(const Property::Value &value);
+  Property::Array* GetArray() const;
 
   /**
-   * @brief Retrieve the length of the array or map.
-   *
-   * Zero if neither.
-   * @pre GetType() returns Property::ARRAY or Property::MAP
-   * @return The length of the array
+   * output to stream
    */
-  int GetSize() const;
+  friend std::ostream& operator<<( std::ostream& ouputStream, const Property::Value& value );
 
 private:
 
   struct DALI_INTERNAL Impl;
   Impl* mImpl; ///< Pointer to the implementation
+
 };
 
 /**
@@ -429,8 +383,7 @@ private:
  * @param [in] value The value to insert
  * @return The output stream operator.
  */
-DALI_IMPORT_API std::ostream& operator<< (std::ostream& ouputStream, const Property::Value& value);
-
+DALI_IMPORT_API std::ostream& operator<<( std::ostream& ouputStream, const Property::Value& value );
 
 } // namespace Dali