doc ru
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/*! \file pipropertystorage.h
|
||||
* \brief Storage of properties for GUI usage
|
||||
*
|
||||
* This file declare PIPropertyStorage
|
||||
*/
|
||||
* \~\brief
|
||||
* \~english Properties array
|
||||
* \~russian Массив свойств
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Storage of properties for GUI usage
|
||||
@@ -27,25 +27,28 @@
|
||||
|
||||
#include "pivariant.h"
|
||||
|
||||
/**
|
||||
* \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(const Property&), addProperty(const PIString&, const PIVariant&, const PIString&, int).
|
||||
*/
|
||||
|
||||
class PIP_EXPORT PIPropertyStorage {
|
||||
public:
|
||||
|
||||
//! \~english Contructs an empty %PIPropertyStorage
|
||||
//! \~russian Создает пустой %PIPropertyStorage
|
||||
PIPropertyStorage() {}
|
||||
|
||||
/**
|
||||
* \brief PIPropertyStorage element.
|
||||
*/
|
||||
struct PIP_EXPORT 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) {}
|
||||
Property(const Property & o):
|
||||
name(o.name), comment(o.comment), value(o.value), flags(o.flags) {}
|
||||
|
||||
//! \~english Contructs %PIPropertyStorage::Property with name "n", comment "c", value "v" and flags "f"
|
||||
//! \~russian Создает %PIPropertyStorage::Property с именем "n", комментарием "c", значением "v" и флагами "f"
|
||||
Property(const PIString & n = PIString(), const PIString & c = PIString(), const PIVariant & v = PIVariant(), int f = 0): name(n), comment(c), value(v), flags(f) {}
|
||||
|
||||
//! \~english Contructs copy of another %PIPropertyStorage::Property "o"
|
||||
//! \~russian Создает копию %PIPropertyStorage::Property "o"
|
||||
Property(const Property & o): name(o.name), comment(o.comment), value(o.value), flags(o.flags) {}
|
||||
|
||||
Property(Property && o) {swap(o);}
|
||||
|
||||
//! \~english Assign operator
|
||||
//! \~russian Оператор присваивания
|
||||
Property & operator =(const Property & v) {
|
||||
name = v.name;
|
||||
comment = v.comment;
|
||||
@@ -56,10 +59,24 @@ public:
|
||||
Property & operator =(Property && v) {swap(v); return *this;}
|
||||
|
||||
|
||||
//! \~english Returns value as boolean
|
||||
//! \~russian Возвращает значение как логическое
|
||||
bool toBool() const {return value.toBool();}
|
||||
|
||||
//! \~english Returns value as integer
|
||||
//! \~russian Возвращает значение как целое
|
||||
int toInt() const {return value.toInt();}
|
||||
|
||||
//! \~english Returns value as float
|
||||
//! \~russian Возвращает значение как float
|
||||
float toFloat() const {return value.toFloat();}
|
||||
|
||||
//! \~english Returns value as double
|
||||
//! \~russian Возвращает значение как double
|
||||
double toDouble() const {return value.toDouble();}
|
||||
|
||||
//! \~english Returns value as string
|
||||
//! \~russian Возвращает значение как строку
|
||||
PIString toString() const {return value.toString();}
|
||||
|
||||
void swap(Property & o) {
|
||||
@@ -69,22 +86,30 @@ public:
|
||||
piSwap(flags, o.flags);
|
||||
}
|
||||
|
||||
/*! Uniqueue id of property */
|
||||
//! \~english Property name (uniqueue for %PIPropertyStorage)
|
||||
//! \~russian Имя свойства (уникальное для %PIPropertyStorage)
|
||||
PIString name;
|
||||
|
||||
/*! Optional description of property */
|
||||
//! \~english Optional description of property
|
||||
//! \~russian Опциональный комментарий свойства
|
||||
PIString comment;
|
||||
|
||||
/*! Custom value of property */
|
||||
//! \~english Property value
|
||||
//! \~russian Значение свойства
|
||||
PIVariant value;
|
||||
|
||||
/*! Abstract flags which may be used for user needs */
|
||||
//! \~english Abstract flags which may be used for user needs
|
||||
//! \~russian Абстрактные флаги, могут быть использованы для своих нужд
|
||||
int flags;
|
||||
};
|
||||
|
||||
//! \~english Contructs %PIPropertyStorage with "pl" properties
|
||||
//! \~russian Создает %PIPropertyStorage со свойствами "pl"
|
||||
PIPropertyStorage(const PIVector<Property> & pl) {props = pl;}
|
||||
|
||||
PIPropertyStorage(PIVector<Property> && pl): props(std::move(pl)) {}
|
||||
//! \~english Contructs %PIPropertyStorage from another "o"
|
||||
//! \~russian Создает %PIPropertyStorage из другого "o"
|
||||
PIPropertyStorage(PIVector<Property> && o): props(std::move(o)) {}
|
||||
|
||||
typedef PIVector<Property>::const_iterator const_iterator;
|
||||
typedef PIVector<Property>::iterator iterator;
|
||||
@@ -95,115 +120,140 @@ public:
|
||||
iterator end() {return props.end();}
|
||||
const_iterator end() const {return props.end();}
|
||||
|
||||
//! \~english Returns properties count
|
||||
//! \~russian Возвращает количество свойств
|
||||
int length() const {return props.length();}
|
||||
|
||||
//! \~english Returns properties count
|
||||
//! \~russian Возвращает количество свойств
|
||||
int size() const {return props.size();}
|
||||
|
||||
//! \~english Returns if no properties
|
||||
//! \~russian Возвращает нет ли свойств
|
||||
bool isEmpty() const {return props.isEmpty();}
|
||||
|
||||
//! \~english Returns if properties
|
||||
//! \~russian Возвращает есть ли свойства
|
||||
bool isNotEmpty() const {return props.isNotEmpty();}
|
||||
|
||||
//! \~english Returns first property
|
||||
//! \~russian Возвращает первое свойство
|
||||
Property & front() {return props.front();}
|
||||
|
||||
//! \~english Returns first property as const
|
||||
//! \~russian Возвращает первое свойство как константу
|
||||
const Property & front() const {return props.front();}
|
||||
|
||||
//! \~english Returns last property
|
||||
//! \~russian Возвращает последнее свойство
|
||||
Property & back() {return props.back();}
|
||||
|
||||
//! \~english Returns last property as const
|
||||
//! \~russian Возвращает последнее свойство как константу
|
||||
const Property & back() const {return props.back();}
|
||||
|
||||
//! \~english Remove property at index "i"
|
||||
//! \~russian Удаляет свойство по индексу "i"
|
||||
void removeAt(int i) {props.remove(i);}
|
||||
|
||||
//! \~english Remove all properties
|
||||
//! \~russian Удаляет все свойства
|
||||
void clear() {props.clear();}
|
||||
|
||||
|
||||
//! \~english Returns copy of this %PIPropertyStorage
|
||||
//! \~russian Возвращает копию этого %PIPropertyStorage
|
||||
PIPropertyStorage copy() const {return PIPropertyStorage(*this);}
|
||||
|
||||
//! \~english Returns properties count
|
||||
//! \~russian Возвращает количество свойств
|
||||
int propertiesCount() const {return props.size();}
|
||||
|
||||
//! \~english Returns properties as PIVector
|
||||
//! \~russian Возвращает свойства как PIVector
|
||||
PIVector<Property> & properties() {return props;}
|
||||
|
||||
//! \~english Returns properties as const PIVector
|
||||
//! \~russian Возвращает свойства как константный PIVector
|
||||
const PIVector<Property> & properties() const {return props;}
|
||||
|
||||
const PIPropertyStorage & propertyStorage() const {return *this;}
|
||||
|
||||
/**
|
||||
* \brief Check if property with \a name exists
|
||||
* @return "true" if property exists
|
||||
*/
|
||||
bool isPropertyExists(const PIString & _name) const;
|
||||
//! \~english Returns if properties with name "name" exists
|
||||
//! \~russian Возвращает присутствует ли свойство с именем "name"
|
||||
bool isPropertyExists(const PIString & name) const;
|
||||
|
||||
/**
|
||||
* \brief Remove all properties
|
||||
*/
|
||||
//! \~english Remove all properties
|
||||
//! \~russian Удаляет все свойства
|
||||
void clearProperties() {props.clear();}
|
||||
|
||||
/**
|
||||
* \brief Add property if name isn't present in storage, otherwrise update existing property with same name.
|
||||
* @return "true" if new property added, else if update existing property return "false"
|
||||
* @param p to copy in storage
|
||||
*/
|
||||
//! \~english Add property if name isn't present in storage, otherwrise update existing property with same name
|
||||
//! \~russian Добавляет новое свойство, если его имени не было в контейнере, иначе обновляет существующее свойство с этим именем
|
||||
bool addProperty(const Property & p);
|
||||
bool addProperty(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.
|
||||
* @return "true" if new property added, else if update existing property return "false"
|
||||
*/
|
||||
//! \~english Add property if name isn't present in storage, otherwrise update existing property with same name
|
||||
//! \~russian Добавляет новое свойство, если его имени не было в контейнере, иначе обновляет существующее свойство с этим именем
|
||||
bool addProperty(const PIString & _name, const PIVariant & _def_value, const PIString & _comment = PIString(), int _flags = 0);
|
||||
|
||||
/**
|
||||
* \brief Remove property with \a name
|
||||
* @return "true" if property exists and removed
|
||||
*/
|
||||
bool removeProperty(const PIString & _name);
|
||||
//! \~english Remove property with name "name", returns if property removed
|
||||
//! \~russian Удаляет свойство с именем "name", возвращает было ли оно удалено
|
||||
bool removeProperty(const PIString & name);
|
||||
|
||||
/**
|
||||
* \brief Remove properties wich has \a flag set
|
||||
* @return removed properties count
|
||||
*/
|
||||
//! \~english Remove all properties with flag "flag" set, returns removed properties count
|
||||
//! \~russian Удаляет все свойства с флагом "flag", возвращает количество удаленных свойств
|
||||
int removePropertiesByFlag(int flag);
|
||||
|
||||
/**
|
||||
* \brief Merge other \a properties_ into this
|
||||
* @param flag_ignore - properties wich has this flag set will be ignored in merge
|
||||
*/
|
||||
void updateProperties(const PIVector<Property> & properties_, int flag_ignore = 0);
|
||||
//! \~english Merge other "properties" into this
|
||||
//! \~russian Объединяет "properties" с текущим контейнером
|
||||
void updateProperties(const PIVector<Property> & properties, int flag_ignore = 0);
|
||||
|
||||
/**
|
||||
* \brief Search property by name and return it.
|
||||
*
|
||||
* @param name of property
|
||||
* @return property value or default constructed Property
|
||||
*/
|
||||
//! \~english Returns property with name "name" or default-constructed %PIPropertyStorage::Property
|
||||
//! \~russian Возвращает свойство с именем "name" или пустое %PIPropertyStorage::Property
|
||||
Property propertyByName(const PIString & name) const;
|
||||
|
||||
/**
|
||||
* \brief Search property by name and return property value.
|
||||
*
|
||||
* @param name of property
|
||||
* @return property value or invalid PIVariant if name unknown
|
||||
*/
|
||||
//! \~english Returns property value with name "name" or invalid %PIVariant
|
||||
//! \~russian Возвращает значение свойства с именем "name" или недействительный %PIVariant
|
||||
PIVariant propertyValueByName(const PIString & name) const;
|
||||
|
||||
/**
|
||||
* \brief Set value of property with specific name if name is present in storage.
|
||||
*
|
||||
* @param name of property to set value
|
||||
* @param value to set
|
||||
* @return "true" if property exists and updated
|
||||
*/
|
||||
//! \~english Set value of property with name "name" to "value", returns if property exists
|
||||
//! \~russian Устанавливает значение "value" свойству с именем "name", возвращает существует ли такое свойство
|
||||
bool setPropertyValue(const PIString & name, const PIVariant & value);
|
||||
|
||||
/**
|
||||
* \brief Set comment of property with specific name if name is present in storage.
|
||||
*
|
||||
* @param name of property to set comment
|
||||
* @param comment to set
|
||||
* @return "true" if property exists and updated
|
||||
*/
|
||||
//! \~english Set comment of property with name "name" to "comment", returns if property exists
|
||||
//! \~russian Устанавливает комментарий "comment" свойству с именем "name", возвращает существует ли такое свойство
|
||||
bool setPropertyComment(const PIString & name, const PIString & comment);
|
||||
|
||||
/**
|
||||
* \brief Set flags of property with specific name if name is present in storage.
|
||||
*
|
||||
* @param name of property to set flags
|
||||
* @param flags to set
|
||||
* @return "true" if property exists and updated
|
||||
*/
|
||||
//! \~english Set flags of property with name "name" to "flags", returns if property exists
|
||||
//! \~russian Устанавливает флаги "flags" свойству с именем "name", возвращает существует ли такое свойство
|
||||
bool setPropertyFlags(const PIString & name, int flags);
|
||||
|
||||
//! \~english Add property "p"
|
||||
//! \~russian Добавляет свойство "p"
|
||||
PIPropertyStorage & operator <<(const PIPropertyStorage::Property & p) {props << p; return *this;}
|
||||
|
||||
//! \~english Add properties "p"
|
||||
//! \~russian Добавляет свойства "p"
|
||||
PIPropertyStorage & operator <<(const PIVector<Property> & p) {props << p; return *this;}
|
||||
|
||||
//! \~english Add properties "p"
|
||||
//! \~russian Добавляет свойства "p"
|
||||
PIPropertyStorage & operator <<(const PIPropertyStorage & p) {props << p.props; return *this;}
|
||||
|
||||
//! \~english Returns property with index "i"
|
||||
//! \~russian Возвращает свойство по индексу "i"
|
||||
Property & operator[](int i) {return props[i];}
|
||||
|
||||
//! \~english Returns property with index "i" as const
|
||||
//! \~russian Возвращает свойство по индексу "i" как константу
|
||||
const Property & operator[](int i) const {return props[i];}
|
||||
|
||||
//! \~english Returns property with name "name"
|
||||
//! \~russian Возвращает свойство с именем "name"
|
||||
Property & operator[](const PIString & name);
|
||||
|
||||
//! \~english Returns property with name "name" as const
|
||||
//! \~russian Возвращает свойство с именем "name" как константу
|
||||
const Property operator[](const PIString & name) const;
|
||||
|
||||
static Property parsePropertyLine(PIString l);
|
||||
|
||||
Reference in New Issue
Block a user