You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by GitBox <gi...@apache.org> on 2021/03/03 12:30:46 UTC

[GitHub] [celix] Oipo commented on a change in pull request #324: Feature/gcc 4 9 0 fixes

Oipo commented on a change in pull request #324:
URL: https://github.com/apache/celix/pull/324#discussion_r586377374



##########
File path: libs/framework/include/celix/Properties.h
##########
@@ -253,6 +259,38 @@ namespace celix {
         std::size_t size() const {
             return celix_properties_size(cProps.get());
         }
+
+        /**
+         * @brief Converts the properties a (new) std::string, std::string map.
+         */
+        std::map<std::string, std::string> convertToMap() const {
+            std::map<std::string, std::string> result{};
+            for (const auto& pair : *this) {
+                result[pair.first] = pair.second;
+            }
+            return result;
+        }
+
+        /**
+         * @brief Converts the properties a (new) std::string, std::string unordered map.
+         */
+        std::unordered_map<std::string, std::string> convertToUnorderedMap() const {
+            std::unordered_map<std::string, std::string> result{};
+            for (const auto& pair : *this) {
+                result[pair.first] = pair.second;
+            }
+            return result;
+        }
+
+        /**
+         * @brief cast the celix::Properties to a std::string, std::string map.
+         * @warning This method is added to ensure backwards compatibility with the celix::dm::Properties, but the
+         * use of this cast should be avoided.
+         * This method will eventually be removed.
+         */
+        operator std::map<std::string, std::string>() const {

Review comment:
       Without the `explicit` keyword, this results in interesting behaviour where it might not be expected. While providing a good backwards-compatible approach, we might want to think about some ifdef construction where the explicit keyword is added if enabled. This will allow easier migration in the future.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org