summaryrefslogtreecommitdiffstats
path: root/src/Dictionary.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Dictionary.cpp')
-rw-r--r--src/Dictionary.cpp78
1 files changed, 39 insertions, 39 deletions
diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp
index 72307f1..fedce2e 100644
--- a/src/Dictionary.cpp
+++ b/src/Dictionary.cpp
@@ -7,15 +7,15 @@
7 * modify it under the terms of the GNU Lesser General Public 7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version. 9 * version 2.1 of the License, or (at your option) any later version.
10 * 10 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details. 14 * Lesser General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Lesser General Public 16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software 17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */ 19 */
20 20
21#include <stdlib.h> 21#include <stdlib.h>
@@ -41,11 +41,11 @@ Dictionary::Dictionary(plist_t node, Node* parent) : Structure(parent)
41 while (subnode) 41 while (subnode)
42 { 42 {
43 _map[std::string(key)] = Utils::FromPlist(subnode, this); 43 _map[std::string(key)] = Utils::FromPlist(subnode, this);
44 44
45 subnode = NULL; 45 subnode = NULL;
46 free(key); 46 free(key);
47 key = NULL; 47 key = NULL;
48 plist_dict_next_item(_node, it, &key, &subnode); 48 plist_dict_next_item(_node, it, &key, &subnode);
49 } 49 }
50 free(it); 50 free(it);
51} 51}
@@ -54,8 +54,8 @@ Dictionary::Dictionary(PList::Dictionary& d) : Structure()
54{ 54{
55 for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) 55 for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++)
56 { 56 {
57 plist_free(it->second->GetPlist()); 57 plist_free(it->second->GetPlist());
58 delete it->second; 58 delete it->second;
59 } 59 }
60 _map.clear(); 60 _map.clear();
61 61
@@ -69,11 +69,11 @@ Dictionary::Dictionary(PList::Dictionary& d) : Structure()
69 while (subnode) 69 while (subnode)
70 { 70 {
71 _map[std::string(key)] = Utils::FromPlist(subnode, this); 71 _map[std::string(key)] = Utils::FromPlist(subnode, this);
72 72
73 subnode = NULL; 73 subnode = NULL;
74 free(key); 74 free(key);
75 key = NULL; 75 key = NULL;
76 plist_dict_next_item(_node, it, NULL, &subnode); 76 plist_dict_next_item(_node, it, NULL, &subnode);
77 } 77 }
78 free(it); 78 free(it);
79} 79}
@@ -82,8 +82,8 @@ Dictionary& Dictionary::operator=(PList::Dictionary& d)
82{ 82{
83 for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) 83 for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++)
84 { 84 {
85 plist_free(it->second->GetPlist()); 85 plist_free(it->second->GetPlist());
86 delete it->second; 86 delete it->second;
87 } 87 }
88 _map.clear(); 88 _map.clear();
89 89
@@ -97,11 +97,11 @@ Dictionary& Dictionary::operator=(PList::Dictionary& d)
97 while (subnode) 97 while (subnode)
98 { 98 {
99 _map[std::string(key)] = Utils::FromPlist(subnode, this); 99 _map[std::string(key)] = Utils::FromPlist(subnode, this);
100 100
101 subnode = NULL; 101 subnode = NULL;
102 free(key); 102 free(key);
103 key = NULL; 103 key = NULL;
104 plist_dict_next_item(_node, it, NULL, &subnode); 104 plist_dict_next_item(_node, it, NULL, &subnode);
105 } 105 }
106 free(it); 106 free(it);
107 return *this; 107 return *this;
@@ -111,8 +111,8 @@ Dictionary::~Dictionary()
111{ 111{
112 for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) 112 for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++)
113 { 113 {
114 plist_free(it->second->GetPlist()); 114 plist_free(it->second->GetPlist());
115 delete it->second; 115 delete it->second;
116 } 116 }
117 _map.clear(); 117 _map.clear();
118} 118}
@@ -146,12 +146,12 @@ Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node)
146{ 146{
147 if (node) 147 if (node)
148 { 148 {
149 Node* clone = node->Clone(); 149 Node* clone = node->Clone();
150 clone->SetParent(this); 150 clone->SetParent(this);
151 plist_dict_insert_item(_node, key.c_str(), clone->GetPlist()); 151 plist_dict_insert_item(_node, key.c_str(), clone->GetPlist());
152 delete _map[key]; 152 delete _map[key];
153 _map[key] = clone; 153 _map[key] = clone;
154 return _map.find(key); 154 return _map.find(key);
155 } 155 }
156 return iterator(NULL); 156 return iterator(NULL);
157} 157}
@@ -160,21 +160,21 @@ void Dictionary::Remove(Node* node)
160{ 160{
161 if (node) 161 if (node)
162 { 162 {
163 char* key = NULL; 163 char* key = NULL;
164 plist_dict_get_item_key(node->GetPlist(), &key); 164 plist_dict_get_item_key(node->GetPlist(), &key);
165 plist_dict_remove_item(_node, key); 165 plist_dict_remove_item(_node, key);
166 std::string skey = key; 166 std::string skey = key;
167 free(key); 167 free(key);
168 _map.erase(skey); 168 _map.erase(skey);
169 delete node; 169 delete node;
170 } 170 }
171} 171}
172 172
173void Dictionary::Remove(const std::string& key) 173void Dictionary::Remove(const std::string& key)
174{ 174{
175 plist_dict_remove_item(_node, key.c_str()); 175 plist_dict_remove_item(_node, key.c_str());
176 delete _map[key]; 176 delete _map[key];
177 _map.erase(key); 177 _map.erase(key);
178} 178}
179 179
180}; 180};