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/String.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/String.cpp')
-rw-r--r-- | src/String.cpp | 20 |
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()); } |