diff options
Diffstat (limited to 'src/Dictionary.cpp')
| -rw-r--r-- | src/Dictionary.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp index 6879e33..15df0b4 100644 --- a/src/Dictionary.cpp +++ b/src/Dictionary.cpp | |||
| @@ -85,7 +85,7 @@ Dictionary::Dictionary(plist_t node) : Structure() | |||
| 85 | free(it); | 85 | free(it); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | Dictionary::Dictionary(Dictionary& d) | 88 | Dictionary::Dictionary(PList::Dictionary& d) : Structure() |
| 89 | { | 89 | { |
| 90 | for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) | 90 | for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) |
| 91 | { | 91 | { |
| @@ -142,7 +142,7 @@ Dictionary::Dictionary(Dictionary& d) | |||
| 142 | free(it); | 142 | free(it); |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | Dictionary& Dictionary::operator=(const Dictionary& d) | 145 | Dictionary& Dictionary::operator=(PList::Dictionary& d) |
| 146 | { | 146 | { |
| 147 | for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) | 147 | for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) |
| 148 | { | 148 | { |
| @@ -209,7 +209,12 @@ Dictionary::~Dictionary() | |||
| 209 | _map.clear(); | 209 | _map.clear(); |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | Node* Dictionary::operator[](std::string& key) | 212 | Node* Dictionary::Clone() |
| 213 | { | ||
| 214 | return new Dictionary(*this); | ||
| 215 | } | ||
| 216 | |||
| 217 | Node* Dictionary::operator[](const std::string& key) | ||
| 213 | { | 218 | { |
| 214 | return _map[key]; | 219 | return _map[key]; |
| 215 | } | 220 | } |
| @@ -224,13 +229,14 @@ Dictionary::iterator Dictionary::End() | |||
| 224 | return _map.end(); | 229 | return _map.end(); |
| 225 | } | 230 | } |
| 226 | 231 | ||
| 227 | void Dictionary::Insert(std::string& key, Node* node) | 232 | void Dictionary::Insert(const std::string& key, Node* node) |
| 228 | { | 233 | { |
| 229 | if (node) | 234 | if (node) |
| 230 | { | 235 | { |
| 231 | plist_dict_insert_item(_node, key.c_str(), node->GetPlist()); | 236 | Node* clone = node->Clone(); |
| 237 | plist_dict_insert_item(_node, key.c_str(), clone->GetPlist()); | ||
| 232 | delete _map[key]; | 238 | delete _map[key]; |
| 233 | _map[key] = node; | 239 | _map[key] = clone; |
| 234 | } | 240 | } |
| 235 | } | 241 | } |
| 236 | 242 | ||
| @@ -247,7 +253,7 @@ void Dictionary::Remove(Node* node) | |||
| 247 | } | 253 | } |
| 248 | } | 254 | } |
| 249 | 255 | ||
| 250 | void Dictionary::Remove(std::string& key) | 256 | void Dictionary::Remove(const std::string& key) |
| 251 | { | 257 | { |
| 252 | plist_dict_remove_item(_node, key.c_str()); | 258 | plist_dict_remove_item(_node, key.c_str()); |
| 253 | delete _map[key]; | 259 | delete _map[key]; |
