From 6b719ecda2072dafeb98a44a6f4eac247748efc0 Mon Sep 17 00:00:00 2001
From: Nikias Bassen
Date: Wed, 19 Mar 2014 02:32:57 +0100
Subject: deprecated plist_dict_insert_item in favor of plist_dict_set_item

---
 include/plist/Dictionary.h |  3 ++-
 include/plist/plist.h      | 12 +++++++++++-
 src/Dictionary.cpp         |  9 +++++++--
 src/plist.c                |  7 +------
 4 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/include/plist/Dictionary.h b/include/plist/Dictionary.h
index a937bde..eee14af 100644
--- a/include/plist/Dictionary.h
+++ b/include/plist/Dictionary.h
@@ -46,7 +46,8 @@ public :
     iterator Begin();
     iterator End();
     iterator Find(const std::string& key);
-    iterator Insert(const std::string& key, Node* node);
+    iterator Set(const std::string& key, Node* node);
+    DEPRECATED("use Set() instead") iterator Insert(const std::string& key, Node* node);
     void Remove(Node* node);
     void Remove(const std::string& key);
     std::string GetNodeKey(Node* key);
diff --git a/include/plist/plist.h b/include/plist/plist.h
index b482199..4dd76a6 100644
--- a/include/plist/plist.h
+++ b/include/plist/plist.h
@@ -44,9 +44,17 @@ extern "C"
 #else
 #define PLIST_API  __declspec( dllimport )
 #endif
+#define DEPRECATED(x) __declspec(deprecated(x))
 #else
 #include <stdint.h>
 #define PLIST_API
+#ifdef __GNUC__
+#define DEPRECATED(x) __attribute__((deprecated(x)))
+#elif defined(_MSC_VER)
+#else
+#define DEPRECATED(x)
+#pragma message("WARNING: You need to implement DEPRECATED for this compiler")
+#endif
 #endif
 
 #include <sys/types.h>
@@ -322,11 +330,13 @@ extern "C"
     /**
      * Insert a new item into a #PLIST_DICT node.
      *
+     * @deprecated Deprecated. Use plist_dict_set_item instead.
+     *
      * @param node the node of type #PLIST_DICT
      * @param item the new item to insert
      * @param key The identifier of the item to insert.
      */
-    PLIST_API void plist_dict_insert_item(plist_t node, const char* key, plist_t item);
+    DEPRECATED("use plist_dict_set_item instead") PLIST_API void plist_dict_insert_item(plist_t node, const char* key, plist_t item);
 
     /**
      * Remove an existing position in a #PLIST_DICT node.
diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp
index 6fd45e6..6009ea4 100644
--- a/src/Dictionary.cpp
+++ b/src/Dictionary.cpp
@@ -140,13 +140,13 @@ Dictionary::iterator Dictionary::Find(const std::string& key)
     return _map.find(key);
 }
 
-Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node)
+Dictionary::iterator Dictionary::Set(const std::string& key, Node* node)
 {
     if (node)
     {
         Node* clone = node->Clone();
         UpdateNodeParent(clone);
-        plist_dict_insert_item(_node, key.c_str(), clone->GetPlist());
+        plist_dict_set_item(_node, key.c_str(), clone->GetPlist());
         delete _map[key];
         _map[key] = clone;
         return _map.find(key);
@@ -154,6 +154,11 @@ Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node)
     return iterator(this->_map.end());
 }
 
+Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node)
+{
+    return this->Set(key, node);
+}
+
 void Dictionary::Remove(Node* node)
 {
     if (node)
diff --git a/src/plist.c b/src/plist.c
index f33de0a..eeb4ffd 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -424,12 +424,7 @@ void plist_dict_set_item(plist_t node, const char* key, plist_t item)
 
 void plist_dict_insert_item(plist_t node, const char* key, plist_t item)
 {
-    if (node && PLIST_DICT == plist_get_node_type(node))
-    {
-        node_attach(node, plist_new_key(key));
-        node_attach(node, item);
-    }
-    return;
+    plist_dict_set_item(node, key, item);
 }
 
 void plist_dict_remove_item(plist_t node, const char* key)
-- 
cgit v1.1-32-gdbae