From c5f45c9d2cef13974c08773cd0f788de12ee2ce4 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 7 Mar 2012 20:35:50 +0000 Subject: Added Properties copy constructor and assignment operator. --- src/properties.cc | 24 ++++++++++++++++++++++++ src/properties.h | 18 ++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/properties.cc b/src/properties.cc index c9263cb..ad40adc 100644 --- a/src/properties.cc +++ b/src/properties.cc @@ -14,10 +14,34 @@ Properties::Properties() { } +Properties::Properties(const Properties & other) +{ + assign(other); +} + Properties::~Properties() { } +void Properties::assign(const Properties & other) +{ + properties_comment = other.properties_comment; + + properties_comments.clear(); + for (Comments::const_iterator i = properties_comments.constBegin(); i != properties_comments.constEnd(); ++i) { + set_comment(i.key(), i.value()); + } + + properties_label = other.properties_label; + properties_name = other.properties_name; + + properties_location = other.properties_location; + properties_color = other.properties_color; + + properties_info = other.properties_info; + properties_values = other.properties_values; +} + void Properties::add_value(const QString &key, const QString &value, const QString &comment) { if (comment.size()) diff --git a/src/properties.h b/src/properties.h index efde85b..89c9c93 100644 --- a/src/properties.h +++ b/src/properties.h @@ -26,6 +26,11 @@ class Properties public: Properties(); + /** + * @brief copy constructor + * */ + Properties(const Properties & other); + virtual ~Properties(); /* ---- inspectors ---- */ @@ -88,6 +93,19 @@ public: /* ---- mutators ---- */ + /** + * @brief assign all values of another Properties instance to this instance + * */ + void assign(const Properties & other); + + /** + * @brief assignment operator + * */ + inline Properties & operator=(const Properties & other) { + assign(other); + return *this; + } + /** * @brief set the comments string of this object * */ -- cgit v1.2.3