PIPropertyStorage: add return values and documentation in some functions

This commit is contained in:
2020-11-25 12:39:15 +03:00
parent 65d2f6b6e4
commit e0e8266b59
3 changed files with 76 additions and 29 deletions

View File

@@ -28,41 +28,54 @@ bool PIPropertyStorage::isPropertyExists(const PIString & _name) const {
}
void PIPropertyStorage::addProperty(const PIPropertyStorage::Property & p) {
bool PIPropertyStorage::addProperty(const PIPropertyStorage::Property & p) {
for (uint i = 0; i < props.size(); ++i)
if (props[i].name == p.name) {
props[i] = p;
return;
return false;
}
props << p;
return true;
}
void PIPropertyStorage::addProperty(PIPropertyStorage::Property && p) {
bool PIPropertyStorage::addProperty(PIPropertyStorage::Property && p) {
for (uint i = 0; i < props.size(); ++i)
if (props[i].name == p.name) {
props[i] = std::move(p);
return;
return false;
}
props << std::move(p);
return true;
}
void PIPropertyStorage::removeProperty(const PIString & _name) {
for (uint i = 0; i < props.size(); ++i)
bool PIPropertyStorage::addProperty(const PIString & _name, const PIVariant & _def_value, const PIString & _comment, int _flags) {
return addProperty(Property(_name, _comment, _def_value, _flags));
}
bool PIPropertyStorage::removeProperty(const PIString & _name) {
for (uint i = 0; i < props.size(); ++i) {
if (props[i].name == _name) {
props.remove(i);
return;
return true;
}
}
return false;
}
void PIPropertyStorage::removePropertiesByFlag(int flag) {
for (int i = 0; i < props.size_s(); ++i)
int PIPropertyStorage::removePropertiesByFlag(int flag) {
int ret = 0;
for (int i = 0; i < props.size_s(); ++i) {
if ((props[i].flags & flag) == flag) {
props.remove(i);
--i;
ret++;
}
}
return ret;
}
@@ -99,30 +112,36 @@ PIVariant PIPropertyStorage::propertyValueByName(const PIString & name) const {
}
void PIPropertyStorage::setPropertyValue(const PIString & name, const PIVariant & value) {
for (uint i = 0; i < props.size(); ++i)
bool PIPropertyStorage::setPropertyValue(const PIString & name, const PIVariant & value) {
for (uint i = 0; i < props.size(); ++i) {
if (props[i].name == name) {
props[i].value = value;
return;
return true;
}
}
return false;
}
void PIPropertyStorage::setPropertyComment(const PIString & name, const PIString & comment) {
for (uint i = 0; i < props.size(); ++i)
bool PIPropertyStorage::setPropertyComment(const PIString & name, const PIString & comment) {
for (uint i = 0; i < props.size(); ++i) {
if (props[i].name == name) {
props[i].comment = comment;
return;
return true;
}
}
return false;
}
void PIPropertyStorage::setPropertyFlags(const PIString & name, int flags) {
for (uint i = 0; i < props.size(); ++i)
bool PIPropertyStorage::setPropertyFlags(const PIString & name, int flags) {
for (uint i = 0; i < props.size(); ++i) {
if (props[i].name == name) {
props[i].flags = flags;
return;
return true;
}
}
return false;
}