diff options
author | Jonathan Beck | 2009-10-16 22:26:13 +0200 |
---|---|---|
committer | Jonathan Beck | 2009-10-16 22:26:13 +0200 |
commit | 32be8ec384bfd78e189d3de6609e50cf4dd072a2 (patch) | |
tree | ac7edad0f19be2a31efaaaaa3acd477dd2f3c233 /src/Data.cpp | |
parent | 8aeef4dd2331445fea8a7a40466b19973e9d09c4 (diff) | |
download | libplist-32be8ec384bfd78e189d3de6609e50cf4dd072a2.tar.gz libplist-32be8ec384bfd78e189d3de6609e50cf4dd072a2.tar.bz2 |
Fix Node lifecycle and change argument as reference to const reference.
Diffstat (limited to 'src/Data.cpp')
-rw-r--r-- | src/Data.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Data.cpp b/src/Data.cpp index 53adfa4..87a508a 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -32,7 +32,19 @@ Data::Data(plist_t node) : Node(node) { } -Data::Data(std::vector<char>& buff) : Node(PLIST_DATA) +Data::Data(PList::Data& d) : Node(PLIST_DATA) +{ + std::vector<char> b = d.GetValue(); + plist_set_data_val(_node, &b[0], b.size()); +} + +Data& Data::operator=(PList::Data& b) +{ + plist_free(_node); + _node = plist_copy(b.GetPlist()); +} + +Data::Data(const std::vector<char>& buff) : Node(PLIST_DATA) { plist_set_data_val(_node, &buff[0], buff.size()); } @@ -41,7 +53,12 @@ Data::~Data() { } -void Data::SetValue(std::vector<char>& buff) +Node* Data::Clone() +{ + return new Data(*this); +} + +void Data::SetValue(const std::vector<char>& buff) { plist_set_data_val(_node, &buff[0], buff.size()); } |