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

Remove wrongly exposed SetParent method.

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