diff options
| author | 2014-03-19 02:32:57 +0100 | |
|---|---|---|
| committer | 2014-03-19 02:32:57 +0100 | |
| commit | 6b719ecda2072dafeb98a44a6f4eac247748efc0 (patch) | |
| tree | b223294da3c9e4124ddead7c6ece4107b72d8b47 | |
| parent | f9299fa80a7530fea4b829ea851972a664edf1fe (diff) | |
| download | libplist-6b719ecda2072dafeb98a44a6f4eac247748efc0.tar.gz libplist-6b719ecda2072dafeb98a44a6f4eac247748efc0.tar.bz2 | |
deprecated plist_dict_insert_item in favor of plist_dict_set_item
| -rw-r--r-- | include/plist/Dictionary.h | 3 | ||||
| -rw-r--r-- | include/plist/plist.h | 12 | ||||
| -rw-r--r-- | src/Dictionary.cpp | 9 | ||||
| -rw-r--r-- | 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 : | |||
| 46 | iterator Begin(); | 46 | iterator Begin(); |
| 47 | iterator End(); | 47 | iterator End(); |
| 48 | iterator Find(const std::string& key); | 48 | iterator Find(const std::string& key); |
| 49 | iterator Insert(const std::string& key, Node* node); | 49 | iterator Set(const std::string& key, Node* node); |
| 50 | DEPRECATED("use Set() instead") iterator Insert(const std::string& key, Node* node); | ||
| 50 | void Remove(Node* node); | 51 | void Remove(Node* node); |
| 51 | void Remove(const std::string& key); | 52 | void Remove(const std::string& key); |
| 52 | std::string GetNodeKey(Node* key); | 53 | 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" | |||
| 44 | #else | 44 | #else |
| 45 | #define PLIST_API __declspec( dllimport ) | 45 | #define PLIST_API __declspec( dllimport ) |
| 46 | #endif | 46 | #endif |
| 47 | #define DEPRECATED(x) __declspec(deprecated(x)) | ||
| 47 | #else | 48 | #else |
| 48 | #include <stdint.h> | 49 | #include <stdint.h> |
| 49 | #define PLIST_API | 50 | #define PLIST_API |
| 51 | #ifdef __GNUC__ | ||
| 52 | #define DEPRECATED(x) __attribute__((deprecated(x))) | ||
| 53 | #elif defined(_MSC_VER) | ||
| 54 | #else | ||
| 55 | #define DEPRECATED(x) | ||
| 56 | #pragma message("WARNING: You need to implement DEPRECATED for this compiler") | ||
| 57 | #endif | ||
| 50 | #endif | 58 | #endif |
| 51 | 59 | ||
| 52 | #include <sys/types.h> | 60 | #include <sys/types.h> |
| @@ -322,11 +330,13 @@ extern "C" | |||
| 322 | /** | 330 | /** |
| 323 | * Insert a new item into a #PLIST_DICT node. | 331 | * Insert a new item into a #PLIST_DICT node. |
| 324 | * | 332 | * |
| 333 | * @deprecated Deprecated. Use plist_dict_set_item instead. | ||
| 334 | * | ||
| 325 | * @param node the node of type #PLIST_DICT | 335 | * @param node the node of type #PLIST_DICT |
| 326 | * @param item the new item to insert | 336 | * @param item the new item to insert |
| 327 | * @param key The identifier of the item to insert. | 337 | * @param key The identifier of the item to insert. |
| 328 | */ | 338 | */ |
| 329 | PLIST_API void plist_dict_insert_item(plist_t node, const char* key, plist_t item); | 339 | DEPRECATED("use plist_dict_set_item instead") PLIST_API void plist_dict_insert_item(plist_t node, const char* key, plist_t item); |
| 330 | 340 | ||
| 331 | /** | 341 | /** |
| 332 | * Remove an existing position in a #PLIST_DICT node. | 342 | * 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) | |||
| 140 | return _map.find(key); | 140 | return _map.find(key); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node) | 143 | Dictionary::iterator Dictionary::Set(const std::string& key, Node* node) |
| 144 | { | 144 | { |
| 145 | if (node) | 145 | if (node) |
| 146 | { | 146 | { |
| 147 | Node* clone = node->Clone(); | 147 | Node* clone = node->Clone(); |
| 148 | UpdateNodeParent(clone); | 148 | UpdateNodeParent(clone); |
| 149 | plist_dict_insert_item(_node, key.c_str(), clone->GetPlist()); | 149 | plist_dict_set_item(_node, key.c_str(), clone->GetPlist()); |
| 150 | delete _map[key]; | 150 | delete _map[key]; |
| 151 | _map[key] = clone; | 151 | _map[key] = clone; |
| 152 | return _map.find(key); | 152 | return _map.find(key); |
| @@ -154,6 +154,11 @@ Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node) | |||
| 154 | return iterator(this->_map.end()); | 154 | return iterator(this->_map.end()); |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node) | ||
| 158 | { | ||
| 159 | return this->Set(key, node); | ||
| 160 | } | ||
| 161 | |||
| 157 | void Dictionary::Remove(Node* node) | 162 | void Dictionary::Remove(Node* node) |
| 158 | { | 163 | { |
| 159 | if (node) | 164 | 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) | |||
| 424 | 424 | ||
| 425 | void plist_dict_insert_item(plist_t node, const char* key, plist_t item) | 425 | void plist_dict_insert_item(plist_t node, const char* key, plist_t item) |
| 426 | { | 426 | { |
| 427 | if (node && PLIST_DICT == plist_get_node_type(node)) | 427 | plist_dict_set_item(node, key, item); |
| 428 | { | ||
| 429 | node_attach(node, plist_new_key(key)); | ||
| 430 | node_attach(node, item); | ||
| 431 | } | ||
| 432 | return; | ||
| 433 | } | 428 | } |
| 434 | 429 | ||
| 435 | void plist_dict_remove_item(plist_t node, const char* key) | 430 | void plist_dict_remove_item(plist_t node, const char* key) |
