Commit 0f92ed12 authored by Jonathan Beck's avatar Jonathan Beck

Remove wrongly exposed SetParent method.

parent 84596548
...@@ -33,9 +33,8 @@ public : ...@@ -33,9 +33,8 @@ public :
virtual ~Node(); virtual ~Node();
virtual Node* Clone() = 0; virtual Node* Clone() = 0;
Node * GetParent();
void SetParent(Node* parent);
Node * GetParent();
plist_type GetType(); plist_type GetType();
plist_t GetPlist(); plist_t GetPlist();
...@@ -44,7 +43,10 @@ protected: ...@@ -44,7 +43,10 @@ protected:
Node(plist_t node, Node* parent = NULL); Node(plist_t node, Node* parent = NULL);
Node(plist_type type, Node* parent = NULL); Node(plist_type type, Node* parent = NULL);
plist_t _node; plist_t _node;
private:
Node* _parent; Node* _parent;
friend class Structure;
}; };
}; };
......
...@@ -44,6 +44,7 @@ public : ...@@ -44,6 +44,7 @@ public :
protected: protected:
Structure(Node* parent = NULL); Structure(Node* parent = NULL);
Structure(plist_type type, Node* parent = NULL); Structure(plist_type type, Node* parent = NULL);
void UpdateNodeParent(Node* node);
private: private:
Structure(Structure& s); Structure(Structure& s);
......
...@@ -101,7 +101,7 @@ void Array::Append(Node* node) ...@@ -101,7 +101,7 @@ void Array::Append(Node* node)
if (node) if (node)
{ {
Node* clone = node->Clone(); Node* clone = node->Clone();
clone->SetParent(this); UpdateNodeParent(clone);
plist_array_append_item(_node, clone->GetPlist()); plist_array_append_item(_node, clone->GetPlist());
_array.push_back(clone); _array.push_back(clone);
} }
...@@ -112,7 +112,7 @@ void Array::Insert(Node* node, unsigned int pos) ...@@ -112,7 +112,7 @@ void Array::Insert(Node* node, unsigned int pos)
if (node) if (node)
{ {
Node* clone = node->Clone(); Node* clone = node->Clone();
clone->SetParent(this); UpdateNodeParent(clone);
plist_array_insert_item(_node, clone->GetPlist(), pos); plist_array_insert_item(_node, clone->GetPlist(), pos);
std::vector<Node*>::iterator it = _array.begin(); std::vector<Node*>::iterator it = _array.begin();
it += pos; it += pos;
......
...@@ -147,7 +147,7 @@ Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node) ...@@ -147,7 +147,7 @@ Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node)
if (node) if (node)
{ {
Node* clone = node->Clone(); Node* clone = node->Clone();
clone->SetParent(this); UpdateNodeParent(clone);
plist_dict_insert_item(_node, key.c_str(), clone->GetPlist()); plist_dict_insert_item(_node, key.c_str(), clone->GetPlist());
delete _map[key]; delete _map[key];
_map[key] = clone; _map[key] = clone;
......
...@@ -96,19 +96,4 @@ Node* Node::GetParent() ...@@ -96,19 +96,4 @@ Node* Node::GetParent()
return _parent; return _parent;
} }
void Node::SetParent(Node* parent)
{
//Unlink node first
if ( NULL != _parent )
{
plist_type type = plist_get_node_type(_parent);
if (PLIST_ARRAY ==type || PLIST_DICT == type )
{
Structure* s = static_cast<Structure*>(_parent);
s->Remove(this);
}
}
_parent = parent;
}
}; };
...@@ -70,5 +70,20 @@ std::vector<char> Structure::ToBin() ...@@ -70,5 +70,20 @@ std::vector<char> Structure::ToBin()
return ret; return ret;
} }
void Structure::UpdateNodeParent(Node* node)
{
//Unlink node first
if ( NULL != node->_parent )
{
plist_type type = plist_get_node_type(node->_parent);
if (PLIST_ARRAY ==type || PLIST_DICT == type )
{
Structure* s = static_cast<Structure*>(node->_parent);
s->Remove(node);
}
}
node->_parent = this;
}
}; };
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