diff options
Diffstat (limited to 'src/Dictionary.cpp')
-rw-r--r-- | src/Dictionary.cpp | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp index 59908c6..30c20b6 100644 --- a/src/Dictionary.cpp +++ b/src/Dictionary.cpp @@ -18,7 +18,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <stdlib.h> +#include <cstdlib> +#include "plist.h" #include <plist/Dictionary.h> namespace PList @@ -39,7 +40,7 @@ static void dictionary_fill(Dictionary *_this, std::map<std::string,Node*> &map, plist_dict_next_item(node, it, &key, &subnode); if (key && subnode) map[std::string(key)] = Node::FromPlist(subnode, _this); - free(key); + delete key; } while (subnode); free(it); } @@ -50,7 +51,7 @@ Dictionary::Dictionary(plist_t node, Node* parent) : Structure(parent) dictionary_fill(this, _map, _node); } -Dictionary::Dictionary(const PList::Dictionary& d) : Structure() +Dictionary::Dictionary(const PList::Dictionary& d) { for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) { @@ -62,7 +63,7 @@ Dictionary::Dictionary(const PList::Dictionary& d) : Structure() dictionary_fill(this, _map, _node); } -Dictionary& Dictionary::operator=(PList::Dictionary& d) +Dictionary& Dictionary::operator=(const PList::Dictionary& d) { for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) { @@ -99,21 +100,45 @@ Dictionary::iterator Dictionary::Begin() return _map.begin(); } +Dictionary::iterator Dictionary::begin() +{ + return _map.begin(); +} + Dictionary::iterator Dictionary::End() { return _map.end(); } +Dictionary::iterator Dictionary::end() +{ + return _map.end(); +} + Dictionary::const_iterator Dictionary::Begin() const { return _map.begin(); } +Dictionary::const_iterator Dictionary::begin() const +{ + return _map.begin(); +} + Dictionary::const_iterator Dictionary::End() const { return _map.end(); } +Dictionary::const_iterator Dictionary::end() const +{ + return _map.end(); +} + +size_t Dictionary::size() const { + return _map.size(); +} + Dictionary::iterator Dictionary::Find(const std::string& key) { return _map.find(key); @@ -143,11 +168,6 @@ Dictionary::iterator Dictionary::Set(const std::string& key, const Node& node) return Set(key, &node); } -Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node) -{ - return this->Set(key, node); -} - void Dictionary::Remove(Node* node) { if (node) @@ -156,7 +176,7 @@ void Dictionary::Remove(Node* node) plist_dict_get_item_key(node->GetPlist(), &key); plist_dict_remove_item(_node, key); std::string skey = key; - free(key); + delete key; _map.erase(skey); delete node; } @@ -179,4 +199,4 @@ std::string Dictionary::GetNodeKey(Node* node) return ""; } -}; +} // namespace PList |