summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2009-10-18 21:54:33 +0200
committerGravatar Jonathan Beck2009-10-18 21:54:33 +0200
commitc17b420a7f65573a84d8acd8a6a92f9d4e0ae696 (patch)
tree385120c277f2fdd8154a26ac525b56a473f32b7e /src
parent6f84d30c7bf3999c85c480a7cc297f1b5300054b (diff)
downloadlibplist-c17b420a7f65573a84d8acd8a6a92f9d4e0ae696.tar.gz
libplist-c17b420a7f65573a84d8acd8a6a92f9d4e0ae696.tar.bz2
Tweak Dictioonary interface a bit.
Diffstat (limited to 'src')
-rw-r--r--src/Dictionary.cpp11
1 files changed, 10 insertions, 1 deletions
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
232void Dictionary::Insert(const std::string& key, Node* node) 232Dictionary::iterator Dictionary::Find(const std::string& key)
233{
234 return _map.find(key);
235}
236
237Dictionary::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
243void Dictionary::Remove(Node* node) 250void 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};