summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2009-11-10 18:30:43 +0100
committerGravatar Jonathan Beck2009-11-10 18:30:43 +0100
commit0f92ed12ff8a0f46e80ff8cfc030c476d371c19b (patch)
tree4015f1e91fbf46a6a211bcbe5d376c7f2e6a67a1 /src
parent84596548e5d0cb14dfd7d2a74156331ab36a8909 (diff)
downloadlibplist-0f92ed12ff8a0f46e80ff8cfc030c476d371c19b.tar.gz
libplist-0f92ed12ff8a0f46e80ff8cfc030c476d371c19b.tar.bz2
Remove wrongly exposed SetParent method.
Diffstat (limited to 'src')
-rw-r--r--src/Array.cpp4
-rw-r--r--src/Dictionary.cpp2
-rw-r--r--src/Node.cpp15
-rw-r--r--src/Structure.cpp15
4 files changed, 18 insertions, 18 deletions
diff --git a/src/Array.cpp b/src/Array.cpp
index a847ae2..3069314 100644
--- a/src/Array.cpp
+++ b/src/Array.cpp
@@ -101,7 +101,7 @@ void Array::Append(Node* node)
101 if (node) 101 if (node)
102 { 102 {
103 Node* clone = node->Clone(); 103 Node* clone = node->Clone();
104 clone->SetParent(this); 104 UpdateNodeParent(clone);
105 plist_array_append_item(_node, clone->GetPlist()); 105 plist_array_append_item(_node, clone->GetPlist());
106 _array.push_back(clone); 106 _array.push_back(clone);
107 } 107 }
@@ -112,7 +112,7 @@ void Array::Insert(Node* node, unsigned int pos)
112 if (node) 112 if (node)
113 { 113 {
114 Node* clone = node->Clone(); 114 Node* clone = node->Clone();
115 clone->SetParent(this); 115 UpdateNodeParent(clone);
116 plist_array_insert_item(_node, clone->GetPlist(), pos); 116 plist_array_insert_item(_node, clone->GetPlist(), pos);
117 std::vector<Node*>::iterator it = _array.begin(); 117 std::vector<Node*>::iterator it = _array.begin();
118 it += pos; 118 it += pos;
diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp
index 62ed433..8b5565f 100644
--- a/src/Dictionary.cpp
+++ b/src/Dictionary.cpp
@@ -147,7 +147,7 @@ Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node)
147 if (node) 147 if (node)
148 { 148 {
149 Node* clone = node->Clone(); 149 Node* clone = node->Clone();
150 clone->SetParent(this); 150 UpdateNodeParent(clone);
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;
diff --git a/src/Node.cpp b/src/Node.cpp
index 8ed3c6a..b0cc96a 100644
--- a/src/Node.cpp
+++ b/src/Node.cpp
@@ -96,19 +96,4 @@ Node* Node::GetParent()
96 return _parent; 96 return _parent;
97} 97}
98 98
99void Node::SetParent(Node* parent)
100{
101 //Unlink node first
102 if ( NULL != _parent )
103 {
104 plist_type type = plist_get_node_type(_parent);
105 if (PLIST_ARRAY ==type || PLIST_DICT == type )
106 {
107 Structure* s = static_cast<Structure*>(_parent);
108 s->Remove(this);
109 }
110 }
111 _parent = parent;
112}
113
114}; 99};
diff --git a/src/Structure.cpp b/src/Structure.cpp
index 872d396..cf7c611 100644
--- a/src/Structure.cpp
+++ b/src/Structure.cpp
@@ -70,5 +70,20 @@ std::vector<char> Structure::ToBin()
70 return ret; 70 return ret;
71} 71}
72 72
73void Structure::UpdateNodeParent(Node* node)
74{
75 //Unlink node first
76 if ( NULL != node->_parent )
77 {
78 plist_type type = plist_get_node_type(node->_parent);
79 if (PLIST_ARRAY ==type || PLIST_DICT == type )
80 {
81 Structure* s = static_cast<Structure*>(node->_parent);
82 s->Remove(node);
83 }
84 }
85 node->_parent = this;
86}
87
73}; 88};
74 89