diff options
author | Jonathan Beck | 2009-11-10 18:30:43 +0100 |
---|---|---|
committer | Jonathan Beck | 2009-11-10 18:30:43 +0100 |
commit | 0f92ed12ff8a0f46e80ff8cfc030c476d371c19b (patch) | |
tree | 4015f1e91fbf46a6a211bcbe5d376c7f2e6a67a1 | |
parent | 84596548e5d0cb14dfd7d2a74156331ab36a8909 (diff) | |
download | libplist-0f92ed12ff8a0f46e80ff8cfc030c476d371c19b.tar.gz libplist-0f92ed12ff8a0f46e80ff8cfc030c476d371c19b.tar.bz2 |
Remove wrongly exposed SetParent method.
-rw-r--r-- | include/plist/Node.h | 6 | ||||
-rw-r--r-- | include/plist/Structure.h | 1 | ||||
-rw-r--r-- | src/Array.cpp | 4 | ||||
-rw-r--r-- | src/Dictionary.cpp | 2 | ||||
-rw-r--r-- | src/Node.cpp | 15 | ||||
-rw-r--r-- | src/Structure.cpp | 15 |
6 files changed, 23 insertions, 20 deletions
diff --git a/include/plist/Node.h b/include/plist/Node.h index 7ea6ed9..2f9f5b6 100644 --- a/include/plist/Node.h +++ b/include/plist/Node.h @@ -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; }; }; diff --git a/include/plist/Structure.h b/include/plist/Structure.h index 66d9293..f6e4495 100644 --- a/include/plist/Structure.h +++ b/include/plist/Structure.h @@ -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); 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) 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; 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) 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; 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() 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; -} - }; 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() 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; +} + }; |