summaryrefslogtreecommitdiffstats
path: root/src/String.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/String.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/String.cpp')
-rw-r--r--src/String.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/String.cpp b/src/String.cpp
index 7bf744c..dbc81ac 100644
--- a/src/String.cpp
+++ b/src/String.cpp
@@ -32,7 +32,18 @@ String::String(plist_t node) : Node(node)
{
}
-String::String(std::string& s) : Node(PLIST_STRING)
+String::String(PList::String& s) : Node(PLIST_UINT)
+{
+ plist_set_string_val(_node, s.GetValue().c_str());
+}
+
+String& String::operator=(PList::String& s)
+{
+ plist_free(_node);
+ _node = plist_copy(s.GetPlist());
+}
+
+String::String(const std::string& s) : Node(PLIST_STRING)
{
plist_set_string_val(_node, s.c_str());
}
@@ -41,7 +52,12 @@ String::~String()
{
}
-void String::SetValue(std::string& s)
+Node* String::Clone()
+{
+ return new String(*this);
+}
+
+void String::SetValue(const std::string& s)
{
plist_set_string_val(_node, s.c_str());
}