This commit is contained in:
peri4
2022-03-21 22:03:47 +03:00
parent 20e0771331
commit 9a8b9c7141
7 changed files with 404 additions and 149 deletions

View File

@@ -20,6 +20,62 @@
#include "pipropertystorage.h"
//! \addtogroup Core
//! \{
//! \~\class PIPropertyStorage pipropertystorage.h
//! \~\brief
//! \~english This class provides key-value properties storage
//! \~russian Этот класс предоставляет ключ-значение хранение свойств
//!
//! \~\details
//! \~english \section PIPropertyStorage_sec0 Synopsis
//! \~russian \section PIPropertyStorage_sec0 Краткий обзор
//!
//! \~english
//! Key-value storage, based on PIVector with PIPropertyStorage::Property elements. Each element in vector
//! contains unique name. You can access property by name with \a propertyValueByName() or \a propertyByName().
//! You can add or replace property by \a addProperty(const Property&) or \a addProperty(const PIString&, const PIVariant&, const PIString&, int).
//!
//! \~russian
//! Хранилище свойств ключ-значние, основанный на PIVector с элементами PIPropertyStorage::Property.
//! Каждый элемент имеет уникальное имя. Доступ к свойствам через \a propertyValueByName() или \a propertyByName().
//! Добавление и перезапись свойств через \a addProperty(const Property&) или \a addProperty(const PIString&, const PIVariant&, const PIString&, int).
//!
//! \~english Example:
//! \~russian Пример:
//! \~\code{.cpp}
//! \endcode
//! \}
//! \addtogroup Core
//! \{
//! \~\class PIPropertyStorage::Property pipropertystorage.h
//! \~\brief
//! \~english PIPropertyStorage element
//! \~russian Элемент PIPropertyStorage
//!
//! \~\details
//! \~english \section PIPropertyStorage_sec0 Synopsis
//! \~russian \section PIPropertyStorage_sec0 Краткий обзор
//!
//! \~english
//! Key-value storage, based on PIVector with PIPropertyStorage::Property elements. Each element in vector
//! contains unique name. You can access property by name with \a propertyValueByName() or \a propertyByName().
//! You can add or replace property by \a addProperty(const Property&) or \a addProperty(const PIString&, const PIVariant&, const PIString&, int).
//!
//! \~russian
//! Хранилище свойств ключ-значние, основанный на PIVector с элементами PIPropertyStorage::Property.
//! Каждый элемент имеет уникальное имя. Доступ к свойствам через \a propertyValueByName() или \a propertyByName().
//! Добавление и перезапись свойств через \a addProperty(const Property&) или \a addProperty(const PIString&, const PIVariant&, const PIString&, int).
//!
//! \~english Example:
//! \~russian Пример:
//! \~\code{.cpp}
//! \endcode
//! \}
bool PIPropertyStorage::isPropertyExists(const PIString & _name) const {
for (uint i = 0; i < props.size(); ++i)
if (props[i].name == _name)
@@ -28,6 +84,9 @@ bool PIPropertyStorage::isPropertyExists(const PIString & _name) const {
}
//! \details
//! \~english Returns "true" if new property added, else if update existing property return "false"
//! \~russian Возвращает истину если новое свойство добавлено, в случае обновления "ложь"
bool PIPropertyStorage::addProperty(const PIPropertyStorage::Property & p) {
for (uint i = 0; i < props.size(); ++i)
if (props[i].name == p.name) {
@@ -50,6 +109,9 @@ bool PIPropertyStorage::addProperty(PIPropertyStorage::Property && p) {
}
//! \details
//! \~english Returns "true" if new property added, else if update existing property return "false"
//! \~russian Возвращает истину если новое свойство добавлено, в случае обновления "ложь"
bool PIPropertyStorage::addProperty(const PIString & _name, const PIVariant & _def_value, const PIString & _comment, int _flags) {
return addProperty(Property(_name, _comment, _def_value, _flags));
}
@@ -66,6 +128,9 @@ bool PIPropertyStorage::removeProperty(const PIString & _name) {
}
//! \details
//! \~english "flag" checked as bitfield
//! \~russian "flag" проверяется как битовое поле
int PIPropertyStorage::removePropertiesByFlag(int flag) {
int ret = 0;
for (int i = 0; i < props.size_s(); ++i) {
@@ -79,6 +144,9 @@ int PIPropertyStorage::removePropertiesByFlag(int flag) {
}
//! \details
//! \~english "flag_ignore" is bitfield to ignore property in merge process
//! \~russian "flag_ignore" - битовое поле для исключения свойств из процесса слияния
void PIPropertyStorage::updateProperties(const PIVector<PIPropertyStorage::Property> & properties_, int flag_ignore) {
PIMap<PIString, PIVariant> values;
piForeachC(Property & p, props)