summaryrefslogtreecommitdiffstats
path: root/src/String.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/String.cpp')
-rw-r--r--src/String.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/String.cpp b/src/String.cpp
index 2ddc28b..8daec0f 100644
--- a/src/String.cpp
+++ b/src/String.cpp
@@ -45,11 +45,30 @@ String& String::operator=(const PList::String& s)
return *this;
}
+String& String::operator=(const std::string& s)
+{
+ plist_free(_node);
+ _node = plist_new_string(s.c_str());
+ return *this;
+}
+
+String& String::operator=(const char* s)
+{
+ plist_free(_node);
+ _node = plist_new_string(s);
+ return *this;
+}
+
String::String(const std::string& s) : Node(PLIST_STRING)
{
plist_set_string_val(_node, s.c_str());
}
+String::String(const char *s) : Node(PLIST_STRING)
+{
+ plist_set_string_val(_node, s);
+}
+
String::~String()
{
}
@@ -66,10 +85,8 @@ void String::SetValue(const std::string& s)
std::string String::GetValue() const
{
- char* s = NULL;
- plist_get_string_val(_node, &s);
+ const char* s = plist_get_string_ptr(_node, NULL);
std::string ret = s ? s : "";
- delete s;
return ret;
}