summaryrefslogtreecommitdiffstats
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
parent6f84d30c7bf3999c85c480a7cc297f1b5300054b (diff)
downloadlibplist-c17b420a7f65573a84d8acd8a6a92f9d4e0ae696.tar.gz
libplist-c17b420a7f65573a84d8acd8a6a92f9d4e0ae696.tar.bz2
Tweak Dictioonary interface a bit.
-rw-r--r--include/plist/Dictionary.h3
-rw-r--r--src/Dictionary.cpp11
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
Node* operator[](const std::string& key);
iterator Begin();
iterator End();
- void Insert(const std::string& key, Node* node);
+ iterator Find(const std::string& key);
+ iterator Insert(const std::string& key, Node* node);
void Remove(Node* node);
void Remove(const std::string& key);
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()
return _map.end();
}
-void Dictionary::Insert(const std::string& key, Node* node)
+Dictionary::iterator Dictionary::Find(const std::string& key)
+{
+ return _map.find(key);
+}
+
+Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node)
{
if (node)
{
@@ -237,7 +242,9 @@ void Dictionary::Insert(const std::string& key, Node* node)
plist_dict_insert_item(_node, key.c_str(), clone->GetPlist());
delete _map[key];
_map[key] = clone;
+ return _map.find(key);
}
+ return iterator(NULL);
}
void Dictionary::Remove(Node* node)
@@ -249,6 +256,7 @@ void Dictionary::Remove(Node* node)
plist_dict_remove_item(_node, key);
std::string skey = key;
free(key);
+ _map.erase(skey);
delete node;
}
}
@@ -257,6 +265,7 @@ void Dictionary::Remove(const std::string& key)
{
plist_dict_remove_item(_node, key.c_str());
delete _map[key];
+ _map.erase(key);
}
};