Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / object / property-map.h
old mode 100755 (executable)
new mode 100644 (file)
index b35a5ad..45431f5
@@ -2,7 +2,7 @@
 #define DALI_PROPERTY_MAP_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 
 // EXTERNAL INCLUDES
-#include <string>
-#include <sstream>
 #include <initializer_list>
+#include <sstream>
+#include <string>
+#include <string_view>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
-#include <dali/public-api/object/property.h>
 #include <dali/public-api/object/property-key.h>
 #include <dali/public-api/object/property-value.h>
+#include <dali/public-api/object/property.h>
 
 namespace Dali
 {
@@ -36,8 +37,8 @@ namespace Dali
  * @{
  */
 
-typedef std::pair< Property::Key, Property::Value > KeyValuePair;
-typedef std::pair<std::string, Property::Value> StringValuePair;
+using KeyValuePair    = std::pair<Property::Key, Property::Value>;
+using StringValuePair = std::pair<std::string, Property::Value>;
 
 /**
  * @brief A Map of property values, the key type could be String or Property::Index.
@@ -46,8 +47,7 @@ typedef std::pair<std::string, Property::Value> StringValuePair;
 class DALI_CORE_API Property::Map
 {
 public:
-
-  typedef std::size_t SizeType;
+  using SizeType = std::size_t;
 
   /**
    * @brief Default constructor.
@@ -61,7 +61,7 @@ public:
    * @SINCE_1_4.17
    * @param[in] values An initializer_list of pairs of index and value.
    */
-  Map( const std::initializer_list< KeyValuePair >& values );
+  Map(const std::initializer_list<KeyValuePair>& values);
 
   /**
    * @brief Copy constructor.
@@ -69,7 +69,7 @@ public:
    * @SINCE_1_0.0
    * @param[in] other The Map to copy from
    */
-  Map( const Map& other );
+  Map(const Map& other);
 
   /**
    * @brief Move constructor.
@@ -78,7 +78,7 @@ public:
    * @param[in] other The Map to move from
    * @note After the @a other array is used, it becomes invalid and is no longer usable.
    */
-  Map( Map&& other );
+  Map(Map&& other);
 
   /**
    * @brief Non-virtual destructor.
@@ -110,17 +110,7 @@ public:
    * @param[in] key The key to insert
    * @param[in] value The value to insert
    */
-  void Insert( const char* key, const Value& value );
-
-  /**
-   * @brief Inserts the key-value pair in the Map, with the key type as string.
-   *
-   * Does not check for duplicates.
-   * @SINCE_1_0.0
-   * @param[in] key The key to insert
-   * @param[in] value The value to insert
-   */
-  void Insert( const std::string& key, const Value& value );
+  void Insert(std::string key, Value value);
 
   /**
    * @brief Inserts the key-value pair in the Map, with the key type as index.
@@ -130,23 +120,7 @@ public:
    * @param[in] key The key to insert
    * @param[in] value The value to insert
    */
-  void Insert( Property::Index key, const Value& value );
-
-
-  /**
-   * @brief Inserts the key-value pair in the Map, with the key type as string.
-   *
-   * Does not check for duplicates
-   * @SINCE_1_2.5
-   * @param key to insert
-   * @param value to insert
-   * @return a reference to this object
-   */
-  inline Property::Map& Add( const char* key, const Value& value )
-  {
-    Insert(key, value);
-    return *this;
-  }
+  void Insert(Property::Index key, Value value);
 
   /**
    * @brief Inserts the key-value pair in the Map, with the key type as string.
@@ -157,13 +131,12 @@ public:
    * @param value to insert
    * @return a reference to this object
    */
-  inline Property::Map& Add( const std::string& key, const Value& value )
+  Property::Map& Add(std::string key, Value value)
   {
-    Insert(key, value);
+    Insert(std::move(key), std::move(value));
     return *this;
   }
 
-
   /**
    * @brief Inserts the key-value pair in the Map, with the key type as index.
    *
@@ -173,9 +146,9 @@ public:
    * @param value to insert
    * @return a reference to this object
    */
-  inline Property::Map& Add( Property::Index key, const Value& value )
+  Property::Map& Add(Property::Index key, Value value)
   {
-    Insert(key, value);
+    Insert(key, std::move(value));
     return *this;
   }
 
@@ -188,7 +161,7 @@ public:
    *
    * @note Will assert if position >= Count()
    */
-  Value& GetValue( SizeType position ) const;
+  Value& GetValue(SizeType position) const;
 
   /**
    * DEPRECATED_1_1.39 Position based retrieval is no longer supported after extending the key type to both Index and String.
@@ -201,7 +174,7 @@ public:
    *
    * @note Will assert if position >= Count()
    */
-  const std::string& GetKey( SizeType position ) const DALI_DEPRECATED_API;
+  const std::string& GetKey(SizeType position) const DALI_DEPRECATED_API;
 
   /**
    * @brief Retrieve the key at the specified position.
@@ -212,7 +185,7 @@ public:
    *
    * @note Will assert if position >= Count()
    */
-  Key GetKeyAt( SizeType position ) const;
+  Key GetKeyAt(SizeType position) const;
 
   /**
    * DEPRECATED_1_1.39 Position based retrieval is no longer supported after extending the key type to both Index and String.
@@ -225,7 +198,7 @@ public:
    *
    * @note Will assert if position >= Count() or key at position is an index key.
    */
-  StringValuePair& GetPair( SizeType position ) const DALI_DEPRECATED_API;
+  StringValuePair& GetPair(SizeType position) const DALI_DEPRECATED_API;
 
   /**
    * @brief Retrieve the key & the value at the specified position.
@@ -236,17 +209,7 @@ public:
    *
    * @note Will assert if position >= Count()
    */
-  KeyValuePair GetKeyValue( SizeType position ) const;
-
-  /**
-   * @brief Finds the value for the specified key if it exists.
-   *
-   * @SINCE_1_0.0
-   * @param[in] key The key to find
-   *
-   * @return A const pointer to the value if it exists, NULL otherwise
-   */
-  Value* Find( const char* key ) const;
+  KeyValuePair GetKeyValue(SizeType position) const;
 
   /**
    * @brief Finds the value for the specified key if it exists.
@@ -256,7 +219,7 @@ public:
    *
    * @return A const pointer to the value if it exists, NULL otherwise
    */
-  Value* Find( const std::string& key ) const;
+  Value* Find(std::string_view key) const;
 
   /**
    * @brief Finds the value for the specified key if it exists.
@@ -266,7 +229,7 @@ public:
    *
    * @return A const pointer to the value if it exists, NULL otherwise
    */
-  Value* Find( Property::Index key ) const;
+  Value* Find(Property::Index key) const;
 
   /**
    * @brief Finds the value for the specified keys if either exist.
@@ -279,7 +242,7 @@ public:
    *
    * @return A const pointer to the value if it exists, NULL otherwise
    */
-  Value* Find( Property::Index indexKey, const std::string& stringKey ) const;
+  Value* Find(Property::Index indexKey, std::string_view stringKey) const;
 
   /**
    * @brief Finds the value for the specified key if it exists and its type is type.
@@ -290,7 +253,7 @@ public:
    *
    * @return A const pointer to the value if it exists, NULL otherwise
    */
-  Value* Find( const std::string& key, Property::Type type ) const;
+  Value* Find(std::string_view key, Property::Type type) const;
 
   /**
    * @brief Finds the value for the specified key if it exists and its type is type.
@@ -301,7 +264,7 @@ public:
    *
    * @return A const pointer to the value if it exists, NULL otherwise
    */
-  Value* Find( Property::Index key, Property::Type type ) const;
+  Value* Find(Property::Index key, Property::Type type) const;
 
   /**
    * @brief Clears the map.
@@ -317,7 +280,7 @@ public:
    * @SINCE_1_0.0
    * @param[in] from The map to merge from
    */
-  void Merge( const Map& from );
+  void Merge(const Map& from);
 
   /**
    * @brief Const operator to access element with the specified string key.
@@ -329,7 +292,7 @@ public:
    *
    * @note Will assert if invalid-key is given.
    */
-  const Value& operator[]( const std::string& key ) const;
+  const Value& operator[](std::string_view key) const;
 
   /**
    * @brief Operator to access the element with the specified string key.
@@ -341,7 +304,7 @@ public:
    *
    * @note If an element with the key does not exist, then it is created.
    */
-  Value& operator[]( const std::string& key );
+  Value& operator[](std::string_view key);
 
   /**
    * @brief Const operator to access element with the specified index key.
@@ -353,7 +316,7 @@ public:
    *
    * @note Will assert if invalid-key is given.
    */
-  const Value& operator[]( Property::Index key ) const;
+  const Value& operator[](Property::Index key) const;
 
   /**
    * @brief Operator to access the element with the specified index key.
@@ -365,7 +328,7 @@ public:
    *
    * @note If an element with the key does not exist, then it is created.
    */
-  Value& operator[]( Property::Index key );
+  Value& operator[](Property::Index key);
 
   /**
    * @brief Assignment operator.
@@ -375,7 +338,7 @@ public:
    *
    * @return The copied map
    */
-  Map& operator=( const Map& other );
+  Map& operator=(const Map& other);
 
   /**
    * @brief Move assignment operator.
@@ -387,17 +350,17 @@ public:
    *
    * @note The other array is an r-value so becomes invalid and is no longer usable.
    */
-  Map& operator=( Map&& other );
+  Map& operator=(Map&& other);
 
   /**
    * @brief Output to stream.
    * @SINCE_1_1.28
    */
-  friend DALI_CORE_API std::ostream& operator<<( std::ostream& stream, const Property::Map& map );
+  friend DALI_CORE_API std::ostream& operator<<(std::ostream& stream, const Property::Map& map);
 
 private:
-  struct DALI_INTERNAL Impl; ///< Private data
-  Impl* mImpl; ///< Pointer to private data
+  struct DALI_INTERNAL Impl;  ///< Private data
+  Impl*                mImpl; ///< Pointer to private data
 };
 
 /**
@@ -408,7 +371,7 @@ private:
  * @param[in] map The map to insert
  * @return The output stream operator
  */
-DALI_CORE_API std::ostream& operator<<( std::ostream& stream, const Property::Map& map );
+DALI_CORE_API std::ostream& operator<<(std::ostream& stream, const Property::Map& map);
 
 /**
  * @}