summaryrefslogtreecommitdiffstats
path: root/src/Data.cpp
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2009-10-16 22:26:13 +0200
committerGravatar Jonathan Beck2009-10-16 22:26:13 +0200
commit32be8ec384bfd78e189d3de6609e50cf4dd072a2 (patch)
treeac7edad0f19be2a31efaaaaa3acd477dd2f3c233 /src/Data.cpp
parent8aeef4dd2331445fea8a7a40466b19973e9d09c4 (diff)
downloadlibplist-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.cpp21
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());
}