summaryrefslogtreecommitdiffstats
path: root/src/String.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/String.cpp')
-rw-r--r--src/String.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/String.cpp b/src/String.cpp
index 0965349..2ddc28b 100644
--- a/src/String.cpp
+++ b/src/String.cpp
@@ -18,7 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <stdlib.h>
+#include <cstdlib>
+#include "plist.h"
#include <plist/String.h>
namespace PList
@@ -32,12 +33,12 @@ String::String(plist_t node, Node* parent) : Node(node, parent)
{
}
-String::String(const PList::String& s) : Node(PLIST_UINT)
+String::String(const PList::String& s) : Node(PLIST_INT)
{
plist_set_string_val(_node, s.GetValue().c_str());
}
-String& String::operator=(PList::String& s)
+String& String::operator=(const PList::String& s)
{
plist_free(_node);
_node = plist_copy(s.GetPlist());
@@ -67,14 +68,9 @@ std::string String::GetValue() const
{
char* s = NULL;
plist_get_string_val(_node, &s);
- std::string ret;
- if (s) {
- ret = s;
- free(s);
- } else {
- ret = "";
- }
+ std::string ret = s ? s : "";
+ delete s;
return ret;
}
-};
+} // namespace PList