Commit c17b420a authored by Jonathan Beck's avatar Jonathan Beck

Tweak Dictioonary interface a bit.

parent 6f84d30c
......@@ -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);
......
......@@ -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);
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment