aboutsummaryrefslogtreecommitdiff
path: root/backend/Object.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-30 19:59:38 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-30 19:59:38 +0100
commit6e1d62955c7a7f39bc9126d709a42a70e02a1d30 (patch)
treec2505409c68d554b1e776cdb0c8104af54d375bf /backend/Object.cpp
parentc1d43cddee94dd370078f755d33147c9a8181852 (diff)
create backend string class
Diffstat (limited to 'backend/Object.cpp')
-rw-r--r--backend/Object.cpp34
1 files changed, 10 insertions, 24 deletions
diff --git a/backend/Object.cpp b/backend/Object.cpp
index ed8bc46..2640607 100644
--- a/backend/Object.cpp
+++ b/backend/Object.cpp
@@ -1,36 +1,22 @@
-#include <string.h>
-#include <stdlib.h>
-
#include "Object.h"
-#include "util.h"
-
-Object::Object(const char * name, const char * description) {
- this->set_name(name);
- this->set_description(description);
-}
-
-Object::~Object() {
- safe_free(this->name);
- safe_free(this->description);
-}
+Object::Object(const String & name, const String & description) : name(name), description(description) { }
-void Object::set_name(const char * name) {
- safe_free(this->name);
- this->name = strdup(name);
+void Object::set_name(const String & name) {
+ this->name = name;
}
-const char * Object::get_name() {
+const String & Object::get_name() const {
return this->name;
}
-const char * Object::get_displayname() {
- return this->get_name();
+const String & Object::get_displayname() const {
+ static String displayname = this->name;
+ return displayname;
}
-void Object::set_description(const char * description) {
- safe_free(this->description);
- this->description = strdup(description);
+void Object::set_description(const String & description) {
+ this->description = description;
}
-const char * Object::get_description() {
+const String & Object::get_description() const {
return this->description;
}