From 0cf6366aa81965817123304e743a6b3a9c3a75e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D0=BE=D0=BC=D0=B5=D0=BD=D0=BA=D0=BE=20=D0=A1=D1=82?= =?UTF-8?q?=D0=B5=D0=BF=D0=B0=D0=BD=20=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D0=BC?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B8=D1=87?= Date: Thu, 19 Sep 2019 16:34:12 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@854 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- src_main/core/pipropertystorage.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src_main/core/pipropertystorage.h b/src_main/core/pipropertystorage.h index 09486278..4a055346 100644 --- a/src_main/core/pipropertystorage.h +++ b/src_main/core/pipropertystorage.h @@ -30,7 +30,7 @@ /** * @brief Key-value storage, based on PIVector with PIPropertyStorage::Property elements. Each element in vector * contains unique name and you can identify property by name with propertyValueByName(), propertyByName(). - * You can add property using addProperty(). + * You can add property using addProperty(const Property&), addProperty(const PIString&, const PIVariant&, const PIString&, int). */ class PIPropertyStorage { public: @@ -42,14 +42,23 @@ public: struct Property { Property(const PIString & n = PIString(), const PIString & c = PIString(), const PIVariant & v = PIVariant(), int f = 0): name(n), comment(c), value(v), flags(f) {} + bool toBool() const {return value.toBool();} int toInt() const {return value.toInt();} float toFloat() const {return value.toFloat();} double toDouble() const {return value.toDouble();} PIString toString() const {return value.toString();} + + /*! Uniqueue id of property */ PIString name; + + /*! Optional description of property */ PIString comment; + + /*! Custom value of property */ PIVariant value; + + /*! Abstract flags which may be used for user needs */ int flags; }; @@ -81,7 +90,18 @@ public: const PIPropertyStorage & propertyStorage() const {return *this;} bool isPropertyExists(const PIString & _name) const; void clearProperties() {props.clear();} + + /** + * @brief Add property if name isn't present in storage, otherwrise update existing property with same name. + * + * @param p to copy in storage + */ void addProperty(const Property & p); + + /** + * @brief First of all construct Property with method params. After then add property if name isn't present + * in storage, otherwrise update existing property with same name. + */ void addProperty(const PIString & _name, const PIVariant & _def_value, const PIString & _comment = PIString(), int _flags = 0) {addProperty(Property(_name, _comment, _def_value, _flags));} void removeProperty(const PIString & _name); void removePropertiesByFlag(int flag);