From ed8a73301b844bf5f7efd9cd437c9c0765a49a88 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sun, 6 Apr 2025 11:48:14 +0200 Subject: C++: Add = operator to String class --- include/plist/String.h | 1 + src/String.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/plist/String.h b/include/plist/String.h index 7e8a6e4..95f8dd1 100644 --- a/include/plist/String.h +++ b/include/plist/String.h @@ -35,6 +35,7 @@ public : String(plist_t node, Node* parent = NULL); String(const String& s); String& operator=(const String& s); + String& operator=(const std::string& s); String& operator=(const char* s); String(const std::string& s); String(const char *s); diff --git a/src/String.cpp b/src/String.cpp index 5bae804..8daec0f 100644 --- a/src/String.cpp +++ b/src/String.cpp @@ -45,6 +45,13 @@ 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); -- cgit v1.1-32-gdbae