doc ru
This commit is contained in:
@@ -78,11 +78,11 @@ public:
|
||||
//! \~russian Устанавливает флаг "i" в "on"
|
||||
PIFlags & setFlag(const int & i, bool on = true) {if (on) flags |= i; else flags &= ~i; return *this;}
|
||||
|
||||
//! \~english Copy operator
|
||||
//! \~english Assign operator
|
||||
//! \~russian Оператор присваивания
|
||||
void operator =(const Enum & e) {flags = e;}
|
||||
|
||||
//! \~english Copy operator
|
||||
//! \~english Assign operator
|
||||
//! \~russian Оператор присваивания
|
||||
void operator =(const int & i) {flags = i;}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*! \file pipropertystorage.h
|
||||
* \brief Storage of properties for GUI usage
|
||||
*
|
||||
* This file declare PIPropertyStorage
|
||||
* \~\brief
|
||||
* \~english Properties array
|
||||
* \~russian Массив свойств
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
@@ -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);
|
||||
|
||||
@@ -20,6 +20,52 @@
|
||||
#include "pistringlist.h"
|
||||
|
||||
|
||||
//! \addtogroup Core
|
||||
//! \{
|
||||
//! \~\class PIStringList pistringlist.h
|
||||
//! \~\brief
|
||||
//! \~english Based on \a PIDeque<PIString> strings list
|
||||
//! \~russian Основанный на \a PIDeque<PIString> массив строк
|
||||
//!
|
||||
//! \~\details
|
||||
//!
|
||||
//! \}
|
||||
|
||||
|
||||
//! \details
|
||||
//! \~english Example:
|
||||
//! \~russian Пример:
|
||||
//! \~\snippet pistring.cpp PIStringList::join
|
||||
PIString PIStringList::join(const PIString & delim) const {
|
||||
PIString s;
|
||||
for (uint i = 0; i < size(); ++i) {
|
||||
s += at(i);
|
||||
if (i < size() - 1)
|
||||
s += delim;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
//! \details
|
||||
//! \~english Example:
|
||||
//! \~russian Пример:
|
||||
//! \~\snippet pistring.cpp PIStringList::removeStrings
|
||||
PIStringList & PIStringList::removeStrings(const PIString & value) {
|
||||
for (uint i = 0; i < size(); ++i) {
|
||||
if (at(i) == value) {
|
||||
remove(i);
|
||||
--i;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//! \details
|
||||
//! \~english Example:
|
||||
//! \~russian Пример:
|
||||
//! \~\snippet pistring.cpp PIStringList::removeDuplicates
|
||||
PIStringList& PIStringList::removeDuplicates() {
|
||||
PIStringList l;
|
||||
PIString s;
|
||||
@@ -40,3 +86,14 @@ PIStringList& PIStringList::removeDuplicates() {
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//! \details
|
||||
//! \~english Example:
|
||||
//! \~russian Пример:
|
||||
//! \~\snippet pistring.cpp PIStringList::trim
|
||||
PIStringList & PIStringList::trim() {
|
||||
for (uint i = 0; i < size(); ++i)
|
||||
(*this)[i].trim();
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/*! \brief Strings array class
|
||||
* \details This class is based on \a PIDeque<PIString> and
|
||||
* expand it functionality. */
|
||||
/*! \file pistringlist.h
|
||||
* \~\brief
|
||||
* \~english Based on \a PIDeque<PIString> strings list
|
||||
* \~russian Основанный на \a PIDeque<PIString> массив строк
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Strings array class
|
||||
@@ -30,80 +32,108 @@ class PIP_EXPORT PIStringList: public PIDeque<PIString>
|
||||
{
|
||||
public:
|
||||
|
||||
//! Contructs empty strings list
|
||||
//! \~english Contructs an empty strings list
|
||||
//! \~russian Создает пустой список строк
|
||||
PIStringList() {;}
|
||||
|
||||
~PIStringList() {;}
|
||||
|
||||
//! Contructs strings list with one string "str"
|
||||
//! \~english Contructs strings list with one string "str"
|
||||
//! \~russian Создает список строк с одной строкой "str"
|
||||
PIStringList(const PIString & str) {push_back(str);}
|
||||
PIStringList(PIString && str) {push_back(std::move(str));}
|
||||
|
||||
//! Contructs empty strings list with strings "s0" and "s1"
|
||||
//! \~english Contructs strings list with strings "s0" and "s1"
|
||||
//! \~russian Создает список строк со строками "s0" и "s1"
|
||||
PIStringList(const PIString & s0, const PIString & s1) {push_back(s0); push_back(s1);}
|
||||
PIStringList(PIString && s0, PIString && s1) {push_back(std::move(s0)); push_back(std::move(s1));}
|
||||
|
||||
//! Contructs empty strings list with strings "s0", "s1" and "s2"
|
||||
//! \~english Contructs strings list with strings "s0", "s1" and "s2"
|
||||
//! \~russian Создает список строк со строками "s0", "s1" и "s2"
|
||||
PIStringList(const PIString & s0, const PIString & s1, const PIString & s2) {push_back(s0); push_back(s1); push_back(s2);}
|
||||
PIStringList(PIString && s0, PIString && s1, PIString && s2) {push_back(std::move(s0)); push_back(std::move(s1)); push_back(std::move(s2));}
|
||||
|
||||
//! Contructs empty strings list with strings "s0", "s1", "s2" and "s3"
|
||||
//! \~english Contructs strings list with strings "s0", "s1", "s2" and "s3"
|
||||
//! \~russian Создает список строк со строками "s0", "s1", "s2" и "s3"
|
||||
PIStringList(const PIString & s0, const PIString & s1, const PIString & s2, const PIString & s3) {push_back(s0); push_back(s1); push_back(s2); push_back(s3);}
|
||||
PIStringList(PIString && s0, PIString && s1, PIString && s2, PIString && s3) {push_back(std::move(s0)); push_back(std::move(s1)); push_back(std::move(s2)); push_back(std::move(s3));}
|
||||
|
||||
//! \~english Contructs strings list with strings "o"
|
||||
//! \~russian Создает список строк со строками "o"
|
||||
PIStringList(const PIStringList & o): PIDeque<PIString>(o) {}
|
||||
PIStringList(PIStringList && o): PIDeque<PIString>(std::move(o)) {}
|
||||
|
||||
//! \~english Contructs strings list with strings "o"
|
||||
//! \~russian Создает список строк со строками "o"
|
||||
PIStringList(const PIVector<PIString> & o): PIDeque<PIString>() {resize(o.size()); for (uint i = 0; i < size(); ++i) (*this)[i] = o[i];}
|
||||
|
||||
//! \~english Contructs strings list with strings "o"
|
||||
//! \~russian Создает список строк со строками "o"
|
||||
PIStringList(const PIDeque<PIString> & o): PIDeque<PIString>() {resize(o.size()); for (uint i = 0; i < size(); ++i) (*this)[i] = o[i];}
|
||||
|
||||
//! Contructs strings list with std::initializer_list
|
||||
//! \~english Contructs strings list with strings "init_list" in std::initializer_list format
|
||||
//! \~russian Создает список строк со строками "init_list" в формате std::initializer_list
|
||||
PIStringList(std::initializer_list<PIString> init_list): PIDeque<PIString>(init_list) {}
|
||||
|
||||
|
||||
//! \brief Join all strings in one with delimiter "delim" and return it
|
||||
//! \details Example: \snippet pistring.cpp PIStringList::join
|
||||
PIString join(const PIString & delim) const {PIString s; for (uint i = 0; i < size(); ++i) {s += at(i); if (i < size() - 1) s += delim;} return s;}
|
||||
//! \~english Join all strings in one with delimiter "delim" and returns it
|
||||
//! \~russian Соединяет все строки в одну через разделитель "delim" и возвращает её
|
||||
PIString join(const PIString & delim) const;
|
||||
|
||||
//! \brief Remove all strings equal "value" and return this
|
||||
//! \details Example: \snippet pistring.cpp PIStringList::removeStrings
|
||||
PIStringList & removeStrings(const PIString & value) {for (uint i = 0; i < size(); ++i) {if (at(i) == value) {remove(i); --i;}} return *this;}
|
||||
//! \~english Remove all strings equal "value" and returns reference to this
|
||||
//! \~russian Удаляет все строки равные "value" и возвращает ссылку на этот список строк
|
||||
PIStringList & removeStrings(const PIString & value);
|
||||
|
||||
PIStringList & remove(uint num) {PIDeque<PIString>::remove(num); return *this;}
|
||||
PIStringList & remove(uint num, uint count) {PIDeque<PIString>::remove(num, count); return *this;}
|
||||
|
||||
//! \brief Remove duplicated strings and return this
|
||||
//! \details Example: \snippet pistring.cpp PIStringList::removeDuplicates
|
||||
//! \~english Remove duplicated strings and returns reference to this
|
||||
//! \~russian Удаляет все дублированные строки и возвращает ссылку на этот список строк
|
||||
PIStringList & removeDuplicates();
|
||||
|
||||
//! \brief Trim all strings
|
||||
//! \details Example: \snippet pistring.cpp PIString::trim
|
||||
PIStringList & trim() {for (uint i = 0; i < size(); ++i) (*this)[i].trim(); return *this;}
|
||||
//! \~english Trim all strings and returns reference to this
|
||||
//! \~russian Подчищает у всех строк пробельные символы в начале и в конце и возвращает ссылку на этот список строк
|
||||
PIStringList & trim();
|
||||
|
||||
//! Return sum of lengths of all strings
|
||||
//! \~english Returns sum of lengths of all strings
|
||||
//! \~russian Возвращает сумму длин всех строк
|
||||
uint contentSize() {uint s = 0; for (uint i = 0; i < size(); ++i) s += at(i).size(); return s;}
|
||||
|
||||
//! Compare operator
|
||||
//! \~english Compare operator
|
||||
//! \~russian Оператор сравнения
|
||||
bool operator ==(const PIStringList & o) const {if (size() != o.size()) return false; for (size_t i = 0; i < size(); ++i) if (o[i] != (*this)[i]) return false; return true;}
|
||||
|
||||
//! Compare operator
|
||||
//! \~english Compare operator
|
||||
//! \~russian Оператор сравнения
|
||||
bool operator !=(const PIStringList & o) const {return !(o == (*this));}
|
||||
|
||||
//! \~english Assign operator
|
||||
//! \~russian Оператор присваивания
|
||||
PIStringList & operator =(const PIStringList & o) {PIDeque<PIString>::operator=(o); return *this;}
|
||||
|
||||
//! \~english Append string "str"
|
||||
//! \~russian Добавляет строку "str"
|
||||
PIStringList & operator <<(const PIString & str) {append(str); return *this;}
|
||||
PIStringList & operator <<(PIString && str) {append(std::move(str)); return *this;}
|
||||
|
||||
//! \~english Append strings list "sl"
|
||||
//! \~russian Добавляет список строк "sl"
|
||||
PIStringList & operator <<(const PIStringList & sl) {append(sl); return *this;}
|
||||
|
||||
};
|
||||
|
||||
|
||||
//! \relatesalso PIByteArray \brief Output operator to PIByteArray
|
||||
//! \relatesalso PIByteArray
|
||||
//! \~english Store operator
|
||||
//! \~russian Оператор сохранения
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIStringList & v) {s << int(v.size_s()); for (int i = 0; i < v.size_s(); ++i) s << v[i]; return s;}
|
||||
|
||||
//! relatesalso PIByteArray \brief Input operator from PIByteArray
|
||||
//! \relatesalso PIByteArray
|
||||
//! \~english Restore operator
|
||||
//! \~russian Оператор извлечения
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIStringList & v) {int sz; s >> sz; v.resize(sz); for (int i = 0; i < sz; ++i) s >> v[i]; return s;}
|
||||
|
||||
//! \relatesalso PICout \brief Output operator to PICout
|
||||
//! \relatesalso PICout
|
||||
//! \~english Output operator to \a PICout
|
||||
//! \~russian Оператор вывода в \a PICout
|
||||
inline PICout operator <<(PICout s, const PIStringList & v) {s.space(); s.setControl(0, true); s << "{"; for (uint i = 0; i < v.size(); ++i) {s << "\"" << v[i] << "\""; if (i < v.size() - 1) s << ", ";} s << "}"; s.restoreControl(); return s;}
|
||||
|
||||
#endif // PISTRINGLIST_H
|
||||
|
||||
@@ -39,31 +39,73 @@
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
||||
/*! \class PISystemTime
|
||||
* \brief System time
|
||||
*
|
||||
* \section PISystemTime_sec0 Synopsis
|
||||
* This class provide arithmetic functions for POSIX system time.
|
||||
* This time represents as seconds and nanosecons in integer formats.
|
||||
* You can take current system time with function \a PISystemTime::current(),
|
||||
* compare times, sum or subtract two times, convert time to/from
|
||||
* seconds, milliseconds, microseconds or nanoseconds.
|
||||
* \section PISystemTime_sec1 Example
|
||||
* \snippet pitimer.cpp system_time
|
||||
*/
|
||||
//! \addtogroup Core
|
||||
//! \{
|
||||
//! \class PISystemTime pitime.h
|
||||
//! \brief
|
||||
//! \~english System time with nanosecond precision
|
||||
//! \~russian Системное время с точностью до наносекунд
|
||||
//!
|
||||
//! \~english \section PISystemTime_sec0 Synopsis
|
||||
//! \~russian \section PISystemTime_sec0 Краткий обзор
|
||||
//! \~english
|
||||
//! This class provide arithmetic functions for POSIX system time.
|
||||
//! This time represents as seconds and nanosecons in integer formats.
|
||||
//! You can take current system time with function \a PISystemTime::current(),
|
||||
//! compare times, sum or subtract two times, convert time to/from
|
||||
//! seconds, milliseconds, microseconds or nanoseconds.
|
||||
//!
|
||||
//! \~russian
|
||||
//! Этот класс предоставляет арифметику для системного времени в формате POSIX.
|
||||
//! Это время представлено в виде целочисленных секунд и наносекунд.
|
||||
//! Можно взять текущее время с помощью метода \a PISystemTime::current(),
|
||||
//! сравнивать, суммировать и вычитать времена, преобразовывать в/из
|
||||
//! секунд, миллисекунд, микросекунд и наносекунд.
|
||||
//!
|
||||
//! \~english \section PISystemTime_sec1 Example
|
||||
//! \~russian \section PISystemTime_sec1 Пример
|
||||
//! \~\snippet pitimer.cpp system_time
|
||||
//!
|
||||
//! \}
|
||||
|
||||
|
||||
/*! \class PITimeMeasurer
|
||||
* \brief Time measurements
|
||||
*
|
||||
* \section PITimeMeasurer_sec0 Synopsis
|
||||
* Function \a reset() set time mark to current
|
||||
* system time, then functions double elapsed_*() returns time elapsed from this mark.
|
||||
* These functions can returns nano-, micro-, milli- and seconds with suffixes "n", "u", "m"
|
||||
* and "s"
|
||||
*/
|
||||
//! \addtogroup Core
|
||||
//! \{
|
||||
//! \class PITimeMeasurer pitime.h
|
||||
//! \brief
|
||||
//! \~english Time measurements
|
||||
//! \~russian Измерение времени
|
||||
//!
|
||||
//! \~english \section PITimeMeasurer_sec0 Usage
|
||||
//! \~russian \section PITimeMeasurer_sec0 Использование
|
||||
//! \~english
|
||||
//! Function \a reset() set time mark to current
|
||||
//! system time, then functions "double elapsed_*()" returns time elapsed from this mark.
|
||||
//! These functions can returns nano-, micro-, milli- and seconds with suffixes "n", "u", "m"
|
||||
//! and "s"
|
||||
//!
|
||||
//! \~russian
|
||||
//! Метод \a reset() устанавливает текущую метку системного времени. Далее методы
|
||||
//! "double elapsed_*()" возвращают время, прошедшее от установленной метки.
|
||||
//! Эти методы возвращают нано, микро, милли и секунды с приставками
|
||||
//! "n", "u", "m" и "s".
|
||||
//!
|
||||
//! \}
|
||||
|
||||
|
||||
//! \details
|
||||
//! \~english
|
||||
//! This function consider \c "usleep" offset
|
||||
//! on QNX/Linux/Mac, which is calculated with
|
||||
//! \a pip_sys_test program. If this is correct
|
||||
//! offset value in system config, this function
|
||||
//! wait \b exactly "usecs" microseconds.
|
||||
//! \~russian
|
||||
//! Этот метод учитывает смещение \c "usleep"
|
||||
//! на QNX/Linux/Mac, которое расчитывается с помощью
|
||||
//! утилиты \a pip_sys_test. Если это значение в системном
|
||||
//! конфиге действительно, то этот метод будет ожидать
|
||||
//! \b точно "usecs" микросекунд.
|
||||
void piUSleep(int usecs) {
|
||||
if (usecs <= 0) return;
|
||||
#ifdef WINDOWS
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
/*! \file pitime.h
|
||||
* \brief Time structs
|
||||
* \ingroup Core
|
||||
* \~\brief
|
||||
* \~english Time structs and methods
|
||||
* \~russian Типы и методы времени
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
@@ -30,23 +33,28 @@
|
||||
# include <time.h>
|
||||
#endif
|
||||
|
||||
/*! \brief Precise sleep for "usecs" microseconds
|
||||
* \details This function consider \c "usleep" offset
|
||||
* on QNX/Linux/Mac, which is calculated with
|
||||
* \a pip_sys_test program. If there is correct
|
||||
* offset value in system config, this function
|
||||
* wait \b exactly "usecs" microseconds. */
|
||||
//! \~english Precise sleep for "usecs" microseconds
|
||||
//! \~russian Точно ожидает "usecs" микросекунд
|
||||
PIP_EXPORT void piUSleep(int usecs); // on !Windows consider constant "usleep" offset
|
||||
|
||||
/*! \brief Precise sleep for "msecs" milliseconds
|
||||
* \details This function exec \a piUSleep (msecs * 1000). */
|
||||
//! ~\brief
|
||||
//! \~english Precise sleep for "msecs" milliseconds
|
||||
//! \~russian Точно ожидает "msecs" миллисекунд
|
||||
//! ~\details
|
||||
//! \~english This function exec \a piUSleep (msecs * 1000)
|
||||
//! \~russian Этот метод вызывает \a piUSleep (msecs * 1000)
|
||||
inline void piMSleep(double msecs) {piUSleep(int(msecs * 1000.));} // on !Windows consider constant "usleep" offset
|
||||
|
||||
/*! \brief Precise sleep for "secs" seconds
|
||||
* \details This function exec \a piUSleep (msecs * 1000000). */
|
||||
//! ~\brief
|
||||
//! \~english Precise sleep for "secs" seconds
|
||||
//! \~russian Точно ожидает "secs" секунд
|
||||
//! ~\details
|
||||
//! \~english This function exec \a piUSleep (msecs * 1000000)
|
||||
//! \~russianЭтот метод вызывает \a piUSleep (msecs * 1000000)
|
||||
inline void piSleep(double secs) {piUSleep(int(secs * 1000000.));} // on !Windows consider constant "usleep" offset
|
||||
|
||||
//! Shortest available on current system sleep
|
||||
//! \~english Shortest available on current system sleep
|
||||
//! \~russian Наименее возможное для данной системы по длительности ожидание
|
||||
inline void piMinSleep() {piMSleep(PIP_MIN_MSLEEP);}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user