diff options
| -rw-r--r-- | include/plist/Dictionary.h | 3 | ||||
| -rw-r--r-- | src/Dictionary.cpp | 11 |
2 files changed, 12 insertions, 2 deletions
diff --git a/include/plist/Dictionary.h b/include/plist/Dictionary.h index 6169774..53e95e6 100644 --- a/include/plist/Dictionary.h +++ b/include/plist/Dictionary.h | |||
| @@ -45,7 +45,8 @@ class Dictionary : public Structure | |||
| 45 | Node* operator[](const std::string& key); | 45 | Node* operator[](const std::string& key); |
| 46 | iterator Begin(); | 46 | iterator Begin(); |
| 47 | iterator End(); | 47 | iterator End(); |
| 48 | void Insert(const std::string& key, Node* node); | 48 | iterator Find(const std::string& key); |
| 49 | iterator Insert(const std::string& key, Node* node); | ||
| 49 | void Remove(Node* node); | 50 | void Remove(Node* node); |
| 50 | void Remove(const std::string& key); | 51 | void Remove(const std::string& key); |
| 51 | 52 | ||
diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp index 79f0afc..a9f85ea 100644 --- a/src/Dictionary.cpp +++ b/src/Dictionary.cpp | |||
| @@ -229,7 +229,12 @@ Dictionary::iterator Dictionary::End() | |||
| 229 | return _map.end(); | 229 | return _map.end(); |
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | void Dictionary::Insert(const std::string& key, Node* node) | 232 | Dictionary::iterator Dictionary::Find(const std::string& key) |
| 233 | { | ||
| 234 | return _map.find(key); | ||
| 235 | } | ||
| 236 | |||
| 237 | Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node) | ||
| 233 | { | 238 | { |
| 234 | if (node) | 239 | if (node) |
| 235 | { | 240 | { |
| @@ -237,7 +242,9 @@ void Dictionary::Insert(const std::string& key, Node* node) | |||
| 237 | plist_dict_insert_item(_node, key.c_str(), clone->GetPlist()); | 242 | plist_dict_insert_item(_node, key.c_str(), clone->GetPlist()); |
| 238 | delete _map[key]; | 243 | delete _map[key]; |
| 239 | _map[key] = clone; | 244 | _map[key] = clone; |
| 245 | return _map.find(key); | ||
| 240 | } | 246 | } |
| 247 | return iterator(NULL); | ||
| 241 | } | 248 | } |
| 242 | 249 | ||
| 243 | void Dictionary::Remove(Node* node) | 250 | void Dictionary::Remove(Node* node) |
| @@ -249,6 +256,7 @@ void Dictionary::Remove(Node* node) | |||
| 249 | plist_dict_remove_item(_node, key); | 256 | plist_dict_remove_item(_node, key); |
| 250 | std::string skey = key; | 257 | std::string skey = key; |
| 251 | free(key); | 258 | free(key); |
| 259 | _map.erase(skey); | ||
| 252 | delete node; | 260 | delete node; |
| 253 | } | 261 | } |
| 254 | } | 262 | } |
| @@ -257,6 +265,7 @@ void Dictionary::Remove(const std::string& key) | |||
| 257 | { | 265 | { |
| 258 | plist_dict_remove_item(_node, key.c_str()); | 266 | plist_dict_remove_item(_node, key.c_str()); |
| 259 | delete _map[key]; | 267 | delete _map[key]; |
| 268 | _map.erase(key); | ||
| 260 | } | 269 | } |
| 261 | 270 | ||
| 262 | }; | 271 | }; |
