/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
END_TEST;
}
+int UtcDaliPropertyMapRemove(void)
+{
+ Property::Map map;
+ map["hello"] = 1;
+ map[10] = "DALi";
+ map["world"] = 2;
+
+ DALI_TEST_CHECK(map.Count() == 3);
+ DALI_TEST_CHECK(!map.Remove(0));
+ DALI_TEST_CHECK(map.Count() == 3);
+ DALI_TEST_CHECK(!map.Remove("doesnotexist"));
+ DALI_TEST_CHECK(map.Count() == 3);
+ DALI_TEST_CHECK(map.Remove(10));
+ DALI_TEST_CHECK(map.Count() == 2);
+ DALI_TEST_CHECK(map.Remove("hello"));
+ DALI_TEST_CHECK(map.Count() == 1);
+ DALI_TEST_CHECK(map.Remove("world"));
+ DALI_TEST_CHECK(map.Count() == 0);
+
+ END_TEST;
+}
+
int UtcDaliPropertyMapMerge(void)
{
Property::Map map;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
mImpl->mIndexValueContainer.clear();
}
+bool Property::Map::Remove(Property::Index key)
+{
+ DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value");
+
+ auto iter = std::find_if(mImpl->mIndexValueContainer.begin(), mImpl->mIndexValueContainer.end(), [key](const IndexValuePair& element) { return element.first == key; });
+ if(iter != mImpl->mIndexValueContainer.end())
+ {
+ mImpl->mIndexValueContainer.erase(iter);
+ return true;
+ }
+ return false;
+}
+
+bool Property::Map::Remove(std::string_view key)
+{
+ DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value");
+
+ auto iter = std::find_if(mImpl->mStringValueContainer.begin(), mImpl->mStringValueContainer.end(), [key](const StringValuePair& element) { return element.first == key; });
+ if(iter != mImpl->mStringValueContainer.end())
+ {
+ mImpl->mStringValueContainer.erase(iter);
+ return true;
+ }
+ return false;
+}
+
void Property::Map::Merge(const Property::Map& from)
{
DALI_ASSERT_DEBUG(mImpl && "Cannot use an object previously used as an r-value");
#define DALI_PROPERTY_MAP_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
void Clear();
/**
+ * @brief Removes the item by the specified key.
+ *
+ * @SINCE_2_1.15
+ * @param[in] key The key to remove
+ * @return @c true if succeeded, @c false otherwise
+ */
+ bool Remove(Property::Index key);
+
+ /**
+ * @brief Removes the item by the specified key.
+ *
+ * @SINCE_2_1.15
+ * @param[in] key The key to remove
+ * @return @c true if succeeded, @c false otherwise
+ */
+ bool Remove(std::string_view key);
+
+ /**
* @brief Merges values from the map 'from' to the current.
*
* Any values in 'from' will overwrite the values in the current map.